Ocean Compute Tech Details

Technical details about OceanCompute functions

Using this class, we are able to manipulate a compute job, run it on Ocean environment and retrieve the results after the execution is finished.

Start Compute Job

  • start(self, consumer_wallet, dataset: ComputeInput, compute_environment: str, algorithm: Optional[ComputeInput] = None, algorithm_meta: Optional[AlgorithmMetadata] = None, algorithm_algocustomdata: Optional[dict] = None, additional_datasets: List[ComputeInput] = []) -> str

Starts a compute job.

It can be called within Ocean Compute class.

Parameters

  • consumer_wallet - the eth Account of consumer who pays & starts for compute job.

  • dataset - ComputeInput object, each of them includes mandatory the DDO and service.

  • compute_environment - string that represents the ID from the chosen C2D environment.

  • additional_datasets - list of ComputeInput objects for additional datasets in case of starting a compute job for multiple datasets.

Optional parameters

  • algorithm - ComputeInput object, each of them includes mandatory the DDO and service for algorithm.

  • algorithm_meta - either provide just the algorithm metadata as AlgorithmMetadata.

  • algorithm_algocustomedata - additional user data for the algorithm as dictionary.

Returns

str

Returns a string type job ID.

Defined in

ocean/ocean_compute.py

Source code

Compute Job Status

  • status(self, ddo: DDO, service: Service, job_id: str, wallet) -> Dict[str, Any]

Gets status of the compute job.

It can be called within Ocean Compute class.

Parameters

  • ddo - DDO offering the compute service of this job

  • service - Service object of compute

  • job_id - ID of the compute job

  • wallet - eth Account which initiated the compute job

Returns

Dict[str, Any]

A dictionary which contains the status for an existing compute job, keys are (ok, status, statusText).

Defined in

ocean/ocean_compute.py

Source code

Compute Job Result

  • result(self, ddo: DDO, service: Service, job_id: str, index: int, wallet ) -> Dict[str, Any]

Gets compute job result.

It can be called within Ocean Compute class.

Parameters

  • ddo - DDO offering the compute service of this job

  • service - Service object of compute

  • job_id - ID of the compute job

  • index - compute result index

  • wallet - eth Account which initiated the compute job

Returns

Dict[str, Any]

A dictionary wich contains the results/logs urls for an existing compute job, keys are (did, urls, logs).

Defined in

ocean/ocean_compute.py

Source code

Compute Job Result Logs

  • compute_job_result_logs(self, ddo: DDO, service: Service, job_id: str, wallet, log_type="output") -> Dict[str, Any]

Gets job output if exists.

It can be called within Ocean Compute class.

Parameters

  • ddo - DDO offering the compute service of this job

  • service - Service object of compute

  • job_id - ID of the compute job

  • wallet - eth Account which initiated the compute job

  • log_type - string which selects what kind of logs to display. Default "output"

Returns

Dict[str, Any]

A dictionary which includes the results/logs urls for an existing compute job, keys are (did, urls, logs).

Defined in

ocean/ocean_compute.py

Source code

Stop Compute Job

  • stop(self, ddo: DDO, service: Service, job_id: str, wallet) -> Dict[str, Any]

Attempts to stop the running compute job.

It can be called within Ocean Compute class.

Parameters

  • ddo - DDO offering the compute service of this job

  • service - Service object of compute

  • job_id - ID of the compute job

  • wallet - eth Account which initiated the compute job

Returns

Dict[str, Any]

A dictionary which contains the status for the stopped compute job, keys are (ok, status, statusText).

Defined in

ocean/ocean_compute.py

Source code

Get Priced C2D Environments

  • get_c2d_environments(self, service_endpoint: str, chain_id: int)

Get list of compute environments.

It can be called within Ocean Compute class.

Parameters

  • service_endpoint - string Provider URL that is stored in compute service.

  • chain_id - using Provider multichain, chain_id is required to specify the network for your environment. It has int type.

Returns

list

A list of objects containing information about each compute environment. For each compute environment, these are the following keys: (id, feeToken, priceMin, consumerAddress, lastSeen, namespace, status).

Defined in

ocean/ocean_compute.py

Source code

Get Free C2D Environments

  • get_free_c2d_environment(self, service_endpoint: str, chain_id)

Get list of free compute environments.

Important thing is that not all Providers contain free environments (priceMin = 0).

It can be called within Ocean Compute class.

Parameters

  • service_endpoint - string Provider URL that is stored in compute service.

  • chain_id - using Provider multichain, chain_id is required to specify the network for your environment. It has int type.

Returns

list

A list of objects containing information about each compute environment. For each compute environment, these are the following keys: (id, feeToken, priceMin, consumerAddress, lastSeen, namespace, status).

Defined in

ocean/ocean_compute.py

Source code

Last updated

Was this helpful?