oceanprotocol-job-details 0.2.0__tar.gz → 0.2.2__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 (17) hide show
  1. {oceanprotocol_job_details-0.2.0 → oceanprotocol_job_details-0.2.2}/PKG-INFO +12 -20
  2. oceanprotocol_job_details-0.2.2/README.md +52 -0
  3. oceanprotocol_job_details-0.2.2/oceanprotocol_job_details/__init__.py +4 -0
  4. {oceanprotocol_job_details-0.2.0 → oceanprotocol_job_details-0.2.2}/oceanprotocol_job_details/ocean.py +11 -4
  5. {oceanprotocol_job_details-0.2.0 → oceanprotocol_job_details-0.2.2}/pyproject.toml +1 -1
  6. oceanprotocol_job_details-0.2.0/README.md +0 -60
  7. oceanprotocol_job_details-0.2.0/oceanprotocol_job_details/loaders/impl/__init__.py +0 -0
  8. {oceanprotocol_job_details-0.2.0 → oceanprotocol_job_details-0.2.2}/.gitignore +0 -0
  9. {oceanprotocol_job_details-0.2.0 → oceanprotocol_job_details-0.2.2}/LICENSE +0 -0
  10. {oceanprotocol_job_details-0.2.0 → oceanprotocol_job_details-0.2.2}/oceanprotocol_job_details/di.py +0 -0
  11. {oceanprotocol_job_details-0.2.0/oceanprotocol_job_details → oceanprotocol_job_details-0.2.2/oceanprotocol_job_details/loaders}/__init__.py +0 -0
  12. {oceanprotocol_job_details-0.2.0/oceanprotocol_job_details/loaders → oceanprotocol_job_details-0.2.2/oceanprotocol_job_details/loaders/impl}/__init__.py +0 -0
  13. {oceanprotocol_job_details-0.2.0 → oceanprotocol_job_details-0.2.2}/oceanprotocol_job_details/loaders/impl/ddo.py +0 -0
  14. {oceanprotocol_job_details-0.2.0 → oceanprotocol_job_details-0.2.2}/oceanprotocol_job_details/loaders/impl/files.py +0 -0
  15. {oceanprotocol_job_details-0.2.0 → oceanprotocol_job_details-0.2.2}/oceanprotocol_job_details/loaders/impl/job_details.py +0 -0
  16. {oceanprotocol_job_details-0.2.0 → oceanprotocol_job_details-0.2.2}/oceanprotocol_job_details/loaders/loader.py +0 -0
  17. {oceanprotocol_job_details-0.2.0 → oceanprotocol_job_details-0.2.2}/oceanprotocol_job_details/paths.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oceanprotocol-job-details
3
- Version: 0.2.0
3
+ Version: 0.2.2
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
@@ -37,10 +37,10 @@ pip install oceanprotocol-job-details
37
37
  As a simple library, we only need to import the main object and use it once:
38
38
 
39
39
  ```Python
40
- from oceanprotocol_job_details.job_details import OceanProtocolJobDetails
40
+ from oceanprotocol_job_details import JobDetails
41
41
 
42
42
  # Having no algorithm input parameters
43
- job_details = OceanProtocolJobDetails().load() # type: ignore
43
+ job_details = JobDetails.load()
44
44
 
45
45
  ```
46
46
 
@@ -49,15 +49,16 @@ If our algorithm has custom input parameters and we want to load them into our a
49
49
  ```Python
50
50
 
51
51
  from dataclasses import dataclass
52
- from oceanprotocol_job_details.job_details import OceanProtocolJobDetails
53
- from oceanprotocol_job_details.ocean import JobDetails
52
+ from oceanprotocol_job_details import JobDetails
53
+
54
54
 
55
55
  @dataclass
56
- class Input:
56
+ class InputParameters:
57
57
  name: str
58
58
  age: int
59
59
 
60
- job_details: JobDetails[Input] = OceanProtocolJobDetails(Input).load()
60
+
61
+ job_details: JobDetails[InputParameters] = JobDetails.load(InputParameters)
61
62
 
62
63
  # Usage (is type hinted)
63
64
  job_details.input_parameters.name
@@ -65,20 +66,11 @@ job_details.input_parameters.age
65
66
 
66
67
  ```
67
68
 
68
- Assumes the following directory structure:
69
- ```
70
- <ROOT_FOLDER>
71
- └───data
72
- ├───ddos
73
- ├───transformation
74
- ├───inputs
75
- └───logs
76
- ```
69
+ Assumes the directory structure of OceanProtocol algorithms.
77
70
 
78
71
  ### Core functionalities
79
72
 
