ocean-runner 0.2.8__tar.gz → 0.2.9__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.9}/PKG-INFO +1 -1
- {ocean_runner-0.2.8 → ocean_runner-0.2.9}/ocean_runner/runner.py +8 -22
- {ocean_runner-0.2.8 → ocean_runner-0.2.9}/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.9}/.gitignore +0 -0
- {ocean_runner-0.2.8 → ocean_runner-0.2.9}/LICENSE +0 -0
- {ocean_runner-0.2.8 → ocean_runner-0.2.9}/README.md +0 -0
- {ocean_runner-0.2.8 → ocean_runner-0.2.9}/ocean_runner/__init__.py +0 -0
- {ocean_runner-0.2.8 → ocean_runner-0.2.9}/ocean_runner/config.py +0 -0
|
@@ -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
|
|
File without changes
|
|
File without changes
|