3838from openeo .internal .graph_building import FlatGraphableMixin , PGNode , as_flat_graph
3939from openeo .internal .jupyter import VisualDict , VisualList
4040from openeo .internal .processes .builder import ProcessBuilderBase
41+ from openeo .internal .processes .parse import Process
4142from openeo .internal .warnings import deprecated , legacy_alias
4243from openeo .metadata import (
4344 Band ,
@@ -1065,36 +1066,26 @@ def describe_process(self, id: str, namespace: Optional[str] = None) -> dict:
10651066
10661067 raise OpenEoClientException ("Process does not exist." )
10671068
1068- """
1069- Loads all available processes of the back end.
1070-
1071- :param namespace: The namespace for which to list processes.
1072-
1073- :return: Dictionary of All available processes of the back end.
1074- """
1075-
1076- def dict_processes (self , namespace : Optional [str ] = None ) -> dict :
1077- processes = self .list_processes (namespace )
1078- result = {}
1079- for process in processes :
1080- result [process ["id" ]] = process
1081- return result
1082-
1083- """
1069+ def get_schema_from_process_parameter (
1070+ self , process_id : str , parameter_id : str , namespace : Optional [str ] = None
1071+ ) -> dict :
1072+ """
10841073 Returns schema of the parameter of the process from the back end.
10851074
10861075 :param process_id: The id of the process.
10871076 :param parameter_id: The id of the parameter.
10881077 :param namespace: The namespace of the process.
10891078
10901079 :return: schema of the parameter in the process.
1091- """
1092-
1093- def get_schema (self , process_id : str , parameter_id : str , namespace : Optional [str ] = None ) -> Union [dict , list ]:
1094- process = self ._capabilities_cache .get (("processes_dict" , "backend" ), lambda : self .dict_processes (namespace ))[
1095- process_id
1096- ]
1097- return extract_process_argument (process , ["parameters" , parameter_id , "schema" ])
1080+ """
1081+ processes = self .list_processes (namespace )
1082+ for process in processes :
1083+ if process ["id" ] == process_id :
1084+ schema = Process .from_dict (process )
1085+ for parameter in schema .parameters :
1086+ if parameter .name == parameter_id :
1087+ return parameter .schema .schema
1088+ raise OpenEoClientException ("Process does not exist." )
10981089
10991090 def list_jobs (self , limit : Union [int , None ] = None ) -> List [dict ]:
11001091 """
@@ -2115,36 +2106,15 @@ def extract_connections(
21152106 return connections
21162107
21172108
2118- """
2119- Extract element of the information using the parameters.
2120-
2121- :param process: The dict or of a process.
2122- :param parameters: list of the parameters to extract.
2123-
2124- :return: arguments of process
2125- """
2126-
2127-
2128- def extract_process_argument (information : Union [dict , list ], parameters : list [str ]) -> Union [dict , list ]:
2129- for parameter in parameters :
2130- if isinstance (information , dict ):
2131- information = information [parameter ]
2132- elif isinstance (information , list ):
2133- information = search_dict_in_list (information , parameter )
2134- return information
2135-
2136-
2137- """
2109+ def search_list_for_dict_key (lst : list , key : str ) -> Union [dict , list ]:
2110+ """
21382111 Searches a value of the dict that matches with the key in the list.
21392112
21402113 :param lst: list with dictionaries
21412114 :param parameters: list of the
21422115
21432116 :return: value that matches key
2144- """
2145-
2146-
2147- def search_list_for_dict_key (lst : list , key : str ) -> Union [dict , list ]:
2117+ """
21482118 result = None
21492119 for item in lst :
21502120 if key in item :
@@ -2155,29 +2125,3 @@ def search_list_for_dict_key(lst: list, key: str) -> Union[dict, list]:
21552125 if result is None :
21562126 raise OpenEoClientException ("No dictionary found with the key {k}." .format (k = key ))
21572127 return result
2158-
2159-
2160- """
2161- Searches a dictionary that contains the key-value pair in the list
2162-
2163- :param lst: list with dictionaries
2164- :param value: the value to search for
2165- :param key: the key to search for
2166-
2167- :return: dictionary containing key-value pair
2168- """
2169-
2170-
2171- def search_dict_in_list (lst : list , value : str , key : str = "name" ) -> Union [dict , list ]:
2172- result = None
2173- for item in lst :
2174- if item [key ] == value :
2175- if result is None :
2176- result = item
2177- else :
2178- raise OpenEoClientException (
2179- "Multiple dictionaries found with the key-value pair ({k},{v})." .format (k = key , v = value )
2180- )
2181- if result is None :
2182- raise OpenEoClientException ("No dictionary found with the key-value pair ({k},{v})." .format (k = key , v = value ))
2183- return result
0 commit comments