Skip to content

Commit df930d6

Browse files
committed
fixup! Support UDF based spatial/temporal extents in load_collection/load_stac #831
1 parent 6567e3e commit df930d6

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

openeo/rest/connection.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,7 @@
3535
import openeo
3636
from openeo.config import config_log, get_config_option
3737
from openeo.internal.documentation import openeo_process
38-
from openeo.internal.graph_building import (
39-
FlatGraphableMixin,
40-
PGNode,
41-
_FromNodeMixin,
42-
as_flat_graph,
43-
)
38+
from openeo.internal.graph_building import FlatGraphableMixin, PGNode, as_flat_graph
4439
from openeo.internal.jupyter import VisualDict, VisualList
4540
from openeo.internal.processes.builder import ProcessBuilderBase
4641
from openeo.internal.warnings import deprecated, legacy_alias
@@ -1191,8 +1186,8 @@ def load_collection(
11911186
self,
11921187
collection_id: Union[str, Parameter],
11931188
spatial_extent: Union[dict, Parameter, shapely.geometry.base.BaseGeometry, str, Path, None] = None,
1194-
temporal_extent: Union[Sequence[InputDate], Parameter, str, _FromNodeMixin, None] = None,
1195-
bands: Union[Iterable[str], Parameter, str, _FromNodeMixin, None] = None,
1189+
temporal_extent: Union[Sequence[InputDate], Parameter, str, FlatGraphableMixin, None] = None,
1190+
bands: Union[Iterable[str], Parameter, str, FlatGraphableMixin, None] = None,
11961191
properties: Union[
11971192
Dict[str, Union[PGNode, Callable]], List[CollectionProperty], CollectionProperty, None
11981193
] = None,
@@ -1293,9 +1288,9 @@ def load_stac(
12931288
self,
12941289
url: str,
12951290
spatial_extent: Union[
1296-
dict, Parameter, shapely.geometry.base.BaseGeometry, str, Path, _FromNodeMixin, None
1291+
dict, Parameter, shapely.geometry.base.BaseGeometry, str, Path, FlatGraphableMixin, None
12971292
] = None,
1298-
temporal_extent: Union[Sequence[InputDate], Parameter, str, _FromNodeMixin, None] = None,
1293+
temporal_extent: Union[Sequence[InputDate], Parameter, str, FlatGraphableMixin, None] = None,
12991294
bands: Union[Iterable[str], Parameter, str, None] = None,
13001295
properties: Union[
13011296
Dict[str, Union[PGNode, Callable]], List[CollectionProperty], CollectionProperty, None

openeo/rest/datacube.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@
3939
from openeo.api.process import Parameter, schema_supports
4040
from openeo.dates import get_temporal_extent
4141
from openeo.internal.documentation import openeo_process
42-
from openeo.internal.graph_building import PGNode, ReduceNode, _FromNodeMixin
42+
from openeo.internal.graph_building import (
43+
FlatGraphableMixin,
44+
PGNode,
45+
ReduceNode,
46+
_FromNodeMixin,
47+
)
4348
from openeo.internal.jupyter import in_jupyter_context
4449
from openeo.internal.processes.builder import (
4550
ProcessBuilderBase,
@@ -91,7 +96,7 @@
9196

9297

9398
# Type annotation aliases
94-
InputDate = Union[str, datetime.date, Parameter, PGNode, ProcessBuilderBase, _FromNodeMixin, None]
99+
InputDate = Union[str, datetime.date, Parameter, PGNode, ProcessBuilderBase, FlatGraphableMixin, None]
95100

96101

97102
class DataCube(_ProcessGraphAbstraction):
@@ -166,9 +171,9 @@ def load_collection(
166171
collection_id: Union[str, Parameter],
167172
connection: Optional[Connection] = None,
168173
spatial_extent: Union[
169-
dict, Parameter, shapely.geometry.base.BaseGeometry, str, pathlib.Path, _FromNodeMixin, None
174+
dict, Parameter, shapely.geometry.base.BaseGeometry, str, pathlib.Path, FlatGraphableMixin, None
170175
] = None,
171-
temporal_extent: Union[Sequence[InputDate], Parameter, str, _FromNodeMixin, None] = None,
176+
temporal_extent: Union[Sequence[InputDate], Parameter, str, FlatGraphableMixin, None] = None,
172177
bands: Union[Iterable[str], Parameter, str, None] = None,
173178
fetch_metadata: bool = True,
174179
properties: Union[
@@ -482,22 +487,22 @@ def _get_temporal_extent(
482487
*args,
483488
start_date: InputDate = None,
484489
end_date: InputDate = None,
485-
extent: Union[Sequence[InputDate], Parameter, str, _FromNodeMixin, None] = None,
486-
) -> Union[List[Union[str, Parameter, PGNode, _FromNodeMixin, None]], Parameter, _FromNodeMixin]:
490+
extent: Union[Sequence[InputDate], Parameter, str, FlatGraphableMixin, None] = None,
491+
) -> Union[List[Union[str, Parameter, PGNode, FlatGraphableMixin, None]], Parameter, FlatGraphableMixin]:
487492
"""Parameter aware temporal_extent normalizer"""
488493
# TODO: move this outside of DataCube class
489494
# TODO: return extent as tuple instead of list
490-
if len(args) == 1 and isinstance(args[0], (Parameter, _FromNodeMixin)):
495+
if len(args) == 1 and isinstance(args[0], (Parameter, FlatGraphableMixin)):
491496
assert start_date is None and end_date is None and extent is None
492497
return args[0]
493-
elif len(args) == 0 and isinstance(extent, (Parameter, _FromNodeMixin)):
498+
elif len(args) == 0 and isinstance(extent, (Parameter, FlatGraphableMixin)):
494499
assert start_date is None and end_date is None
495500
# TODO: warn about unexpected parameter schema
496501
return extent
497502
else:
498503
def convertor(d: Any) -> Any:
499504
# TODO: can this be generalized through _FromNodeMixin?
500-
if isinstance(d, Parameter) or isinstance(d, _FromNodeMixin):
505+
if isinstance(d, Parameter) or isinstance(d, FlatGraphableMixin):
501506
# TODO: warn about unexpected parameter schema
502507
return d
503508
elif isinstance(d, ProcessBuilderBase):
@@ -533,7 +538,7 @@ def filter_temporal(
533538
*args,
534539
start_date: InputDate = None,
535540
end_date: InputDate = None,
536-
extent: Union[Sequence[InputDate], Parameter, str, _FromNodeMixin, None] = None,
541+
extent: Union[Sequence[InputDate], Parameter, str, FlatGraphableMixin, None] = None,
537542
) -> DataCube:
538543
"""
539544
Limit the DataCube to a certain date range, which can be specified in several ways:

0 commit comments

Comments
 (0)