|
18 | 18 | ) |
19 | 19 |
|
20 | 20 | from oceanprotocol_job_details import ( |
| 21 | + EmptyInputParameters, |
21 | 22 | EmptyJobDetails, |
22 | 23 | ParametrizedJobDetails, |
23 | 24 | load_job_details, |
24 | 25 | run_in_executor, |
25 | 26 | ) |
26 | 27 | from oceanprotocol_job_details.ocean import _BaseJobDetails |
27 | 28 | from pydantic import BaseModel, JsonValue |
28 | | -from returns.result import Failure, Success |
29 | 29 | from typing_extensions import override |
30 | 30 |
|
31 | 31 | from ocean_runner.config import Config |
32 | 32 |
|
33 | | -InputT = TypeVar("InputT", bound=BaseModel | None) |
| 33 | +InputT = TypeVar("InputT", bound=BaseModel) |
34 | 34 | ResultT = TypeVar("ResultT") |
35 | 35 | T = TypeVar("T") |
36 | 36 |
|
@@ -251,19 +251,18 @@ class ParametrizedAlgorithm(Algorithm[InputT, ResultT]): |
251 | 251 | @override |
252 | 252 | @cached_property |
253 | 253 | def job_details(self) -> ParametrizedJobDetails[InputT]: |
254 | | - match self._job_details.read(): |
255 | | - case Success(parametrized_job_details): |
256 | | - return parametrized_job_details |
257 | | - case Failure(error): |
258 | | - raise error |
259 | | - case _: # pragma: no cover |
260 | | - raise RuntimeError("Unreachable code") |
| 254 | + result = self._job_details.read() |
261 | 255 |
|
| 256 | + if isinstance(result, Exception): |
| 257 | + raise result |
262 | 258 |
|
263 | | -class EmptyAlgorithm(Algorithm[None, ResultT]): |
| 259 | + return result |
| 260 | + |
| 261 | + |
| 262 | +class EmptyAlgorithm(Algorithm[EmptyInputParameters, ResultT]): |
264 | 263 | """For algorithms with no custom parameters""" |
265 | 264 |
|
266 | 265 | @override |
267 | 266 | @cached_property |
268 | | - def job_details(self) -> EmptyJobDetails[None]: |
269 | | - return cast(EmptyJobDetails[None], self._job_details) |
| 267 | + def job_details(self) -> EmptyJobDetails[EmptyInputParameters]: |
| 268 | + return cast(EmptyJobDetails[EmptyInputParameters], self._job_details) |
0 commit comments