Skip to content

Commit

Permalink
Improve profiles downloading (3)
Browse files Browse the repository at this point in the history
Fix pytests after making scope nullable
  • Loading branch information
dostuffthatmatters committed Aug 2, 2024
1 parent 38e7f90 commit ef378fb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/profiles/generate_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def list_downloaded_data(
) -> dict[ProfilesQueryLocation, set[datetime.date]]:

assert config.profiles is not None
assert config.profiles.scope is not None
downloaded_data: dict[ProfilesQueryLocation, set[datetime.date]] = {}

r = re.compile(r"^\d{8,10}_\d{2}(N|S)\d{3}(E|W)\.(map|mod|vmr)$")
Expand Down Expand Up @@ -91,6 +92,7 @@ def list_requested_data(
) -> dict[ProfilesQueryLocation, set[datetime.date]]:

assert config.profiles is not None
assert config.profiles.scope is not None
requested_data: dict[ProfilesQueryLocation, set[datetime.date]] = {}

for sensor in em27_metadata_interface.sensors.root:
Expand Down
4 changes: 4 additions & 0 deletions src/profiles/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def run() -> None:
else:
print("No standard site data to download")

if config.profiles.scope is None:
print("No scope defined, skipping on-demand data download")
return

for version in config.profiles.scope.models:
print(f"Downloading on-demand {version} data")

Expand Down
1 change: 1 addition & 0 deletions tests/profiles/test_list_downloaded_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_list_downloaded_data(
}
config = provide_config_template.model_copy(deep=True)
assert config.profiles is not None
assert config.profiles.scope is not None
config.profiles.scope.from_date = min(random_dates)
config.profiles.scope.to_date = max(random_dates)
for _ in range(5):
Expand Down
1 change: 1 addition & 0 deletions tests/profiles/test_list_requested_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def test_list_requested_data(provide_config_template: src.types.Config) -> None:
}
config = provide_config_template.model_copy(deep=True)
assert config.profiles is not None
assert config.profiles.scope is not None
config.profiles.scope.from_date = datetime.date(2000, 1, 1)
config.profiles.scope.to_date = datetime.date(2000, 5, 8)

Expand Down

0 comments on commit ef378fb

Please sign in to comment.