Skip to content

Commit

Permalink
Describe contains coordinate not on the variable (#131)
Browse files Browse the repository at this point in the history
Fix a bug where we would have some coordinates for variables that don't have it in the describe
  • Loading branch information
renaudjester authored Sep 17, 2024
1 parent 0e5a113 commit 66d8b46
Show file tree
Hide file tree
Showing 5 changed files with 4,859 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,7 @@ build-and-publish-dockerhub-image:
docker build --ulimit nofile=65536:65536 --tag copernicusmarine/copernicusmarine:$${VERSION} --tag copernicusmarine/copernicusmarine:latest -f Dockerfile.dockerhub --build-arg VERSION="$${VERSION}" .
docker push copernicusmarine/copernicusmarine:$${VERSION}
docker push copernicusmarine/copernicusmarine:latest


update-snapshots-tests:
pytest --snapshot-update tests/test_command_line_interface.py::TestCommandLineInterface::test_describe_including_datasets
2 changes: 1 addition & 1 deletion copernicusmarine/catalogue_parser/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def from_metadata_item(
cube_variables = metadata_item.properties["cube:variables"]
cube_variable = cube_variables[variable_id]

# to get coordinates
extra_fields_asset = asset.extra_fields
dimensions = extra_fields_asset.get("viewDims") or {}
return cls(
Expand All @@ -236,6 +235,7 @@ def from_metadata_item(
metadata_item.properties.get("admp_valid_start_date"),
)
for dimension, dimension_metadata in dimensions.items()
if dimension in cube_variable["dimensions"]
],
)

Expand Down
16 changes: 9 additions & 7 deletions copernicusmarine/download_functions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ def get_approximation_size_data_downloaded(
download_estimated_size = 0
for variable_name in temp_dataset.data_vars:
coordinates_size = 1
variable = [
var for var in service.variables if var.short_name == variable_name
][0]
for coordinate_name in temp_dataset.sizes:
if coordinate_name == "elevation":
coordinate_name = "depth"
Expand All @@ -270,15 +273,14 @@ def get_approximation_size_data_downloaded(
for coordinate_names in COORDINATES_LABEL.values()
if coordinate_name in coordinate_names
][0]
coordinate = [
coordinates = [
coord
for coord in [
var
for var in service.variables
if var.short_name == variable_name
][0].coordinates
for coord in variable.coordinates
if coord.coordinate_id in possible_coordinate_id
][0]
]
if not coordinates:
continue
coordinate = coordinates[0]
chunking_length = coordinate.chunking_length
if not chunking_length:
continue
Expand Down
Loading

0 comments on commit 66d8b46

Please sign in to comment.