oceanprotocol-job-details 0.2.1__tar.gz → 0.2.3__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.1 → oceanprotocol_job_details-0.2.3}/PKG-INFO +1 -1
  2. oceanprotocol_job_details-0.2.3/oceanprotocol_job_details/__init__.py +4 -0
  3. {oceanprotocol_job_details-0.2.1 → oceanprotocol_job_details-0.2.3}/oceanprotocol_job_details/di.py +4 -1
  4. {oceanprotocol_job_details-0.2.1 → oceanprotocol_job_details-0.2.3}/oceanprotocol_job_details/ocean.py +4 -0
  5. oceanprotocol_job_details-0.2.3/oceanprotocol_job_details/paths.py +38 -0
  6. {oceanprotocol_job_details-0.2.1 → oceanprotocol_job_details-0.2.3}/pyproject.toml +1 -1
  7. oceanprotocol_job_details-0.2.1/oceanprotocol_job_details/__init__.py +0 -4
  8. oceanprotocol_job_details-0.2.1/oceanprotocol_job_details/paths.py +0 -28
  9. {oceanprotocol_job_details-0.2.1 → oceanprotocol_job_details-0.2.3}/.gitignore +0 -0
  10. {oceanprotocol_job_details-0.2.1 → oceanprotocol_job_details-0.2.3}/LICENSE +0 -0
  11. {oceanprotocol_job_details-0.2.1 → oceanprotocol_job_details-0.2.3}/README.md +0 -0
  12. {oceanprotocol_job_details-0.2.1 → oceanprotocol_job_details-0.2.3}/oceanprotocol_job_details/loaders/__init__.py +0 -0
  13. {oceanprotocol_job_details-0.2.1 → oceanprotocol_job_details-0.2.3}/oceanprotocol_job_details/loaders/impl/__init__.py +0 -0
  14. {oceanprotocol_job_details-0.2.1 → oceanprotocol_job_details-0.2.3}/oceanprotocol_job_details/loaders/impl/ddo.py +0 -0
  15. {oceanprotocol_job_details-0.2.1 → oceanprotocol_job_details-0.2.3}/oceanprotocol_job_details/loaders/impl/files.py +0 -0
  16. {oceanprotocol_job_details-0.2.1 → oceanprotocol_job_details-0.2.3}/oceanprotocol_job_details/loaders/impl/job_details.py +0 -0
  17. {oceanprotocol_job_details-0.2.1 → oceanprotocol_job_details-0.2.3}/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.2.1
3
+ Version: 0.2.3
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
@@ -0,0 +1,4 @@
1
+ from .ocean import JobDetails
2
+
3
+
4
+ __all__ = [JobDetails]
@@ -10,7 +10,10 @@ class Container(containers.DeclarativeContainer):
10
10
 
11
11
  config = providers.Configuration()
12
12
 
13
- paths = providers.Singleton(Paths)
13
+ paths = providers.Singleton(
14
+ Paths,
15
+ base_dir=config.base_dirs,
16
+ )
14
17
 
15
18
  file_loader = providers.Factory(
16
19
  FilesLoader,
@@ -267,6 +267,8 @@ class JobDetails(Generic[T]):
267
267
  def load(
268
268
  cls,
269
269
  _type: Type[T] | None = None,
270
+ *,
271
+ base_dir: str | None = None,
270
272
  dids: str | None = None,
271
273
  transformation_did: str | None = None,
272
274
  secret: str | None = None,
@@ -278,6 +280,7 @@ class JobDetails(Generic[T]):
278
280
  1. That the ocean protocol contains the needed data based on the passed environment variables.
279
281
 
280
282
  Those needed environment variables are:
283
+ - BASE_DIR: Base directory to read the data from, parent of the ddos, inputs, outputs and logs directories.
281
284
  - DIDS: The DIDs of the inputs
282
285
  - TRANSFORMATION_DID: The DID of the transformation algorithm
283
286
  - SECRET (optional): A really secret secret
@@ -290,6 +293,7 @@ class JobDetails(Generic[T]):
290
293
  container = Container()
291
294
  container.config.from_dict(
292
295
  {
296
+ "base_dir": base_dir or os.environ.get("BASE_DIR", None),
293
297
  "dids": dids or os.environ.get("DIDS"),
294
298
  "transformation_did": transformation_did
295
299
  or os.environ.get("TRANSFORMATION_DID"),
@@ -0,0 +1,38 @@
1
+ from dataclasses import InitVar, dataclass, field
2
+ from pathlib import Path
3
+
4
+
5
+ @dataclass
6
+ class Paths:
7
+ """Configuration class for the Ocean Protocol Job Details"""
8
+
9
+ base_dir: InitVar[Path | None]
10
+
11
+ _base: Path = field(init=False)
12
+
13
+ def __post_init__(self, base_dir: Path | None) -> None:
14
+ self._base = base_dir or Path("/data")
15
+
16
+ @property
17
+ def data(self) -> Path:
18
+ return self._base
19
+
20
+ @property
21
+ def inputs(self) -> Path:
22
+ return self.data / "inputs"
23
+
24
+ @property
25
+ def ddos(self) -> Path:
26
+ return self.data / "ddos"
27
+
28
+ @property
29
+ def outputs(self) -> Path:
30
+ return self.data / "outputs"
31
+
32
+ @property
33
+ def logs(self) -> Path:
34
+ return self.data / "logs"
35
+
36
+ @property
37
+ def algorithm_custom_parameters(self) -> Path:
38
+ return self.inputs / "algoCustomData.json"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "oceanprotocol-job-details"
3
- version = "0.2.1"
3
+ version = "0.2.3"
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,4 +0,0 @@
1
- from ocean import JobDetails
2
-
3
-
4
- __all__ = [JobDetails]
@@ -1,28 +0,0 @@
1
- from dataclasses import dataclass
2
- from logging import getLogger
3
- from pathlib import Path
4
-
5
- logger = getLogger(__name__)
6
-
7
-
8
- @dataclass
9
- class Paths:
10
- """Configuration class for the Ocean Protocol Job Details"""
11
-
12
- data: Path = Path("/data")
13
- """The path to the data directory"""
14
-
15
- inputs: Path = data / "inputs"
16
- """The path to the inputs directory"""
17
-
18
- ddos: Path = data / "ddos"
19
- """The path to the DDOs directory"""
20
-
21
- outputs: Path = data / "outputs"
22
- """The path to the outputs directory"""
23
-
24
- logs: Path = data / "logs"
25
- """The path to the logs directory"""
26
-
27
- algorithm_custom_parameters: Path = inputs / "algoCustomData.json"
28
- """The path to the algorithm's custom parameters file"""