oceanprotocol-job-details 0.3.11__tar.gz → 0.3.13__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.
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/PKG-INFO +4 -3
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/README.md +3 -2
- oceanprotocol_job_details-0.3.13/oceanprotocol_job_details/executors.py +25 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/ocean.py +9 -5
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/pyproject.toml +9 -2
- oceanprotocol_job_details-0.3.11/oceanprotocol_job_details/executors.py +0 -13
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/.gitignore +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/LICENSE +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/__init__.py +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/di.py +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/domain.py +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/helpers.py +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/loaders/__init__.py +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/loaders/impl/__init__.py +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/loaders/impl/ddo.py +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/loaders/impl/files.py +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/loaders/impl/job_details.py +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/loaders/loader.py +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/py.typed +0 -0
- {oceanprotocol_job_details-0.3.11 → oceanprotocol_job_details-0.3.13}/oceanprotocol_job_details/settings.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: oceanprotocol-job-details
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.13
|
|
4
4
|
Summary: A Python package to get details from OceanProtocol jobs
|
|
5
5
|
Project-URL: Homepage, https://github.com/AgrospAI/oceanprotocol-job-details
|
|
6
6
|
Project-URL: Issues, https://github.com/AgrospAI/oceanprotocol-job-details/issues
|
|
@@ -72,8 +72,9 @@ class InputParameters(BaseModel):
|
|
|
72
72
|
job_details = load_job_details({"base_dir": "...", "transformation_did": "..."}, InputParameters)
|
|
73
73
|
|
|
74
74
|
# Usage
|
|
75
|
-
job_details.input_parameters
|
|
76
|
-
|
|
75
|
+
parameters = await job_details.input_parameters()
|
|
76
|
+
parameters.foo
|
|
77
|
+
parameters.foo.bar
|
|
77
78
|
```
|
|
78
79
|
|
|
79
80
|
The values to fill the custom `InputParameters` will be parsed from the `algoCustomData.json` located next to the input data directories.
|
|
@@ -46,8 +46,9 @@ class InputParameters(BaseModel):
|
|
|
46
46
|
job_details = load_job_details({"base_dir": "...", "transformation_did": "..."}, InputParameters)
|
|
47
47
|
|
|
48
48
|
# Usage
|
|
49
|
-
job_details.input_parameters
|
|
50
|
-
|
|
49
|
+
parameters = await job_details.input_parameters()
|
|
50
|
+
parameters.foo
|
|
51
|
+
parameters.foo.bar
|
|
51
52
|
```
|
|
52
53
|
|
|
53
54
|
The values to fill the custom `InputParameters` will be parsed from the `algoCustomData.json` located next to the input data directories.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import inspect
|
|
3
|
+
from typing import Any, Callable, Coroutine, TypeVar
|
|
4
|
+
|
|
5
|
+
T = TypeVar("T")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async def run_in_executor(
|
|
9
|
+
obj: Callable[..., T]
|
|
10
|
+
| Callable[..., Coroutine[Any, Any, T]]
|
|
11
|
+
| Coroutine[Any, Any, T],
|
|
12
|
+
*args,
|
|
13
|
+
**kwargs,
|
|
14
|
+
) -> T:
|
|
15
|
+
if inspect.iscoroutinefunction(obj):
|
|
16
|
+
return await obj(*args, **kwargs)
|
|
17
|
+
|
|
18
|
+
if inspect.iscoroutine(obj):
|
|
19
|
+
return await obj
|
|
20
|
+
|
|
21
|
+
if callable(obj):
|
|
22
|
+
loop = asyncio.get_running_loop()
|
|
23
|
+
return await loop.run_in_executor(None, obj, *args, **kwargs)
|
|
24
|
+
|
|
25
|
+
return obj
|
|
@@ -9,7 +9,7 @@ import aiofiles
|
|
|
9
9
|
from pydantic import BaseModel, ConfigDict, Secret
|
|
10
10
|
|
|
11
11
|
from oceanprotocol_job_details.domain import DDO, Files, Paths
|
|
12
|
-
from oceanprotocol_job_details.
|
|
12
|
+
from oceanprotocol_job_details.executors import run_in_executor
|
|
13
13
|
|
|
14
14
|
InputParametersT = TypeVar("InputParametersT", BaseModel, None)
|
|
15
15
|
|
|
@@ -24,6 +24,8 @@ class JobDetails(BaseModel, Generic[InputParametersT]): # type: ignore[explicit
|
|
|
24
24
|
|
|
25
25
|
model_config = ConfigDict(arbitrary_types_allowed=True, frozen=True)
|
|
26
26
|
|
|
27
|
+
_input_parameters: InputParametersT | None = None
|
|
28
|
+
|
|
27
29
|
def inputs(self) -> Generator[Tuple[int, Path], None, None]:
|
|
28
30
|
yield from (
|
|
29
31
|
(idx, file)
|
|
@@ -31,11 +33,13 @@ class JobDetails(BaseModel, Generic[InputParametersT]): # type: ignore[explicit
|
|
|
31
33
|
for file in files.input_files
|
|
32
34
|
)
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
async def input_parameters(self) -> InputParametersT:
|
|
37
|
+
if self._input_parameters is None:
|
|
38
|
+
input_parameters = await self.ainput_parameters()
|
|
39
|
+
object.__setattr__(self, "_input_parameters", input_parameters)
|
|
40
|
+
return self._input_parameters
|
|
37
41
|
|
|
38
|
-
async def ainput_parameters(self) -> InputParametersT
|
|
42
|
+
async def ainput_parameters(self) -> InputParametersT:
|
|
39
43
|
if self.input_type is None:
|
|
40
44
|
return None
|
|
41
45
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "oceanprotocol-job-details"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.13"
|
|
4
4
|
description = "A Python package to get details from OceanProtocol jobs"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Agrospai", email = "agrospai@udl.cat" },
|
|
@@ -27,6 +27,8 @@ Homepage = "https://github.com/AgrospAI/oceanprotocol-job-details"
|
|
|
27
27
|
Issues = "https://github.com/AgrospAI/oceanprotocol-job-details/issues"
|
|
28
28
|
|
|
29
29
|
[tool.pytest.ini_options]
|
|
30
|
+
asyncio_mode = "auto"
|
|
31
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
30
32
|
log_level = "INFO"
|
|
31
33
|
pythonpath = "oceanprotocol_job_details"
|
|
32
34
|
log_cli = true
|
|
@@ -51,4 +53,9 @@ warn_return_any = true
|
|
|
51
53
|
disallow_any_explicit = true
|
|
52
54
|
|
|
53
55
|
[dependency-groups]
|
|
54
|
-
dev = [
|
|
56
|
+
dev = [
|
|
57
|
+
"mypy>=1.15.0",
|
|
58
|
+
"pytest>=8.3.4",
|
|
59
|
+
"pytest-asyncio>=1.3.0",
|
|
60
|
+
"types-aiofiles>=25.1.0.20251011",
|
|
61
|
+
]
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
from typing import Coroutine, TypeVar
|
|
3
|
-
|
|
4
|
-
T = TypeVar("T")
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def run_in_executor(coro: Coroutine[None, None, T]) -> T:
|
|
8
|
-
try:
|
|
9
|
-
loop = asyncio.get_running_loop()
|
|
10
|
-
except RuntimeError:
|
|
11
|
-
return asyncio.run(coro)
|
|
12
|
-
else:
|
|
13
|
-
return loop.run_until_complete(coro)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|