54
54
ProcessParameterInvalidException ,
55
55
FeatureUnsupportedException ,
56
56
OpenEOApiException ,
57
- CollectionNotFoundException ,
57
+ CollectionNotFoundException , ProcessUnsupportedException ,
58
58
)
59
59
from openeo_driver .processes import ProcessRegistry , ProcessSpec , DEFAULT_NAMESPACE , ProcessArgs
60
60
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:
1824
1824
process_id = process_id , namespace = namespace , args = args , env = env
1825
1825
)
1826
1826
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
+
1827
1840
if namespace in ["user" , None ]:
1828
1841
user = env .get ("user" )
1829
1842
if user :
1830
- # TODO: first check process registry with predefined processes because querying of user defined processes
1831
- # is more expensive IO-wise?
1832
1843
# 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
1833
1844
# name without renaming his UDP?
1834
1845
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:
1837
1848
_log .debug ("Using process {p!r} from namespace 'user'." .format (p = process_id ))
1838
1849
return evaluate_udp (process_id = process_id , udp = udp , args = args , env = env )
1839
1850
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 )
1844
1852
1845
1853
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
-
1851
1854
1852
1855
@non_standard_process (
1853
1856
ProcessSpec ("read_vector" , description = "Reads vector data from a file or a URL." )
0 commit comments