Skip to content

Commit ea078ff

Browse files
committed
do not push down resample_cube_spatial in case an 'apply' process is in between
Open-EO/openeo-geopyspark-driver#790
1 parent 9bc7bc0 commit ea078ff

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

openeo_driver/dry_run.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,10 @@ def apply_tiles_spatiotemporal(self, process, context: Optional[dict] = None) ->
706706
else:
707707
return self
708708

709+
def apply(self, process: dict, *, context: Optional[dict] = None, env: EvalEnv) -> "DriverDataCube":
710+
cube = self._process("apply", {})
711+
return cube
712+
709713
def apply_neighborhood(
710714
self, process, *, size: List[dict], overlap: List[dict], context: Optional[dict] = None, env: EvalEnv
711715
) -> "DriverDataCube":
@@ -771,7 +775,7 @@ def fit_class_random_forest(self, predictors, target, training, num_trees, mtry)
771775

772776
# TODO: some methods need metadata manipulation?
773777

774-
apply = _nop
778+
775779
apply_tiles = _nop
776780

777781
reduce = _nop

tests/test_dry_run.py

+19
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,25 @@ def test_resample_filter_spatial(dry_run_env, dry_run_tracer):
988988
}
989989

990990

991+
992+
def test_resample_cube_spatial(dry_run_env, dry_run_tracer):
993+
polygon = {"type": "Polygon", "coordinates": [[(0, 0), (3, 5), (8, 2), (0, 0)]]}
994+
cube = DataCube(PGNode("load_collection", id="S2_FOOBAR"), connection=None)
995+
cube = cube.apply(lambda x: x + 1)
996+
cube = cube.resample_cube_spatial(target=DataCube(PGNode("load_collection", id="S2_FOOBAR"), connection=None),method="max")
997+
998+
pg = cube.flat_graph()
999+
res = evaluate(pg, env=dry_run_env,do_dry_run=False)
1000+
1001+
source_constraints = dry_run_tracer.get_source_constraints(merge=True)
1002+
assert len(source_constraints) == 2
1003+
src, constraints = source_constraints[0]
1004+
assert src == ("load_collection", ("S2_FOOBAR", ()))
1005+
1006+
assert constraints == { 'process_type': [ ProcessType.FOCAL_SPACE]}
1007+
1008+
1009+
9911010
def test_auto_align(dry_run_env, dry_run_tracer):
9921011
polygon = {"type": "Polygon", "coordinates": [[(0.1, 0.1), (3, 5), (8, 2), (0.1, 0.1)]]}
9931012
cube = DataCube(PGNode("load_collection", id="ESA_WORLDCOVER_10M_2020_V1"), connection=None)

0 commit comments

Comments
 (0)