Skip to content

Commit eed2450

Browse files
jdriesPeter Van Bouwel
authored and
Peter Van Bouwel
committed
prefer predefined process over udp
Open-EO#353
1 parent dc715b1 commit eed2450

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

openeo_driver/ProcessGraphDeserializer.py

+15-12
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
ProcessParameterInvalidException,
5555
FeatureUnsupportedException,
5656
OpenEOApiException,
57-
CollectionNotFoundException,
57+
CollectionNotFoundException, ProcessUnsupportedException,
5858
)
5959
from openeo_driver.processes import ProcessRegistry, ProcessSpec, DEFAULT_NAMESPACE, ProcessArgs
6060
from openeo_driver.processgraph import get_process_definition_from_url
@@ -1824,11 +1824,22 @@ def apply_process(process_id: str, args: dict, namespace: Union[str, None], env:
18241824
process_id=process_id, namespace=namespace, args=args, env=env
18251825
)
18261826

1827+
process_registry = env.backend_implementation.processing.get_process_registry(api_version=env["version"])
1828+
1829+
try:
1830+
process_function = process_registry.get_function(process_id, namespace=(namespace or "backend"))
1831+
_log.debug(f"Applying process {process_id} to arguments {args}")
1832+
#TODO: for API compliance, we would actually first need to check if a UDP with same name exists.
1833+
# we would however prefer to avoid overriding predefined functions with UDP's.
1834+
# if we want to do this, we require caching in UDP registry to avoid expensive UDP lookups. We only need to cache the list of UDP names for a given user.
1835+
return process_function(args=ProcessArgs(args, process_id=process_id), env=env)
1836+
except ProcessUnsupportedException as e:
1837+
pass
1838+
1839+
18271840
if namespace in ["user", None]:
18281841
user = env.get("user")
18291842
if user:
1830-
# TODO: first check process registry with predefined processes because querying of user defined processes
1831-
# is more expensive IO-wise?
18321843
# the DB-call can be cached if necessary, but how will a user be able to use a new pre-defined process of the same
18331844
# name without renaming his UDP?
18341845
udp = env.backend_implementation.user_defined_processes.get(user_id=user.user_id, process_id=process_id)
@@ -1837,17 +1848,9 @@ def apply_process(process_id: str, args: dict, namespace: Union[str, None], env:
18371848
_log.debug("Using process {p!r} from namespace 'user'.".format(p=process_id))
18381849
return evaluate_udp(process_id=process_id, udp=udp, args=args, env=env)
18391850

1840-
# And finally: check registry of predefined (namespaced) processes
1841-
if namespace is None:
1842-
namespace = "backend"
1843-
_log.debug("Using process {p!r} from namespace 'backend'.".format(p=process_id))
1851+
raise ProcessUnsupportedException(process=process_id, namespace=namespace)
18441852

18451853

1846-
process_registry = env.backend_implementation.processing.get_process_registry(api_version=env["version"])
1847-
process_function = process_registry.get_function(process_id, namespace=namespace)
1848-
_log.debug(f"Applying process {process_id} to arguments {args}")
1849-
return process_function(args=ProcessArgs(args, process_id=process_id), env=env)
1850-
18511854

18521855
@non_standard_process(
18531856
ProcessSpec("read_vector", description="Reads vector data from a file or a URL.")

0 commit comments

Comments
 (0)