Skip to content

Commit

Permalink
do not push down resample_cube_spatial in case an 'apply' process is …
Browse files Browse the repository at this point in the history
  • Loading branch information
jdries committed Jun 7, 2024
1 parent 9bc7bc0 commit ea078ff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion openeo_driver/dry_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,10 @@ def apply_tiles_spatiotemporal(self, process, context: Optional[dict] = None) ->
else:
return self

def apply(self, process: dict, *, context: Optional[dict] = None, env: EvalEnv) -> "DriverDataCube":
cube = self._process("apply", {})
return cube

def apply_neighborhood(
self, process, *, size: List[dict], overlap: List[dict], context: Optional[dict] = None, env: EvalEnv
) -> "DriverDataCube":
Expand Down Expand Up @@ -771,7 +775,7 @@ def fit_class_random_forest(self, predictors, target, training, num_trees, mtry)

# TODO: some methods need metadata manipulation?

apply = _nop

apply_tiles = _nop

reduce = _nop
Expand Down
19 changes: 19 additions & 0 deletions tests/test_dry_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,25 @@ def test_resample_filter_spatial(dry_run_env, dry_run_tracer):
}



def test_resample_cube_spatial(dry_run_env, dry_run_tracer):
polygon = {"type": "Polygon", "coordinates": [[(0, 0), (3, 5), (8, 2), (0, 0)]]}
cube = DataCube(PGNode("load_collection", id="S2_FOOBAR"), connection=None)
cube = cube.apply(lambda x: x + 1)
cube = cube.resample_cube_spatial(target=DataCube(PGNode("load_collection", id="S2_FOOBAR"), connection=None),method="max")

pg = cube.flat_graph()
res = evaluate(pg, env=dry_run_env,do_dry_run=False)

source_constraints = dry_run_tracer.get_source_constraints(merge=True)
assert len(source_constraints) == 2
src, constraints = source_constraints[0]
assert src == ("load_collection", ("S2_FOOBAR", ()))

assert constraints == { 'process_type': [ ProcessType.FOCAL_SPACE]}



def test_auto_align(dry_run_env, dry_run_tracer):
polygon = {"type": "Polygon", "coordinates": [[(0.1, 0.1), (3, 5), (8, 2), (0.1, 0.1)]]}
cube = DataCube(PGNode("load_collection", id="ESA_WORLDCOVER_10M_2020_V1"), connection=None)
Expand Down

0 comments on commit ea078ff

Please sign in to comment.