80
- Given the Ocean Protocol job details structure as in [https://github.com/GX4FM-Base-X/pontus-x-ontology](Pontus-X Ontology), parses the passed algorithm parameters into an object to use in your algorithms.
73
+ Given the Ocean Protocol job details structure, parses the passed algorithm parameters into an object to use in your algorithms.
81
74
 
82
- 1. Parsing JSON
83
- 1. Validation
84
- 1. Metadata and service extraction
75
+ 1. Input parameter JSON parsing and validation
76
+ 1. Metadata and service extraction from the directory structure.
@@ -0,0 +1,52 @@
1
+ A Python package to get details from OceanProtocol jobs
2
+
3
+ ---
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ pip install oceanprotocol-job-details
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ As a simple library, we only need to import the main object and use it once:
14
+
15
+ ```Python
16
+ from oceanprotocol_job_details import JobDetails
17
+
18
+ # Having no algorithm input parameters
19
+ job_details = JobDetails.load()
20
+
21
+ ```
22
+
23
+ If our algorithm has custom input parameters and we want to load them into our algorithm, we can do it as follows:
24
+
25
+ ```Python
26
+
27
+ from dataclasses import dataclass
28
+ from oceanprotocol_job_details import JobDetails
29
+
30
+
31
+ @dataclass
32
+ class InputParameters:
33
+ name: str
34
+ age: int
35
+
36
+
37
+ job_details: JobDetails[InputParameters] = JobDetails.load(InputParameters)
38
+
39
+ # Usage (is type hinted)
40
+ job_details.input_parameters.name
41
+ job_details.input_parameters.age
42
+
43
+ ```
44
+
45
+ Assumes the directory structure of OceanProtocol algorithms.
46
+
47
+ ### Core functionalities
48
+
49
+ Given the Ocean Protocol job details structure, parses the passed algorithm parameters into an object to use in your algorithms.
50
+
51
+ 1. Input parameter JSON parsing and validation
52
+ 1. Metadata and service extraction from the directory structure.
@@ -0,0 +1,4 @@
1
+ from .ocean import JobDetails
2
+
3
+
4
+ __all__ = [JobDetails]
@@ -264,7 +264,13 @@ class JobDetails(Generic[T]):
264
264
  ) from e
265
265
 
266
266
  @classmethod
267
- def load(cls, _type: Type[T] | None = None) -> JobDetails[T]:
267
+ def load(
268
+ cls,
269
+ _type: Type[T] | None = None,
270
+ dids: str | None = None,
271
+ transformation_did: str | None = None,
272
+ secret: str | None = None,
273
+ ) -> JobDetails[T]:
268
274
  """Load a JobDetails instance that holds the runtime details.
269
275
 
270
276
  Loading it will check the following:
@@ -284,9 +290,10 @@ class JobDetails(Generic[T]):
284
290
  container = Container()
285
291
  container.config.from_dict(
286
292
  {
287
- "dids": os.environ.get("DIDS"),
288
- "transformation_did": os.environ.get("TRANSFORMATION_DID"),
289
- "secret": os.environ.get("SECRET"),
293
+ "dids": dids or os.environ.get("DIDS"),
294
+ "transformation_did": transformation_did
295
+ or os.environ.get("TRANSFORMATION_DID"),
296
+ "secret": secret or os.environ.get("SECRET"),
290
297
  }
291
298
  )
292
299
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "oceanprotocol-job-details"
3
- version = "0.2.0"
3
+ version = "0.2.2"
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" },
@@ -1,60 +0,0 @@
1
- A Python package to get details from OceanProtocol jobs
2
-
3
- ---
4
-
5
- ## Installation
6
-
7
- ```
8
- pip install oceanprotocol-job-details
9
- ```
10
-
11
- ## Usage
12
-
13
- As a simple library, we only need to import the main object and use it once:
14
-
15
- ```Python
16
- from oceanprotocol_job_details.job_details import OceanProtocolJobDetails
17
-
18
- # Having no algorithm input parameters
19
- job_details = OceanProtocolJobDetails().load() # type: ignore
20
-
21
- ```
22
-
23
- If our algorithm has custom input parameters and we want to load them into our algorithm, we can do it as follows:
24
-
25
- ```Python
26
-
27
- from dataclasses import dataclass
28
- from oceanprotocol_job_details.job_details import OceanProtocolJobDetails
29
- from oceanprotocol_job_details.ocean import JobDetails
30
-
31
- @dataclass
32
- class Input:
33
- name: str
34
- age: int
35
-
36
- job_details: JobDetails[Input] = OceanProtocolJobDetails(Input).load()
37
-
38
- # Usage (is type hinted)
39
- job_details.input_parameters.name
40
- job_details.input_parameters.age
41
-
42
- ```
43
-
44
- Assumes the following directory structure:
45
- ```
46
- <ROOT_FOLDER>
47
- └───data
48
- ├───ddos
49
- ├───transformation
50
- ├───inputs
51
- └───logs
52
- ```
53
-
54
- ### Core functionalities
55
-
56
- Given the Ocean Protocol job details structure as in [https://github.com/GX4FM-Base-X/pontus-x-ontology](Pontus-X Ontology), parses the passed algorithm parameters into an object to use in your algorithms.
57
-
58
- 1. Parsing JSON
59
- 1. Validation
60
- 1. Metadata and service extraction