Skip to content

Commit 27beb74

Browse files
authored
Merge pull request #31 from cedadev/conditional_method
Bug fixing.
2 parents 2c362b4 + 7d5f7f3 commit 27beb74

File tree

5 files changed

+27
-33
lines changed

5 files changed

+27
-33
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
project = "Extraction Methods"
1414
copyright = "2025, Rhys Evans"
1515
author = "Rhys Evans"
16-
release = "1.1.0"
16+
release = "1.1.1"
1717

1818
# -- General configuration ---------------------------------------------------
1919
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extraction_methods/core/extraction_method.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,8 @@
2626
extraction_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) -> Any:
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-
4729
def update_input(
48-
func: Callable[[Any, dict[str, Any]], Any]
30+
func: Callable[[Any, dict[str, Any]], Any],
4931
) -> Callable[[Any, dict[str, Any]], Any]:
5032
"""
5133
Wrapper to update inputs with body values before run.
@@ -64,7 +46,7 @@ def wrapper(self, body: dict[str, Any]) -> Any: # type: ignore[no-untyped-def]
6446
return wrapper
6547

6648

67-
def set_extraction_method_defaults(conf_defaults: dict[str, Any]) -> None:
49+
def set_extraction_method_defaults(conf_defaults: dict):
6850
"""
6951
Function to set global extraction_method_defaults variable.
7052
"""
@@ -80,9 +62,7 @@ class SetInput:
8062
input_class: Any = Input
8163
dummy_input_class: Any = DummyInput
8264

83-
def __init__(
84-
self, extraction_method_conf: ExtractionMethodConf, *args: Any, **kwargs: Any
85-
) -> None:
65+
def __init__(self, extraction_method_conf: dict, *args: Any, **kwargs: Any) -> None:
8666
"""
8767
Set ``input`` attribute to instance of ``dummy_input_class`` with
8868
default values overrided by kwargs.
@@ -200,3 +180,21 @@ def run(self, body: dict[str, Any]) -> Iterator[dict[str, Any]]:
200180
:return: updated body dict
201181
:rtype: dict
202182
"""
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)

extraction_methods/core/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def update_attrs(self, body: dict[str, Any]) -> None:
122122
:param body: current generated properties
123123
:type body: dict
124124
"""
125-
for key, value in self.dict(exclude={"exists_key"}).items():
125+
for key, value in self.model_dump(exclude={"exists_key"}).items():
126126
setattr(self, key, self.update_attr(value, body))
127127

128128

@@ -131,7 +131,7 @@ class Backend(BaseModel):
131131
Model for Backend configuration.
132132
"""
133133

134-
name: str = Field(
134+
method: str = Field(
135135
description="Name of backend.",
136136
)
137137
inputs: dict[str, Any] = Field(

extraction_methods/plugins/assets/assets.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ class AssetInput(Input):
4444
default="assets",
4545
description="term for method to output to.",
4646
)
47-
href_term: str = Field(
48-
default="path",
49-
description="term to use for href.",
50-
)
5147

5248

5349
class AssetExtract(SetEntryPointsMixin, ExtractionMethod):
@@ -88,8 +84,8 @@ class AssetExtract(SetEntryPointsMixin, ExtractionMethod):
8884
def run(self, body: dict[str, Any]) -> dict[str, Any]:
8985

9086
output = {}
91-
backend_entry_point = self.entry_points[self.input.backend.name].load()
92-
backend = backend_entry_point(**self.input.backend.inputs)
87+
backend_entry_point = self.entry_points[self.input.backend.method].load()
88+
backend = backend_entry_point(self.input.backend)
9389
assets = backend._run(body)
9490

9591
for asset in assets:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "extraction-methods"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
description = "Methods to enable the extraction of metadata"
55
authors = [
66
{"name" = "rhysrevans3", "email" = "<[email protected]>"},

0 commit comments

Comments
 (0)