@@ -140,7 +140,7 @@ def wrapped(args: dict, env: EvalEnv):
140140
141141# Type hint alias for a "process function":
142142# a Python function that implements some openEO process (as used in `apply_process`)
143- ProcessFunction = Callable [[dict , EvalEnv ], Any ]
143+ ProcessFunction = Callable [[Union [ dict , ProcessArgs ] , EvalEnv ], Any ]
144144
145145
146146def process (f : ProcessFunction ) -> ProcessFunction :
@@ -764,14 +764,15 @@ def load_collection(args: dict, env: EvalEnv) -> DriverDataCube:
764764 .param (name = 'options' , description = "options specific to the file format" , schema = {"type" : "object" })
765765 .returns (description = "the data as a data cube" , schema = {})
766766)
767- def load_disk_data (args : Dict , env : EvalEnv ) -> DriverDataCube :
767+ def load_disk_data (args : ProcessArgs , env : EvalEnv ) -> DriverDataCube :
768768 """
769769 Deprecated, use load_uploaded_files or load_stac
770770 """
771+ _log .warning ("DEPRECATED: load_disk_data usage" )
771772 kwargs = dict (
772- glob_pattern = extract_arg ( args , 'glob_pattern' ),
773- format = extract_arg ( args , 'format' ),
774- options = args .get ( ' options' , {} ),
773+ glob_pattern = args . get_required ( "glob_pattern" , expected_type = str ),
774+ format = args . get_required ( "format" , expected_type = str ),
775+ options = args .get_optional ( " options" , default = {}, expected_type = dict ),
775776 )
776777 dry_run_tracer : DryRunDataTracer = env .get (ENV_DRY_RUN_TRACER )
777778 if dry_run_tracer :
@@ -1019,7 +1020,9 @@ def apply_polygon(args: ProcessArgs, env: EvalEnv) -> DriverDataCube:
10191020 process = args .get_deep ("process" , "process_graph" , expected_type = dict )
10201021 if "polygons" in args and "geometries" not in args :
10211022 # TODO remove this deprecated "polygons" parameter handling when not used anymore
1022- _log .warning ("In process 'apply_polygon': parameter 'polygons' is deprecated, use 'geometries' instead." )
1023+ _log .warning (
1024+ "DEPRECATED: In process 'apply_polygon': parameter 'polygons' is deprecated, use 'geometries' instead."
1025+ )
10231026 geometries = args .get_required ("polygons" )
10241027 else :
10251028 geometries = args .get_required ("geometries" )
@@ -1152,19 +1155,19 @@ def get_validated_parameter(args, param_name, default_value, expected_type, min_
11521155
11531156@process_registry_100 .add_function (spec = read_spec ("openeo-processes/experimental/predict_random_forest.json" ))
11541157@process_registry_2xx .add_function (spec = read_spec ("openeo-processes/experimental/predict_random_forest.json" ))
1155- def predict_random_forest (args : dict , env : EvalEnv ):
1158+ def predict_random_forest (args : ProcessArgs , env : EvalEnv ):
11561159 raise NotImplementedError
11571160
11581161
11591162@process_registry_100 .add_function (spec = read_spec ("openeo-processes/experimental/predict_catboost.json" ))
11601163@process_registry_2xx .add_function (spec = read_spec ("openeo-processes/experimental/predict_catboost.json" ))
1161- def predict_catboost (args : dict , env : EvalEnv ):
1164+ def predict_catboost (args : ProcessArgs , env : EvalEnv ):
11621165 raise NotImplementedError
11631166
11641167
11651168@process_registry_100 .add_function (spec = read_spec ("openeo-processes/experimental/predict_probabilities.json" ))
11661169@process_registry_2xx .add_function (spec = read_spec ("openeo-processes/experimental/predict_probabilities.json" ))
1167- def predict_probabilities (args : dict , env : EvalEnv ):
1170+ def predict_probabilities (args : ProcessArgs , env : EvalEnv ):
11681171 raise NotImplementedError
11691172
11701173
@@ -1708,8 +1711,8 @@ def linear_scale_range(args: dict, env: EvalEnv) -> DriverDataCube:
17081711
17091712
17101713@process
1711- def constant (args : dict , env : EvalEnv ):
1712- return args [ "x" ]
1714+ def constant (args : ProcessArgs , env : EvalEnv ):
1715+ return args . get_required ( "x" )
17131716
17141717
17151718def flatten_children_node_types (process_graph : Union [dict , list ]):
@@ -1861,10 +1864,11 @@ def apply_process(process_id: str, args: dict, namespace: Union[str, None], env:
18611864 ])
18621865 .returns ("GeoJSON-style feature collection" , schema = {"type" : "object" , "subtype" : "geojson" })
18631866)
1864- def read_vector (args : Dict , env : EvalEnv ) -> DelayedVector :
1867+ def read_vector (args : ProcessArgs , env : EvalEnv ) -> DelayedVector :
18651868 # TODO #114 EP-3981: deprecated in favor of load_uploaded_files/load_external? https://github.com/Open-EO/openeo-processes/issues/322
18661869 # TODO: better argument name than `filename`?
1867- path = extract_arg (args , "filename" )
1870+ _log .warning ("DEPRECATED: read_vector usage" )
1871+ path = args .get_required ("filename" )
18681872 _check_geometry_path_assumption (
18691873 path = path , process = "read_vector" , parameter = "filename"
18701874 )
@@ -1911,10 +1915,10 @@ def load_uploaded_files(args: ProcessArgs, env: EvalEnv) -> Union[DriverVectorCu
19111915 .param ('data' , description = "GeoJson object." , schema = {"type" : "object" , "subtype" : "geojson" })
19121916 .returns ("vector-cube" , schema = {"type" : "object" , "subtype" : "vector-cube" })
19131917)
1914- def to_vector_cube (args : Dict , env : EvalEnv ):
1915- _log .warning ("Experimental process ` to_vector_cube` is deprecated, use ` load_geojson` instead" )
1918+ def to_vector_cube (args : ProcessArgs , env : EvalEnv ):
1919+ _log .warning ("DEPRECATED: process to_vector_cube is deprecated, use load_geojson instead" )
19161920 # TODO: remove this experimental/deprecated process
1917- data = extract_arg ( args , "data" , process_id = "to_vector_cube " )
1921+ data = args . get_required ( "data" )
19181922 if isinstance (data , dict ) and data .get ("type" ) in {"Polygon" , "MultiPolygon" , "Feature" , "FeatureCollection" }:
19191923 return env .backend_implementation .vector_cube_cls .from_geojson (data )
19201924 raise FeatureUnsupportedException (f"Converting { type (data )} to vector cube is not supported" )
@@ -2111,9 +2115,9 @@ def evaluate_process_from_url(process_id: str, namespace: str, args: dict, env:
21112115 .param ('seconds' , description = "Number of seconds to sleep." , schema = {"type" : "number" }, required = True )
21122116 .returns ("Original data" , schema = {})
21132117)
2114- def sleep (args : Dict , env : EvalEnv ):
2115- data = extract_arg ( args , "data" )
2116- seconds = extract_arg ( args , "seconds" )
2118+ def sleep (args : ProcessArgs , env : EvalEnv ):
2119+ data = args . get_required ( "data" )
2120+ seconds = args . get_required ( "seconds" , expected_type = ( int , float ) )
21172121 dry_run_tracer : DryRunDataTracer = env .get (ENV_DRY_RUN_TRACER )
21182122 if not dry_run_tracer :
21192123 _log .info ("Sleeping {s} seconds" .format (s = seconds ))
@@ -2220,7 +2224,7 @@ def resolution_merge(args: ProcessArgs, env: EvalEnv):
22202224 .param ('data' , description = "Data to discard." , schema = {}, required = False )
22212225 .returns ("Nothing" , schema = {})
22222226)
2223- def discard_result (args : Dict , env : EvalEnv ):
2227+ def discard_result (args : ProcessArgs , env : EvalEnv ):
22242228 # TODO: keep a reference to the discarded result?
22252229 return NullResult ()
22262230
@@ -2335,8 +2339,9 @@ def array_create(args: ProcessArgs, env: EvalEnv) -> list:
23352339
23362340
23372341@process_registry_100 .add_function (spec = read_spec ("openeo-processes/1.x/proposals/load_result.json" ))
2338- def load_result (args : dict , env : EvalEnv ) -> DriverDataCube :
2339- job_id = extract_arg (args , "id" )
2342+ def load_result (args : ProcessArgs , env : EvalEnv ) -> DriverDataCube :
2343+ _log .warning ("DEPRECATED: load_result usage" )
2344+ job_id = args .get_required ("id" , expected_type = str )
23402345 user = env .get ("user" )
23412346
23422347 arguments = {}
0 commit comments