oceanprotocol-job-details 0.1.2__py3-none-any.whl → 0.1.4__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/config.py +11 -10
- oceanprotocol_job_details/ocean.py +29 -1
- {oceanprotocol_job_details-0.1.2.dist-info → oceanprotocol_job_details-0.1.4.dist-info}/METADATA +1 -1
- {oceanprotocol_job_details-0.1.2.dist-info → oceanprotocol_job_details-0.1.4.dist-info}/RECORD +6 -6
- {oceanprotocol_job_details-0.1.2.dist-info → oceanprotocol_job_details-0.1.4.dist-info}/WHEEL +0 -0
- {oceanprotocol_job_details-0.1.2.dist-info → oceanprotocol_job_details-0.1.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -9,22 +9,22 @@ logger = getLogger(__name__)
|
|
|
9
9
|
class Config:
|
|
10
10
|
"""Configuration class for the Ocean Protocol Job Details"""
|
|
11
11
|
|
|
12
|
-
path_data:
|
|
12
|
+
path_data: Path = Path("/data")
|
|
13
13
|
"""The path to the data directory"""
|
|
14
14
|
|
|
15
|
-
path_inputs:
|
|
15
|
+
path_inputs: Path = path_data / "inputs"
|
|
16
16
|
"""The path to the inputs directory"""
|
|
17
17
|
|
|
18
|
-
path_ddos:
|
|
18
|
+
path_ddos: Path = path_data / "ddos"
|
|
19
19
|
"""The path to the DDOs directory"""
|
|
20
20
|
|
|
21
|
-
path_outputs:
|
|
21
|
+
path_outputs: Path = path_data / "outputs"
|
|
22
22
|
"""The path to the outputs directory"""
|
|
23
23
|
|
|
24
|
-
path_logs:
|
|
24
|
+
path_logs: Path = path_data / "logs"
|
|
25
25
|
"""The path to the logs directory"""
|
|
26
26
|
|
|
27
|
-
path_algorithm_custom_parameters:
|
|
27
|
+
path_algorithm_custom_parameters: Path = path_inputs / "algoCustomData.json"
|
|
28
28
|
"""The path to the algorithm's custom parameters file"""
|
|
29
29
|
|
|
30
30
|
|
|
@@ -43,11 +43,12 @@ def update_config_from(base: Path) -> None:
|
|
|
43
43
|
base.mkdir(parents=True, exist_ok=True)
|
|
44
44
|
|
|
45
45
|
for field in fields(config):
|
|
46
|
-
|
|
47
|
-
if
|
|
48
|
-
raise ValueError(f"Field {field.name}
|
|
46
|
+
current_value = getattr(config, field.name)
|
|
47
|
+
if not isinstance(current_value, Path):
|
|
48
|
+
raise ValueError(f"Field {field.name} is n|ot a Path")
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
rel_path = Path(current_value).relative_to("/data")
|
|
51
|
+
object.__setattr__(config, field.name, base / rel_path)
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
__all__ = ["config"]
|
|
@@ -2,6 +2,8 @@ from dataclasses import dataclass, field
|
|
|
2
2
|
from functools import cached_property
|
|
3
3
|
from typing import Any, Generic, Optional, Type, TypeVar, final
|
|
4
4
|
|
|
5
|
+
import orjson
|
|
6
|
+
|
|
5
7
|
from dataclasses_json import config as dc_config
|
|
6
8
|
from dataclasses_json import dataclass_json
|
|
7
9
|
|
|
@@ -155,6 +157,20 @@ class DDO:
|
|
|
155
157
|
purgatory: Purgatory
|
|
156
158
|
|
|
157
159
|
|
|
160
|
+
def _normalize_json(value):
|
|
161
|
+
if isinstance(value, str):
|
|
162
|
+
try:
|
|
163
|
+
decoded = orjson.loads(value)
|
|
164
|
+
return _normalize_json(decoded) # recurse if nested again
|
|
165
|
+
except orjson.JSONDecodeError:
|
|
166
|
+
return value
|
|
167
|
+
elif isinstance(value, dict):
|
|
168
|
+
return {k: _normalize_json(v) for k, v in value.items()}
|
|
169
|
+
elif isinstance(value, list):
|
|
170
|
+
return [_normalize_json(v) for v in value]
|
|
171
|
+
return value
|
|
172
|
+
|
|
173
|
+
|
|
158
174
|
@final
|
|
159
175
|
@dataclass_json
|
|
160
176
|
@dataclass(frozen=True)
|
|
@@ -180,4 +196,16 @@ class JobDetails(Generic[T]):
|
|
|
180
196
|
"""Read the input parameters and return them in an instance of the dataclass T"""
|
|
181
197
|
|
|
182
198
|
with open(config.path_algorithm_custom_parameters, "r") as f:
|
|
183
|
-
|
|
199
|
+
raw = f.read().strip()
|
|
200
|
+
if not raw:
|
|
201
|
+
raise ValueError(
|
|
202
|
+
f"Custom parameters file {config.path_algorithm_custom_parameters} is empty"
|
|
203
|
+
)
|
|
204
|
+
try:
|
|
205
|
+
parsed = _normalize_json(orjson.loads(raw))
|
|
206
|
+
return dataclass_json(self._type).from_dict(parsed) # type: ignore
|
|
207
|
+
except Exception as e:
|
|
208
|
+
raise ValueError(
|
|
209
|
+
f"Failed to parse input paramers into {self._type.__name__}: {e}\n"
|
|
210
|
+
f"Raw content: {raw}"
|
|
211
|
+
) from e
|
{oceanprotocol_job_details-0.1.2.dist-info → oceanprotocol_job_details-0.1.4.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: oceanprotocol-job-details
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
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
|
{oceanprotocol_job_details-0.1.2.dist-info → oceanprotocol_job_details-0.1.4.dist-info}/RECORD
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
oceanprotocol_job_details/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
oceanprotocol_job_details/config.py,sha256=
|
|
2
|
+
oceanprotocol_job_details/config.py,sha256=e-V1ybwr-LzuceyhZalmPOTzpgTbuUxlwjbLu7EJMvc,1469
|
|
3
3
|
oceanprotocol_job_details/job_details.py,sha256=98Uvx3jes1f75onYxT-65EOOOwcxdw32slAa3n1MqUc,1477
|
|
4
|
-
oceanprotocol_job_details/ocean.py,sha256=
|
|
4
|
+
oceanprotocol_job_details/ocean.py,sha256=N27O-qzE6NMYaTIe2O_ZNKdQGuFKtfPELy2-_IdEZls,4505
|
|
5
5
|
oceanprotocol_job_details/utils.py,sha256=btgys1g4AKSADsde_JRofPVmI0VbR_jf85DIYhuMhgs,940
|
|
6
6
|
oceanprotocol_job_details/loaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
oceanprotocol_job_details/loaders/loader.py,sha256=HIzsVKCuGP7ghfM7ppN3ANVybvsA64wr3h8I68mqS6A,195
|
|
@@ -9,7 +9,7 @@ oceanprotocol_job_details/loaders/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JC
|
|
|
9
9
|
oceanprotocol_job_details/loaders/impl/ddo.py,sha256=LcKoDuGnZw8JW68Q5P9gWGYeZqszC97HxnkzOuorHBA,707
|
|
10
10
|
oceanprotocol_job_details/loaders/impl/files.py,sha256=hft3Y61D6eHpa9ZQ5i2C5tnCv9IZaTudOZaOIQUbkxo,2002
|
|
11
11
|
oceanprotocol_job_details/loaders/impl/job_details.py,sha256=ERKQm1oH3jW8ebb8l4glL-Wm-9rV8mBfFalVvo0UomU,802
|
|
12
|
-
oceanprotocol_job_details-0.1.
|
|
13
|
-
oceanprotocol_job_details-0.1.
|
|
14
|
-
oceanprotocol_job_details-0.1.
|
|
15
|
-
oceanprotocol_job_details-0.1.
|
|
12
|
+
oceanprotocol_job_details-0.1.4.dist-info/METADATA,sha256=mfNcO-GwsN59tmuWhGBUfc43bghmY46GqSp1Kk1QyY0,3141
|
|
13
|
+
oceanprotocol_job_details-0.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
14
|
+
oceanprotocol_job_details-0.1.4.dist-info/licenses/LICENSE,sha256=ni3ix7P_GxK1W3VGC4fJ3o6QoCngCEpSuTJwO4nkpbw,1055
|
|
15
|
+
oceanprotocol_job_details-0.1.4.dist-info/RECORD,,
|
{oceanprotocol_job_details-0.1.2.dist-info → oceanprotocol_job_details-0.1.4.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|