Skip to content

Commit

Permalink
Linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-phaf committed Dec 13, 2024
1 parent 76ace7d commit 49c1944
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
21 changes: 10 additions & 11 deletions api/load-test/locust-ewc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ def on_start(self):
stations = response.json()["features"]
self.stations = {s["id"]: s["properties"]["parameter-name"] for s in stations}
self.station_ids = list(self.stations.keys())
self.stations_by_location = {(s["geometry"]["coordinates"][0],s["geometry"]["coordinates"][1]): s["properties"]["parameter-name"] for s in stations}
self.stations_by_location = {
(s["geometry"]["coordinates"][0], s["geometry"]["coordinates"][1]): s["properties"]["parameter-name"]
for s in stations
}
self.station_locations = list(self.stations_by_location.keys())

# @task
Expand All @@ -39,13 +42,13 @@ def on_start(self):
def get_data_single_station_single_parameter_last_x_hours(self):
hours = random.choice(hours_choice)
date_time = datetime.now(UTC) - timedelta(hours=hours)
dt_string = date_time.strftime('%Y-%m-%dT%H:%M:%SZ')
dt_string = date_time.strftime("%Y-%m-%dT%H:%M:%SZ")
station_id = random.choice(self.station_ids)
parameter = random.choice(self.stations[station_id])
response = self.client.get(
f"/collections/observations/locations/{station_id}?parameter-name={parameter}&datetime={dt_string}/..",
name=f"location {hours:02d} hours",
headers=headers
headers=headers,
)

@task
Expand All @@ -55,27 +58,23 @@ def get_data_single_position_single_parameter(self):
response = self.client.get(
f"/collections/observations/position?coords=POINT({lon} {lat})&parameter-name={parameter}",
name="position",
headers=headers
headers=headers,
)

@task
def get_data_area_single_parameter_last_hour(self):
date_time = datetime.now(UTC) - timedelta(hours=1)
dt_string = date_time.strftime('%Y-%m-%dT%H:%M:%SZ')
dt_string = date_time.strftime("%Y-%m-%dT%H:%M:%SZ")
standard_name = random.choice(common_standard_names)
(cx, cy) = random.choice(self.station_locations)
sz = random.choice(polygon_size)/2.0
sz = random.choice(polygon_size) / 2.0
left = cx - sz
bottom = cy - sz
right = cx + sz
top = cy + sz
polygon = f"POLYGON(({left} {bottom},{right} {bottom},{right} {top},{left} {top},{left} {bottom}))"
url = f"/collections/observations/area?coords={polygon}&standard_names={standard_name}&datetime={dt_string}/.."
response = self.client.get(
url,
name=f"area {sz*2.0}deg x {sz*2.0}deg x 1h",
headers=headers
)
response = self.client.get(url, name=f"area {sz*2.0}deg x {sz*2.0}deg x 1h", headers=headers)
# if sz == 2.0:
# j = response.json()
# # print(sz*2.0)
Expand Down
8 changes: 6 additions & 2 deletions api/load-test/locustfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
from locust import HttpUser
from locust import task

parameters = ["wind_speed:10.0:mean:PT10M", "wind_speed:10.0:mean:PT10M", "relative_humidity:2.0:mean:PT1M",
"air_temperature:2.0:mean:PT1M"]
parameters = [
"wind_speed:10.0:mean:PT10M",
"wind_speed:10.0:mean:PT10M",
"relative_humidity:2.0:mean:PT1M",
"air_temperature:2.0:mean:PT1M",
]
# fmt: off
stations = [
"0-20000-0-06203", "0-20000-0-06204", "0-20000-0-06205", "0-20000-0-06207", "0-20000-0-06208", "0-20000-0-06211",
Expand Down

1 comment on commit 49c1944

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Unit Test Coverage Report
FileStmtsMissCoverMissing
__init__.py00100% 
datastore_pb2.py614821%34–81
datastore_pb2_grpc.py542750%15–16, 19, 65–80, 121–123, 128–130, 135–137, 142–144, 148–173, 219, 246, 273, 300
export_metrics.py100100% 
grpc_getter.py201145%15–19, 23–26, 30–32, 36–38
main.py45784%51, 56, 66, 76–77, 87–88
metadata_endpoints.py693254%50–59, 63, 115, 130–257, 261
response_classes.py50100% 
utilities.py1803978%21, 39, 46, 68–71, 79–90, 95–102, 122, 126, 128, 156, 162, 180, 238–244, 248–250, 280, 284, 306, 311
custom_geo_json
   edr_feature_collection.py60100% 
formatters
   __init__.py110100% 
   covjson.py60198%91
   geojson.py21290%27, 52
openapi
   custom_dimension_examples.py40100% 
   edr_query_parameter_descriptions.py110100% 
   openapi_examples.py130100% 
   openapi_metadata.py10100% 
routers
   __init__.py00100% 
   edr.py101496%348–349, 438–439
   feature.py471960%99–132, 148–153, 159–181
TOTAL71919074% 

Title Coverage Tests Skipped Failures Errors Time
API Unit Tests Coverage 40 0 💤 0 ❌ 0 🔥 1.936s ⏱️
Ingest Unit Tests Coverage 16 0 💤 0 ❌ 0 🔥 11.767s ⏱️

Please sign in to comment.