Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions workflow/scripts/inference_get_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,26 @@ def extract_pypi_requirements(
"""
requirements: dict[str, str] = {}

for module, version_str in module_versions.items():
if module.startswith("_"):
for module, version_info in module_versions.items():
if module.startswith("_") or not version_info:
continue
if not version_str or not version_str[0].isdigit():

if isinstance(version_info, str): # backwards compatibility
version = version_info
elif isinstance(
version_info, dict
): # https://github.com/ecmwf/anemoi-utils/commit/b28a62b3a0da6382449362132cdc000efc39ce5d
version = version_info.get("version")
else:
raise ValueError(
f"Unexpected module version info. Expected a string or dict containing a 'version' key, got {type(version_info)}"
)

if not version[0].isdigit():
continue

try:
version = Version(version_str)
version = Version(version)
except InvalidVersion:
continue

Expand Down
Loading