2626extraction_method_defaults = {}
2727
2828
29+ class ExtractionMethodConf (BaseModel ):
30+ """STAC extraction method model."""
31+
32+ method : str
33+ inputs : Optional [dict [str , Any ]] = {}
34+
35+ _extraction_methods : EntryPoints = entry_points (group = "extraction_methods" )
36+
37+ def __repr__ (self ) -> str :
38+ return yaml .dump (self .model_dump ())
39+
40+ def _run (self , body : dict [str , Any ]) -> dict [str , Any ]:
41+ extraction_method = self ._extraction_methods [self .method ].load ()
42+ extraction_method = extraction_method (self )
43+
44+ return extraction_method ._run (body ) # type: ignore[no-any-return]
45+
46+
2947def update_input (
3048 func : Callable [[Any , dict [str , Any ]], Any ],
3149) -> Callable [[Any , dict [str , Any ]], Any ]:
@@ -46,7 +64,7 @@ def wrapper(self, body: dict[str, Any]) -> Any: # type: ignore[no-untyped-def]
4664 return wrapper
4765
4866
49- def set_extraction_method_defaults (conf_defaults : dict ) :
67+ def set_extraction_method_defaults (conf_defaults : dict [ str , Any ]) -> None :
5068 """
5169 Function to set global extraction_method_defaults variable.
5270 """
@@ -62,7 +80,9 @@ class SetInput:
6280 input_class : Any = Input
6381 dummy_input_class : Any = DummyInput
6482
65- def __init__ (self , extraction_method_conf : dict , * args : Any , ** kwargs : Any ) -> None :
83+ def __init__ (
84+ self , extraction_method_conf : ExtractionMethodConf , * args : Any , ** kwargs : Any
85+ ) -> None :
6686 """
6787 Set ``input`` attribute to instance of ``dummy_input_class`` with
6888 default values overrided by kwargs.
@@ -180,21 +200,3 @@ def run(self, body: dict[str, Any]) -> Iterator[dict[str, Any]]:
180200 :return: updated body dict
181201 :rtype: dict
182202 """
183-
184-
185- class ExtractionMethodConf (BaseModel ):
186- """STAC extraction method model."""
187-
188- method : str
189- inputs : Optional [dict ] = {}
190-
191- _extraction_methods : EntryPoints = entry_points (group = "extraction_methods" )
192-
193- def __repr__ (self ):
194- return yaml .dump (self .model_dump ())
195-
196- def _run (self , body : dict [str , Any ]) -> dict [str , Any ]:
197- extraction_method = self ._extraction_methods [self .method ].load ()
198- extraction_method = extraction_method (self )
199-
200- return extraction_method ._run (body )
0 commit comments