oceanprotocol-job-details 0.0.10__tar.gz → 0.0.11__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.
Files changed (16) hide show
  1. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/PKG-INFO +1 -1
  2. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/oceanprotocol_job_details/dataclasses/job_details.py +5 -13
  3. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/oceanprotocol_job_details/dataclasses/ocean.py +67 -67
  4. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/oceanprotocol_job_details/loaders/impl/map.py +0 -2
  5. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/pyproject.toml +1 -1
  6. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/.gitignore +0 -0
  7. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/LICENSE +0 -0
  8. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/README.md +0 -0
  9. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/oceanprotocol_job_details/__init__.py +0 -0
  10. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/oceanprotocol_job_details/dataclasses/__init__.py +0 -0
  11. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/oceanprotocol_job_details/dataclasses/constants.py +0 -0
  12. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/oceanprotocol_job_details/job_details.py +0 -0
  13. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/oceanprotocol_job_details/loaders/__init__.py +0 -0
  14. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/oceanprotocol_job_details/loaders/impl/__init__.py +0 -0
  15. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/oceanprotocol_job_details/loaders/impl/utils.py +0 -0
  16. {oceanprotocol_job_details-0.0.10 → oceanprotocol_job_details-0.0.11}/oceanprotocol_job_details/loaders/loader.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oceanprotocol-job-details
3
- Version: 0.0.10
3
+ Version: 0.0.11
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
@@ -1,10 +1,11 @@
1
- import json
2
1
  import logging
3
2
  import os
4
3
  from dataclasses import InitVar, dataclass
5
4
  from pathlib import Path
6
5
  from typing import Any, Mapping, Optional, Sequence
7
6
 
7
+ from orjson import JSONDecodeError, loads
8
+
8
9
  from oceanprotocol_job_details.dataclasses.constants import Paths
9
10
 
10
11
  _MetadataType = Mapping[str, Any]
@@ -50,13 +51,6 @@ class JobDetails:
50
51
  # Cache parameters, should not be included as _fields_ of the class
51
52
  _parameters: InitVar[Optional[_MetadataType]] = None
52
53
 
53
- def __post_init__(self, _):
54
- os.makedirs(Paths.LOGS, exist_ok=True)
55
-
56
- logging.getLogger().addHandler(
57
- logging.FileHandler(Paths.LOGS / "job_details.log", mode="w")
58
- )
59
-
60
54
  @property
61
55
  def parameters(self, parameters: Optional[Path] = None) -> _MetadataType:
62
56
  """Parameters for algorithm job, read from default path"""
@@ -66,16 +60,14 @@ class JobDetails:
66
60
 
67
61
  if self._parameters is None:
68
62
  if not parameters.exists():
69
- logging.warning(
70
- f"Parameters file {parameters} not found, supplying empty"
71
- )
63
+ logging.warning(f"Missing parameters file: {parameters} not found")
72
64
  self._parameters = {}
73
65
  else:
74
66
  # Load the parameters from filesystem
75
67
  with open(parameters, "r") as f:
76
68
  try:
77
- self._parameters = json.load(f)
78
- except json.JSONDecodeError as e:
69
+ self._parameters = loads(f.read())
70
+ except JSONDecodeError as e:
79
71
  self._parameters = {}
