ocean-runner 0.2.16__py3-none-any.whl → 0.2.18__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ocean_runner/runner.py +38 -20
- {ocean_runner-0.2.16.dist-info → ocean_runner-0.2.18.dist-info}/METADATA +2 -2
- ocean_runner-0.2.18.dist-info/RECORD +7 -0
- {ocean_runner-0.2.16.dist-info → ocean_runner-0.2.18.dist-info}/WHEEL +1 -1
- ocean_runner-0.2.16.dist-info/RECORD +0 -7
- {ocean_runner-0.2.16.dist-info → ocean_runner-0.2.18.dist-info}/licenses/LICENSE +0 -0
ocean_runner/runner.py
CHANGED
|
@@ -13,7 +13,8 @@ JobDetailsT = TypeVar("JobDetailsT")
|
|
|
13
13
|
ResultT = TypeVar("ResultT")
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
def default_error_callback(
|
|
16
|
+
def default_error_callback(algorithm: Algorithm, e: Exception) -> None:
|
|
17
|
+
algorithm.logger.exception("Error during algorithm execution")
|
|
17
18
|
raise e
|
|
18
19
|
|
|
19
20
|
|
|
@@ -43,13 +44,28 @@ class Algorithm(Generic[JobDetailsT, ResultT]):
|
|
|
43
44
|
_result: ResultT | None = field(default=None, init=False)
|
|
44
45
|
|
|
45
46
|
# Decorator-registered callbacks
|
|
46
|
-
_validate_fn: Callable[[Algorithm], None] | None = field(
|
|
47
|
-
|
|
47
|
+
_validate_fn: Callable[[Algorithm], None] | None = field(
|
|
48
|
+
default=None,
|
|
49
|
+
init=False,
|
|
50
|
+
repr=False,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
_run_fn: Callable[[Algorithm], ResultT] | None = field(
|
|
54
|
+
default=None,
|
|
55
|
+
init=False,
|
|
56
|
+
repr=False,
|
|
57
|
+
)
|
|
58
|
+
|
|
48
59
|
_save_fn: Callable[[ResultT, Path, Algorithm], None] | None = field(
|
|
49
|
-
default=None,
|
|
60
|
+
default=None,
|
|
61
|
+
init=False,
|
|
62
|
+
repr=False,
|
|
50
63
|
)
|
|
51
|
-
|
|
52
|
-
|
|
64
|
+
|
|
65
|
+
_error_callback: Callable[[Algorithm, Exception], None] | None = field(
|
|
66
|
+
default=None,
|
|
67
|
+
init=False,
|
|
68
|
+
repr=False,
|
|
53
69
|
)
|
|
54
70
|
|
|
55
71
|
def __post_init__(self, config: Config | None) -> None:
|
|
@@ -79,18 +95,6 @@ class Algorithm(Generic[JobDetailsT, ResultT]):
|
|
|
79
95
|
sys.path.extend([str(path.absolute()) for path in config.source_paths])
|
|
80
96
|
self.logger.debug(f"Added [{len(config.source_paths)}] entries to PATH")
|
|
81
97
|
|
|
82
|
-
# Load job details
|
|
83
|
-
self._job_details = JobDetails.load(
|
|
84
|
-
_type=config.custom_input,
|
|
85
|
-
base_dir=config.environment.base_dir,
|
|
86
|
-
dids=config.environment.dids,
|
|
87
|
-
transformation_did=config.environment.transformation_did,
|
|
88
|
-
secret=config.environment.secret,
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
self.logger.info("Loaded JobDetails")
|
|
92
|
-
self.logger.debug(asdict(self.job_details))
|
|
93
|
-
|
|
94
98
|
self.config = config
|
|
95
99
|
|
|
96
100
|
class Error(RuntimeError): ...
|
|
@@ -133,6 +137,18 @@ class Algorithm(Generic[JobDetailsT, ResultT]):
|
|
|
133
137
|
|
|
134
138
|
def __call__(self) -> ResultT | None:
|
|
135
139
|
"""Executes the algorithm pipeline: validate → run → save_results."""
|
|
140
|
+
# Load job details
|
|
141
|
+
self._job_details = JobDetails.load(
|
|
142
|
+
_type=self.config.custom_input,
|
|
143
|
+
base_dir=self.config.environment.base_dir,
|
|
144
|
+
dids=self.config.environment.dids,
|
|
145
|
+
transformation_did=self.config.environment.transformation_did,
|
|
146
|
+
secret=self.config.environment.secret,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
self.logger.info("Loaded JobDetails")
|
|
150
|
+
self.logger.debug(asdict(self.job_details))
|
|
151
|
+
|
|
136
152
|
try:
|
|
137
153
|
# Validation step
|
|
138
154
|
if self._validate_fn:
|
|
@@ -166,7 +182,9 @@ class Algorithm(Generic[JobDetailsT, ResultT]):
|
|
|
166
182
|
)
|
|
167
183
|
|
|
168
184
|
except Exception as e:
|
|
169
|
-
self.
|
|
170
|
-
|
|
185
|
+
if self._error_callback:
|
|
186
|
+
self._error_callback(e)
|
|
187
|
+
else:
|
|
188
|
+
default_error_callback(self, e)
|
|
171
189
|
|
|
172
190
|
return self._result
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ocean-runner
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.18
|
|
4
4
|
Summary: A fluent API for OceanProtocol algorithms
|
|
5
5
|
Project-URL: Homepage, https://github.com/AgrospAI/ocean-runner
|
|
6
6
|
Project-URL: Issues, https://github.com/AgrospAI/ocean-runner/issues
|
|
@@ -17,7 +17,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
17
17
|
Classifier: Operating System :: OS Independent
|
|
18
18
|
Classifier: Programming Language :: Python :: 3
|
|
19
19
|
Requires-Python: >=3.10
|
|
20
|
-
Requires-Dist: oceanprotocol-job-details>=0.2.
|
|
20
|
+
Requires-Dist: oceanprotocol-job-details>=0.2.8
|
|
21
21
|
Requires-Dist: pytest>=8.4.2
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ocean_runner/__init__.py,sha256=awAmE6kZhuwcrD3gT7qFZArdhiuzW-EFTA6tGKhw06k,138
|
|
2
|
+
ocean_runner/config.py,sha256=gyyUotPJ7n8wPPdsJZIBUT4zBlkoNbhV876JDTdPNsY,1398
|
|
3
|
+
ocean_runner/runner.py,sha256=2j0XNk06gIlPoer_kVRtSf-noYZzhORi_7-UnPQBJxA,6005
|
|
4
|
+
ocean_runner-0.2.18.dist-info/METADATA,sha256=NsZ4U_FM2scbLrsgP9BrxczPoBzItV1xs2VlttEGTAI,6562
|
|
5
|
+
ocean_runner-0.2.18.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
+
ocean_runner-0.2.18.dist-info/licenses/LICENSE,sha256=_B25KqK4amoADWkMN150tnZFm_Fy7VvZpvIC8ZydWdI,1053
|
|
7
|
+
ocean_runner-0.2.18.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
ocean_runner/__init__.py,sha256=awAmE6kZhuwcrD3gT7qFZArdhiuzW-EFTA6tGKhw06k,138
|
|
2
|
-
ocean_runner/config.py,sha256=gyyUotPJ7n8wPPdsJZIBUT4zBlkoNbhV876JDTdPNsY,1398
|
|
3
|
-
ocean_runner/runner.py,sha256=mPxnJCP-XYl0akRAI4HdAku0KlsTCrXTVPCwlQj5JoY,5721
|
|
4
|
-
ocean_runner-0.2.16.dist-info/METADATA,sha256=s4MrShZfoQzbWIXZRV06Rt0S4lhqYuRjK_OG9QKJoKg,6562
|
|
5
|
-
ocean_runner-0.2.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
6
|
-
ocean_runner-0.2.16.dist-info/licenses/LICENSE,sha256=_B25KqK4amoADWkMN150tnZFm_Fy7VvZpvIC8ZydWdI,1053
|
|
7
|
-
ocean_runner-0.2.16.dist-info/RECORD,,
|
|
File without changes
|