Skip to content

Commit

Permalink
fix metadata for apply_dimension with target
Browse files Browse the repository at this point in the history
  • Loading branch information
jdries committed Aug 13, 2024
1 parent 2df4d51 commit 3583ee2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- apply_dimension with a 'target_dimension' argument was not correctly adjusting datacube metadata on the client side, causing a mismatch.


## [0.31.0] - 2024-07-26

Expand Down
7 changes: 6 additions & 1 deletion openeo/rest/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,11 +1160,16 @@ def apply_dimension(
"process": process,
"dimension": self._assert_valid_dimension_name(dimension),
}

metadata = self.metadata
if target_dimension is not None:
arguments["target_dimension"] = target_dimension
metadata = self.metadata.reduce_dimension(dimension_name=dimension) if self.metadata else None
if(not target_dimension in self.metadata.dimension_names()):
metadata = self.metadata.add_dimension(target_dimension, label="unknown")
if context is not None:
arguments["context"] = context
result_cube = self.process(process_id="apply_dimension", arguments=arguments)
result_cube = self.process(process_id="apply_dimension", arguments=arguments, metadata = metadata)

return result_cube

Expand Down

0 comments on commit 3583ee2

Please sign in to comment.