80
72
  logger.warning(
81
73
  f"Error loading parameters file {parameters}: {e}"
@@ -1,67 +1,67 @@
1
- from dataclasses import Field
2
- from datetime import datetime
3
- from typing import Annotated, Any, List, Optional
4
-
5
- from pydantic import BaseModel, HttpUrl
6
-
7
- """Base classes for the Ocean Protocol algorithm structure"""
8
-
9
-
10
- class Credential:
11
- type: Annotated[str, Field(frozen=True)]
12
- values: Annotated[List[str], Field(frozen=True)]
13
-
14
-
15
- class Credentials:
16
- allow: Optional[Annotated[List[Credential], Field(frozen=True)]] = []
17
- deny: Optional[Annotated[List[Credential], Field(frozen=True)]] = []
18
-
19
-
20
- class Metadata(BaseModel):
21
- """Base class for the Metadata structure"""
22
-
23
- description: Annotated[str, Field(frozen=True)]
24
- name: Annotated[str, Field(frozen=True)]
25
- type: Annotated[str, Field(frozen=True)]
26
- author: Annotated[str, Field(frozen=True)]
27
- license: Annotated[str, Field(frozen=True)]
28
-
29
- algorithm: Any
30
- tags: Optional[Annotated[List[str], Field(frozen=True)]] = None
31
- created: Optional[Annotated[datetime, Field(frozen=True)]] = None
32
- updated: Optional[Annotated[datetime, Field(frozen=True)]] = None
33
- copyrightHolder: Optional[Annotated[str, Field(frozen=True)]] = None
34
- links: Optional[Annotated[List[HttpUrl], Field(frozen=True)]] = None
35
- contentLanguage: Optional[Annotated[str, Field(frozen=True)]] = None
36
- categories: Optional[Annotated[List[str], Field(frozen=True)]] = None
37
-
38
-
39
- class Service(BaseModel):
40
- """Base class for the Service structure"""
41
-
42
- id: Annotated[str, Field(frozen=True)]
43
- type: Annotated[str, Field(frozen=True)]
44
- timeout: Annotated[int, Field(frozen=True)]
45
- files: Annotated[str, Field(frozen=True)]
46
- datatokenAddress: Annotated[str, Field(frozen=True)]
47
- serviceEndpoint: Annotated[HttpUrl, Field(frozen=True)]
48
-
49
- compute: Any
50
- consumerParameters: Any
51
- additionalInformation: Any
52
- name: Optional[Annotated[str, Field(frozen=True)]] = None
53
- description: Optional[Annotated[str, Field(frozen=True)]] = None
54
-
55
-
56
- class DDO(BaseModel):
57
- """DDO structure in Ocean Protocol"""
58
-
59
- id: Annotated[str, Field(frozen=True)]
60
- context: Annotated[List[str], Field(frozen=True)]
61
- version: Annotated[str, Field(frozen=True)]
62
- chainId: Annotated[int, Field(frozen=True)]
63
- nftAddress: Annotated[str, Field(frozen=True)]
64
- metadata: Annotated[Metadata, Field(frozen=True)]
65
- services: Annotated[List[Service], Field(frozen=True)]
66
-
67
- credentials: Annotated[Optional[str], Field(frozen=True)] = None
1
+ from dataclasses import Field
2
+ from datetime import datetime
3
+ from typing import Annotated, Any, List, Optional
4
+
5
+ from pydantic import BaseModel, HttpUrl
6
+
7
+ """Base classes for the Ocean Protocol algorithm structure"""
8
+
9
+
10
+ class Credential:
11
+ type: Annotated[str, Field(frozen=True)]
12
+ values: Annotated[List[str], Field(frozen=True)]
13
+
14
+
15
+ class Credentials:
16
+ allow: Optional[Annotated[List[Credential], Field(frozen=True)]] = []
17
+ deny: Optional[Annotated[List[Credential], Field(frozen=True)]] = []
18
+
19
+
20
+ class Metadata(BaseModel):
21
+ """Base class for the Metadata structure"""
22
+
23
+ description: Annotated[str, Field(frozen=True)]
24
+ name: Annotated[str, Field(frozen=True)]
25
+ type: Annotated[str, Field(frozen=True)]
26
+ author: Annotated[str, Field(frozen=True)]
27
+ license: Annotated[str, Field(frozen=True)]
28
+
29
+ algorithm: Any
30
+ tags: Optional[Annotated[List[str], Field(frozen=True)]] = None
31
+ created: Optional[Annotated[datetime, Field(frozen=True)]] = None
32
+ updated: Optional[Annotated[datetime, Field(frozen=True)]] = None
33
+ copyrightHolder: Optional[Annotated[str, Field(frozen=True)]] = None
34
+ links: Optional[Annotated[List[HttpUrl], Field(frozen=True)]] = None
35
+ contentLanguage: Optional[Annotated[str, Field(frozen=True)]] = None
36
+ categories: Optional[Annotated[List[str], Field(frozen=True)]] = None
37
+
38
+
39
+ class Service(BaseModel):
40
+ """Base class for the Service structure"""
41
+
42
+ id: Annotated[str, Field(frozen=True)]
43
+ type: Annotated[str, Field(frozen=True)]
44
+ timeout: Annotated[int, Field(frozen=True)]
45
+ files: Annotated[str, Field(frozen=True)]
46
+ datatokenAddress: Annotated[str, Field(frozen=True)]
47
+ serviceEndpoint: Annotated[HttpUrl, Field(frozen=True)]
48
+
49
+ compute: Any
50
+ consumerParameters: Any
51
+ additionalInformation: Any
52
+ name: Optional[Annotated[str, Field(frozen=True)]] = None
53
+ description: Optional[Annotated[str, Field(frozen=True)]] = None
54
+
55
+
56
+ class DDO(BaseModel):
57
+ """DDO structure in Ocean Protocol"""
58
+
59
+ id: Annotated[str, Field(frozen=True)]
60
+ context: Annotated[List[str], Field(frozen=True)]
61
+ version: Annotated[str, Field(frozen=True)]
62
+ chainId: Annotated[int, Field(frozen=True)]
63
+ nftAddress: Annotated[str, Field(frozen=True)]
64
+ metadata: Annotated[Metadata, Field(frozen=True)]
65
+ services: Annotated[List[Service], Field(frozen=True)]
66
+
67
+ credentials: Annotated[Optional[str], Field(frozen=True)] = None
@@ -49,8 +49,6 @@ class Map(Loader[JobDetails]):
49
49
  """Loads the current Job Details from the environment variables"""
50
50
 
51
51
  def __init__(self, mapper: Mapping[str, str], keys: Keys, *args, **kwargs) -> None:
52
- super().__init__(*args, **kwargs)
53
-
54
52
  self._mapper = mapper
55
53
  self._keys = keys
56
54
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "oceanprotocol-job-details"
3
- version = "0.0.10"
3
+ version = "0.0.11"
4
4
  description = "A Python package to get details from OceanProtocol jobs"
5
5
  authors = [
6
6
  { name = "Christian López García", email = "christian.lopez@udl.cat" },