|
1 |
| -import json |
2 | 1 | import pathlib
|
3 |
| -from typing import Union, Optional |
4 | 2 | import typing
|
| 3 | +from typing import Union, Optional |
5 | 4 |
|
6 |
| -from openeo.internal.graph_building import PGNode, _FromNodeMixin |
| 5 | +from openeo.internal.graph_building import PGNode |
7 | 6 | from openeo.metadata import CollectionMetadata
|
8 |
| -from openeo.rest._datacube import _ProcessGraphAbstraction, THIS |
| 7 | +from openeo.rest._datacube import _ProcessGraphAbstraction |
9 | 8 | from openeo.rest.job import RESTJob
|
10 |
| -from openeo.util import legacy_alias |
| 9 | +from openeo.util import legacy_alias, dict_no_none |
11 | 10 |
|
12 | 11 | if hasattr(typing, 'TYPE_CHECKING') and typing.TYPE_CHECKING:
|
13 | 12 | # Imports for type checking only (circular import issue at runtime). `hasattr` is Python 3.5 workaround #210
|
@@ -45,23 +44,14 @@ def process(
|
45 | 44 | pg = self._build_pgnode(process_id=process_id, arguments=arguments, namespace=namespace, **kwargs)
|
46 | 45 | return VectorCube(graph=pg, connection=self._connection, metadata=metadata or self.metadata)
|
47 | 46 |
|
48 |
| - def process_with_node(self, pg: PGNode, metadata: CollectionMetadata = None) -> 'VectorCube': |
49 |
| - """ |
50 |
| - Generic helper to create a new DataCube by applying a process (given as process graph node) |
51 |
| -
|
52 |
| - :param pg: process graph node (containing process id and arguments) |
53 |
| - :param metadata: (optional) metadata to override original cube metadata (e.g. when reducing dimensions) |
54 |
| - :return: new DataCube instance |
55 |
| - """ |
56 |
| - arguments = pg.arguments |
57 |
| - for k, v in arguments.items(): |
58 |
| - # TODO: it's against intended flow to resolve THIS and _FromNodeMixin at this point (should be done before building PGNode) |
59 |
| - if v is THIS: |
60 |
| - v = self |
61 |
| - if isinstance(v, _FromNodeMixin): |
62 |
| - arguments[k] = {"from_node": v.from_node()} |
63 |
| - # TODO: deep copy `self.metadata` instead of using same instance? |
64 |
| - return VectorCube(graph=pg, connection=self._connection, metadata=metadata or self.metadata) |
| 47 | + def run_udf( |
| 48 | + self, udf: str, runtime: str, version: Optional[str] = None, context: Optional[dict] = None |
| 49 | + ) -> "VectorCube": |
| 50 | + return self.process( |
| 51 | + process_id="run_udf", |
| 52 | + data=self, udf=udf, runtime=runtime, |
| 53 | + arguments=dict_no_none({"version": version, "context": context}), |
| 54 | + ) |
65 | 55 |
|
66 | 56 | def save_result(self, format: str = "GeoJson", options: dict = None):
|
67 | 57 | return self.process(
|
|
0 commit comments