ocean-runner 0.2.8__tar.gz → 0.2.10__tar.gz
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-0.2.8 → ocean_runner-0.2.10}/PKG-INFO +1 -7
- {ocean_runner-0.2.8 → ocean_runner-0.2.10}/README.md +0 -6
- {ocean_runner-0.2.8 → ocean_runner-0.2.10}/ocean_runner/config.py +0 -5
- {ocean_runner-0.2.8 → ocean_runner-0.2.10}/ocean_runner/runner.py +8 -22
- {ocean_runner-0.2.8 → ocean_runner-0.2.10}/pyproject.toml +1 -1
- ocean_runner-0.2.8/ocean_runner/runtime_mode.py +0 -6
- {ocean_runner-0.2.8 → ocean_runner-0.2.10}/.gitignore +0 -0
- {ocean_runner-0.2.8 → ocean_runner-0.2.10}/LICENSE +0 -0
- {ocean_runner-0.2.8 → ocean_runner-0.2.10}/ocean_runner/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ocean-runner
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.10
|
|
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
|
|
@@ -134,11 +134,6 @@ Algorithm(
|
|
|
134
134
|
"""
|
|
135
135
|
Random secret to use while testing.
|
|
136
136
|
"""
|
|
137
|
-
|
|
138
|
-
runtime: "dev",
|
|
139
|
-
"""
|
|
140
|
-
Runtime mode. "dev" to run normally, "test" to run pytest
|
|
141
|
-
"""
|
|
142
137
|
)
|
|
143
138
|
"""
|
|
144
139
|
Should not be needed in production algorithms, used to mock environment variables, defaults to using env.
|
|
@@ -197,4 +192,3 @@ Environment variables:
|
|
|
197
192
|
- `TRANSFORMATION_DID` Algorithm DID, must have format: `abc..90`
|
|
198
193
|
- `SECRET` Algorithm secret.
|
|
199
194
|
- `BASE_DIR` (optional, default="/data"): Base path to the OceanProtocol data directories.
|
|
200
|
-
- `RUNTIME` (optional, default="dev"): Runtime mode
|
|
@@ -111,11 +111,6 @@ Algorithm(
|
|
|
111
111
|
"""
|
|
112
112
|
Random secret to use while testing.
|
|
113
113
|
"""
|
|
114
|
-
|
|
115
|
-
runtime: "dev",
|
|
116
|
-
"""
|
|
117
|
-
Runtime mode. "dev" to run normally, "test" to run pytest
|
|
118
|
-
"""
|
|
119
114
|
)
|
|
120
115
|
"""
|
|
121
116
|
Should not be needed in production algorithms, used to mock environment variables, defaults to using env.
|
|
@@ -174,4 +169,3 @@ Environment variables:
|
|
|
174
169
|
- `TRANSFORMATION_DID` Algorithm DID, must have format: `abc..90`
|
|
175
170
|
- `SECRET` Algorithm secret.
|
|
176
171
|
- `BASE_DIR` (optional, default="/data"): Base path to the OceanProtocol data directories.
|
|
177
|
-
- `RUNTIME` (optional, default="dev"): Runtime mode
|
|
@@ -8,7 +8,6 @@ from typing import Callable, Generic, Self, TypeVar
|
|
|
8
8
|
from oceanprotocol_job_details import JobDetails
|
|
9
9
|
|
|
10
10
|
from ocean_runner.config import Config
|
|
11
|
-
from ocean_runner.runtime_mode import RuntimeMode
|
|
12
11
|
|
|
13
12
|
JobDetailsT = TypeVar(
|
|
14
13
|
"JobDetailsT",
|
|
@@ -34,19 +33,6 @@ def default_save(*, result: ResultT, base: Path, algorithm: Algorithm) -> None:
|
|
|
34
33
|
f.write(str(result))
|
|
35
34
|
|
|
36
35
|
|
|
37
|
-
def default_test_run(algorithm: Algorithm) -> int:
|
|
38
|
-
import pytest
|
|
39
|
-
|
|
40
|
-
result = pytest.main()
|
|
41
|
-
|
|
42
|
-
if result == 0:
|
|
43
|
-
algorithm.logger.info("Passed all tests")
|
|
44
|
-
else:
|
|
45
|
-
algorithm.logger.error("Some tests failed")
|
|
46
|
-
|
|
47
|
-
return result
|
|
48
|
-
|
|
49
|
-
|
|
50
36
|
@dataclass
|
|
51
37
|
class Algorithm(Generic[JobDetailsT, ResultT]):
|
|
52
38
|
|
|
@@ -57,7 +43,6 @@ class Algorithm(Generic[JobDetailsT, ResultT]):
|
|
|
57
43
|
|
|
58
44
|
_job_details: JobDetails[JobDetailsT] = field(init=False)
|
|
59
45
|
_result: ResultT | None = field(default=None, init=False)
|
|
60
|
-
_runtime: RuntimeMode = field(default=RuntimeMode.DEV, init=False)
|
|
61
46
|
|
|
62
47
|
error_callback = default_error_callback
|
|
63
48
|
|
|
@@ -89,8 +74,6 @@ class Algorithm(Generic[JobDetailsT, ResultT]):
|
|
|
89
74
|
sys.path.extend([str(path.absolute()) for path in config.source_paths])
|
|
90
75
|
self.logger.debug(f"Added [{len(config.source_paths)}] entries to PATH")
|
|
91
76
|
|
|
92
|
-
self._runtime = RuntimeMode(config.environment.runtime) or self._runtime
|
|
93
|
-
|
|
94
77
|
self._job_details = JobDetails.load(
|
|
95
78
|
_type=config.custom_input,
|
|
96
79
|
base_dir=config.environment.base_dir,
|
|
@@ -116,7 +99,10 @@ class Algorithm(Generic[JobDetailsT, ResultT]):
|
|
|
116
99
|
raise Algorithm.Error("Result missing, run the algorithm first")
|
|
117
100
|
return self._result
|
|
118
101
|
|
|
119
|
-
def validate(
|
|
102
|
+
def validate(
|
|
103
|
+
self,
|
|
104
|
+
callback: Callable[[Self], None] = default_validation,
|
|
105
|
+
) -> Self:
|
|
120
106
|
self.logger.info("Validating instance...")
|
|
121
107
|
try:
|
|
122
108
|
callback(self)
|
|
@@ -125,12 +111,12 @@ class Algorithm(Generic[JobDetailsT, ResultT]):
|
|
|
125
111
|
|
|
126
112
|
return self
|
|
127
113
|
|
|
128
|
-
def run(
|
|
114
|
+
def run(
|
|
115
|
+
self,
|
|
116
|
+
callable: Callable[[Self], ResultT],
|
|
117
|
+
) -> Self:
|
|
129
118
|
self.logger.info("Running algorithm...")
|
|
130
119
|
try:
|
|
131
|
-
if is_check_test and self._runtime == RuntimeMode.TEST:
|
|
132
|
-
callable = default_test_run
|
|
133
|
-
|
|
134
120
|
self._result = callable(self)
|
|
135
121
|
except Exception as e:
|
|
136
122
|
self.error_callback(e)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|