oceanprotocol-job-details 0.0.1__py3-none-any.whl → 0.0.5__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.
- oceanprotocol_job_details/job_details.py +28 -0
- {src/oceanprotocol_job_details → oceanprotocol_job_details}/loaders/impl/environment.py +21 -7
- {oceanprotocol_job_details-0.0.1.dist-info → oceanprotocol_job_details-0.0.5.dist-info}/METADATA +32 -1
- oceanprotocol_job_details-0.0.5.dist-info/RECORD +13 -0
- oceanprotocol_job_details-0.0.1.dist-info/RECORD +0 -27
- src/oceanprotocol_job_details/dataclasses/__pycache__/__init__.cpython-313.pyc +0 -0
- src/oceanprotocol_job_details/dataclasses/__pycache__/__init__.cpython-39.pyc +0 -0
- src/oceanprotocol_job_details/dataclasses/__pycache__/constants.cpython-313.pyc +0 -0
- src/oceanprotocol_job_details/dataclasses/__pycache__/constants.cpython-39.pyc +0 -0
- src/oceanprotocol_job_details/dataclasses/__pycache__/job_details.cpython-313.pyc +0 -0
- src/oceanprotocol_job_details/dataclasses/__pycache__/job_details.cpython-39.pyc +0 -0
- src/oceanprotocol_job_details/job_details.py +0 -20
- src/oceanprotocol_job_details/loaders/__pycache__/__init__.cpython-313.pyc +0 -0
- src/oceanprotocol_job_details/loaders/__pycache__/__init__.cpython-39.pyc +0 -0
- src/oceanprotocol_job_details/loaders/__pycache__/loader.cpython-313.pyc +0 -0
- src/oceanprotocol_job_details/loaders/__pycache__/loader.cpython-39.pyc +0 -0
- src/oceanprotocol_job_details/loaders/impl/__pycache__/__init__.cpython-313.pyc +0 -0
- src/oceanprotocol_job_details/loaders/impl/__pycache__/__init__.cpython-39.pyc +0 -0
- src/oceanprotocol_job_details/loaders/impl/__pycache__/environment.cpython-313.pyc +0 -0
- src/oceanprotocol_job_details/loaders/impl/__pycache__/environment.cpython-39.pyc +0 -0
- {src/oceanprotocol_job_details → oceanprotocol_job_details}/__init__.py +0 -0
- {src/oceanprotocol_job_details → oceanprotocol_job_details}/dataclasses/__init__.py +0 -0
- {src/oceanprotocol_job_details → oceanprotocol_job_details}/dataclasses/constants.py +0 -0
- {src/oceanprotocol_job_details → oceanprotocol_job_details}/dataclasses/job_details.py +0 -0
- {src/oceanprotocol_job_details → oceanprotocol_job_details}/loaders/__init__.py +0 -0
- {src/oceanprotocol_job_details → oceanprotocol_job_details}/loaders/impl/__init__.py +0 -0
- {src/oceanprotocol_job_details → oceanprotocol_job_details}/loaders/loader.py +0 -0
- {oceanprotocol_job_details-0.0.1.dist-info → oceanprotocol_job_details-0.0.5.dist-info}/LICENSE +0 -0
- {oceanprotocol_job_details-0.0.1.dist-info → oceanprotocol_job_details-0.0.5.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from typing import Literal, Optional
|
|
2
|
+
from oceanprotocol_job_details.dataclasses.job_details import JobDetails
|
|
3
|
+
from oceanprotocol_job_details.loaders.loader import Loader
|
|
4
|
+
from oceanprotocol_job_details.loaders.impl.environment import EnvironmentLoader
|
|
5
|
+
|
|
6
|
+
_Implementations = Literal["env"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class OceanProtocolJobDetails(Loader[JobDetails]):
|
|
10
|
+
"""Decorator that loads the JobDetails from the given implementation"""
|
|
11
|
+
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
implementation: Optional[_Implementations] = "env",
|
|
15
|
+
*args,
|
|
16
|
+
**kwargs,
|
|
17
|
+
):
|
|
18
|
+
if implementation == "env":
|
|
19
|
+
# As there are not more implementations, we can use the EnvironmentLoader directly
|
|
20
|
+
self._loader = lambda: EnvironmentLoader(*args, **kwargs)
|
|
21
|
+
else:
|
|
22
|
+
raise NotImplementedError(f"Implementation {implementation} not supported")
|
|
23
|
+
|
|
24
|
+
def load(self) -> JobDetails:
|
|
25
|
+
return self._loader().load()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
del _Implementations
|
|
@@ -7,13 +7,13 @@ from json import load, loads
|
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
from typing import Optional, final
|
|
9
9
|
|
|
10
|
-
from
|
|
10
|
+
from oceanprotocol_job_details.dataclasses.constants import (
|
|
11
11
|
DidKeys,
|
|
12
12
|
Paths,
|
|
13
13
|
ServiceType,
|
|
14
14
|
)
|
|
15
|
-
from
|
|
16
|
-
from
|
|
15
|
+
from oceanprotocol_job_details.dataclasses.job_details import Algorithm, JobDetails
|
|
16
|
+
from oceanprotocol_job_details.loaders.loader import Loader
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
@dataclass(frozen=True)
|
|
@@ -51,7 +51,12 @@ class EnvironmentLoader(Loader[JobDetails]):
|
|
|
51
51
|
)
|
|
52
52
|
|
|
53
53
|
def _root(self) -> Path:
|
|
54
|
-
|
|
54
|
+
root = Path(self.mapper.get(Keys.ROOT, Path.home()))
|
|
55
|
+
|
|
56
|
+
if not root.exists():
|
|
57
|
+
raise FileNotFoundError(f"Root folder {root} does not exist")
|
|
58
|
+
|
|
59
|
+
return root
|
|
55
60
|
|
|
56
61
|
def _dids(self) -> Sequence[str]:
|
|
57
62
|
return loads(self.mapper.get(Keys.DIDS)) if Keys.DIDS in self.mapper else []
|
|
@@ -64,8 +69,11 @@ class EnvironmentLoader(Loader[JobDetails]):
|
|
|
64
69
|
files: Mapping[str, Sequence[Path]] = {}
|
|
65
70
|
for did in dids:
|
|
66
71
|
# Retrieve DDO from disk
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
file_path = root / Paths.DDOS / did
|
|
73
|
+
if not file_path.exists():
|
|
74
|
+
raise FileNotFoundError(f"DDO file {file_path} does not exist")
|
|
75
|
+
|
|
76
|
+
with open(file_path, "r") as f:
|
|
69
77
|
ddo = load(f)
|
|
70
78
|
for service in ddo[DidKeys.SERVICE]:
|
|
71
79
|
if service[DidKeys.SERVICE_TYPE] == ServiceType.METADATA:
|
|
@@ -87,11 +95,17 @@ class EnvironmentLoader(Loader[JobDetails]):
|
|
|
87
95
|
|
|
88
96
|
def _algorithm(self, root: Path) -> Algorithm:
|
|
89
97
|
did = self.mapper.get(Keys.ALGORITHM, None)
|
|
98
|
+
|
|
90
99
|
if not did:
|
|
91
100
|
return None
|
|
101
|
+
|
|
102
|
+
ddo = root / Paths.DDOS / did
|
|
103
|
+
if not ddo.exists():
|
|
104
|
+
raise FileNotFoundError(f"DDO file {ddo} does not exist")
|
|
105
|
+
|
|
92
106
|
return Algorithm(
|
|
93
107
|
did=did,
|
|
94
|
-
ddo=
|
|
108
|
+
ddo=ddo,
|
|
95
109
|
)
|
|
96
110
|
|
|
97
111
|
def _secret(self) -> str:
|
{oceanprotocol_job_details-0.0.1.dist-info → oceanprotocol_job_details-0.0.5.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: oceanprotocol-job-details
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: A Python package to get details from OceanProtocol jobs
|
|
5
5
|
License: Copyright 2025 Agrospai
|
|
6
6
|
|
|
@@ -29,3 +29,34 @@ A Python package to get details from OceanProtocol jobs
|
|
|
29
29
|
```
|
|
30
30
|
pip install oceanprotocol-job-details
|
|
31
31
|
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
As a simple library, we only need to import the main object and use it once:
|
|
36
|
+
|
|
37
|
+
```Python
|
|
38
|
+
from oceanprotocol_job_details.job_details import OceanProtocolJobDetails
|
|
39
|
+
|
|
40
|
+
# Using default parameters
|
|
41
|
+
job_details = OceanProtocolJobDetails().load()
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Advanced Usage (not recommended)
|
|
45
|
+
|
|
46
|
+
If instead of the environment variables, we want to use another kind of mapping, can pass it as a parameter and it will work as long as it has the same key values (Can be implemented in a more generic way, but there is no need right now).
|
|
47
|
+
|
|
48
|
+
```Python
|
|
49
|
+
from oceanprotocol_job_details.job_details import OceanProtocolJobDetails
|
|
50
|
+
from oceanprotocol_job_details.loaders.impl.environment import Keys
|
|
51
|
+
|
|
52
|
+
# Fill in with values that will be used instead of env
|
|
53
|
+
custom_mapper = {
|
|
54
|
+
Keys.ALGORITHM: " ... ",
|
|
55
|
+
Keys.DIDS: " ... ",
|
|
56
|
+
Keys.ROOT: " ... ",
|
|
57
|
+
Keys.SECRET: " ... ",
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
job_details = OceanProtocolJobDetails(mapper=custom_mapper).load()
|
|
61
|
+
```
|
|
62
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
oceanprotocol_job_details/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
oceanprotocol_job_details/dataclasses/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
oceanprotocol_job_details/dataclasses/constants.py,sha256=CWkWtBgKjI8xyHPKIwJ2lStpyCTDnfnWXvcXlIFYWig,773
|
|
4
|
+
oceanprotocol_job_details/dataclasses/job_details.py,sha256=7y8LoiPmAPsS71HRzm6pWbB7TwV9qIwe1Cd2Dgd4liE,860
|
|
5
|
+
oceanprotocol_job_details/job_details.py,sha256=GfzHNAWpYC0SBHdB1O4im5MNfuxLyRn-dFrhhxo2Ogw,946
|
|
6
|
+
oceanprotocol_job_details/loaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
oceanprotocol_job_details/loaders/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
oceanprotocol_job_details/loaders/impl/environment.py,sha256=2fu46KssPvwI0wal3UVKeKMf5_WEHJnVW0aLKMf7Nk8,3414
|
|
9
|
+
oceanprotocol_job_details/loaders/loader.py,sha256=JwR6OSkzIQQkeeyAU-ad_F89W9WNvoRwvHQY7Q3zIXI,256
|
|
10
|
+
oceanprotocol_job_details-0.0.5.dist-info/LICENSE,sha256=ni3ix7P_GxK1W3VGC4fJ3o6QoCngCEpSuTJwO4nkpbw,1055
|
|
11
|
+
oceanprotocol_job_details-0.0.5.dist-info/METADATA,sha256=vCYufxlwewMK8WpL37ej6tEZ_7eu-IJMhHKKKusyum8,2793
|
|
12
|
+
oceanprotocol_job_details-0.0.5.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
13
|
+
oceanprotocol_job_details-0.0.5.dist-info/RECORD,,
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
src/oceanprotocol_job_details/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
src/oceanprotocol_job_details/dataclasses/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
src/oceanprotocol_job_details/dataclasses/__pycache__/__init__.cpython-313.pyc,sha256=0ONMfxi9YdNbrlvd7HHyKh2D2cclkF8_sfHxnk4QPT4,210
|
|
4
|
-
src/oceanprotocol_job_details/dataclasses/__pycache__/__init__.cpython-39.pyc,sha256=7IaVhvOAnm2gtr5G8j5exCNzoBYsr7hcEbDmAEEqTro,214
|
|
5
|
-
src/oceanprotocol_job_details/dataclasses/__pycache__/constants.cpython-313.pyc,sha256=_7cahtV77VBhIQRsHzVXEkdJy-hZcJfbx50EAvwhrB8,1886
|
|
6
|
-
src/oceanprotocol_job_details/dataclasses/__pycache__/constants.cpython-39.pyc,sha256=CKNB_CwiQ3ovpftAPEeQF1ZvZgz7OmpNYN7DGA94yZM,1428
|
|
7
|
-
src/oceanprotocol_job_details/dataclasses/__pycache__/job_details.cpython-313.pyc,sha256=kUxopSviCQSMPQCP5YcApB9TXUwR6XN9BI9m3rE-UKo,1369
|
|
8
|
-
src/oceanprotocol_job_details/dataclasses/__pycache__/job_details.cpython-39.pyc,sha256=C3n5BqEo0ZQo4DYXqWvMj3NYW-XKVFxWtec7dbUpJ6k,1042
|
|
9
|
-
src/oceanprotocol_job_details/dataclasses/constants.py,sha256=CWkWtBgKjI8xyHPKIwJ2lStpyCTDnfnWXvcXlIFYWig,773
|
|
10
|
-
src/oceanprotocol_job_details/dataclasses/job_details.py,sha256=7y8LoiPmAPsS71HRzm6pWbB7TwV9qIwe1Cd2Dgd4liE,860
|
|
11
|
-
src/oceanprotocol_job_details/job_details.py,sha256=w0SKnmNlAj7rBRx3uqZ3VkxFcLK15tzDKV-a2ZjJLio,765
|
|
12
|
-
src/oceanprotocol_job_details/loaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
src/oceanprotocol_job_details/loaders/__pycache__/__init__.cpython-313.pyc,sha256=caqlfFNy8aRS-NJB1cTGZcxYpTtEN-jo3ko3URP0xnA,206
|
|
14
|
-
src/oceanprotocol_job_details/loaders/__pycache__/__init__.cpython-39.pyc,sha256=pc23pM8sGE4f260FM8sT-M0Qql660vUDjtrt7phY4W8,210
|
|
15
|
-
src/oceanprotocol_job_details/loaders/__pycache__/loader.cpython-313.pyc,sha256=vHfalXDEN178-qFNfAqPhkFTSB8JhlBG_lRcpPbddUU,827
|
|
16
|
-
src/oceanprotocol_job_details/loaders/__pycache__/loader.cpython-39.pyc,sha256=tXChWYmZnyBtRgPQoHGP3i3dHMpPmxP-f_rCz92i1Gk,693
|
|
17
|
-
src/oceanprotocol_job_details/loaders/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
-
src/oceanprotocol_job_details/loaders/impl/__pycache__/__init__.cpython-313.pyc,sha256=SfhHqoTLJUeOLvPm9_x4niYNVumJaP4L4ilj8GNLbR0,211
|
|
19
|
-
src/oceanprotocol_job_details/loaders/impl/__pycache__/__init__.cpython-39.pyc,sha256=zeCeX-1xNkV2K7Wc-pxUiqiA6YGSzxHtrX0MwHvs46g,215
|
|
20
|
-
src/oceanprotocol_job_details/loaders/impl/__pycache__/environment.cpython-313.pyc,sha256=hWSoqiSjFPAPuPZTiagjcHQpKDvHJU0feETedMVXenM,5628
|
|
21
|
-
src/oceanprotocol_job_details/loaders/impl/__pycache__/environment.cpython-39.pyc,sha256=jRusbU4hEZNwAceFjicor38yipl3_768zeUnOHuy5BA,3824
|
|
22
|
-
src/oceanprotocol_job_details/loaders/impl/environment.py,sha256=Eej428jnf2XX3Tv_K4sGFBKG-ZYIyDqN6e4m3_gF1JI,3041
|
|
23
|
-
src/oceanprotocol_job_details/loaders/loader.py,sha256=JwR6OSkzIQQkeeyAU-ad_F89W9WNvoRwvHQY7Q3zIXI,256
|
|
24
|
-
oceanprotocol_job_details-0.0.1.dist-info/LICENSE,sha256=ni3ix7P_GxK1W3VGC4fJ3o6QoCngCEpSuTJwO4nkpbw,1055
|
|
25
|
-
oceanprotocol_job_details-0.0.1.dist-info/METADATA,sha256=4BJ-6XobKtaD-c0lBVGGLQhxV-qdppugIIFP0DHwkY8,1857
|
|
26
|
-
oceanprotocol_job_details-0.0.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
27
|
-
oceanprotocol_job_details-0.0.1.dist-info/RECORD,,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
from typing import Literal, Optional
|
|
2
|
-
from src.oceanprotocol_job_details.dataclasses.job_details import JobDetails
|
|
3
|
-
from src.oceanprotocol_job_details.loaders.loader import Loader
|
|
4
|
-
from src.oceanprotocol_job_details.loaders.impl.environment import EnvironmentLoader
|
|
5
|
-
|
|
6
|
-
_Implementations = Literal["env"]
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class OceanProtocolJobDetails(Loader[JobDetails]):
|
|
10
|
-
"""Decorator that loads the JobDetails from the given implementation"""
|
|
11
|
-
|
|
12
|
-
def __init__(self, implementation: Optional[_Implementations], *args, **kwargs):
|
|
13
|
-
# As there are not more implementations, we can use the EnvironmentLoader directly
|
|
14
|
-
self._loader = lambda: EnvironmentLoader(*args, **kwargs)
|
|
15
|
-
|
|
16
|
-
def load(self) -> JobDetails:
|
|
17
|
-
return self._loader().load()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
del _Implementations
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oceanprotocol_job_details-0.0.1.dist-info → oceanprotocol_job_details-0.0.5.dist-info}/LICENSE
RENAMED
|
File without changes
|
{oceanprotocol_job_details-0.0.1.dist-info → oceanprotocol_job_details-0.0.5.dist-info}/WHEEL
RENAMED
|
File without changes
|