Skip to main content

OceanProtocol Job Details

PyPI Coverage

A Python package to get details from OceanProtocol jobs

Installation

pip install oceanprotocol-job-details
#or
uv add oceanprotocol-job-details

Usage

As a simple library, we only need to import load_job_details and run it. It will:

  1. Read from disk the needed parameters to populate the JobDetails from the given base_dir. Looking for the files corresponding to the passed DIDs in the filesystem according to the Ocean Protocol Structure.
  2. If given a InputParameters type that inherits from pydantic.BaseModel, it will create an instance from the environment variables.

Minimal Example

from oceanprotocol_job_details import load_job_details

job_details = load_job_details({"base_dir": "...", "transformation_did": "..."})

Custom Input Parameters

If our algorithm has custom input parameters and we want to load them into our algorithm, we can do it as follows:

from pydantic import BaseModel
from oceanprotocol_job_details import load_job_details


class Foo(BaseModel):
    bar: str


class InputParameters(BaseModel):
    # Allows for nested types
    foo: Foo


job_details = load_job_details({"base_dir": "...", "transformation_did": "..."}, InputParameters)

# Usage
parameters = await job_details.input_parameters()
parameters.foo
parameters.foo.bar

The values to fill the custom InputParameters will be parsed from the algoCustomData.json located next to the input data directories.

Iterating Input Files the clean way

from oceanprotocol_job_details import load_job_details


job_details = load_job_details(...)

for idx, file_path in job_details.inputs():
    ...

_, file_path = next(job_details.inputs())

OceanProtocol Structure

data        # Root /data directory
├── ddos    # Contains the loaded dataset's DDO (metadata)
│   ├── 17feb...e42 # DDO file
│   └── ... # One DDO per loaded dataset
├── inputs  # Datasets dir
│   ├── 17feb...e42 # Dir holding the data of its name DID, contains files named 0..X
│   │   └── 0 # Data file
│   └── algoCustomData.json # Custom algorithm input data
├── logs    # Algorithm output logs dir
└── outputs # Algorithm output files dir

Note: Even though it's possible that the algorithm is passed multiple datasets, right now the implementation only allows to use one dataset per algorithm execution, so normally the executing job will only have one ddo, one dir inside inputs, and one data file named 0.

Metadata

Release files for oceanprotocol-job-details 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oceanprotocol-job-details 0.5.2
File Size Uploaded
oceanprotocol_job_details-0.5.2.tar.gz 9.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for oceanprotocol-job-details 0.5.2
File Interpreter ABI Platform
oceanprotocol_job_details-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 25.7 kB

Release files / oceanprotocol_job_details-0.5.2.tar.gz

Download URL oceanprotocol_job_details-0.5.2.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e2d86359fea955e3a8f91bf0011dbae036f0b26df1429698431edf727c11ebc5
BLAKE2b-256 checksum
How to use checksums
fcad949ce024b1211745dfe1e5ffb8daf486ba13f66ddb487f7ac7b481c70d7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / oceanprotocol_job_details-0.5.2-py3-none-any.whl

Download URL oceanprotocol_job_details-0.5.2-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c20a7e74c15e7009ce5eb35a1a0d5ff38a6493d6cb83df04b81cfb81f1d88933
BLAKE2b-256 checksum
How to use checksums
a64d24773966feac410e7f83f835166797d25af93cfa56678116f686dac60078
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.5.2 This release

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.3.22

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.12

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page