squid_py.brizo.brizo module

Brizo module.

class squid_py.brizo.brizo.Brizo

Bases: object

Brizo is the name chosen for the asset service provider.

The main functions available are: - consume_service - run_compute_service (not implemented yet)

static compute_job_result(agreement_id, job_id, service_endpoint, account_address, signature)
Parameters
  • agreement_id – hex str Service Agreement Id

  • job_id – str id of compute job that was returned from start_compute_job

  • service_endpoint – str url of the provider service endpoint for compute service

  • account_address – hex str the ethereum address of the consumer’s account

  • signature – hex str signed message to allow the provider to authorize the consumer

Returns

dict of job_id to result urls. When job_id is not provided, this will return result for each job_id that exist for the agreement_id

static compute_job_status(agreement_id, job_id, service_endpoint, account_address, signature)
Parameters
  • agreement_id – hex str Service Agreement Id

  • job_id – str id of compute job that was returned from start_compute_job

  • service_endpoint – str url of the provider service endpoint for compute service

  • account_address – hex str the ethereum address of the consumer’s account

  • signature – hex str signed message to allow the provider to authorize the consumer

Returns

dict of job_id to status info. When job_id is not provided, this will return status for each job_id that exist for the agreement_id

static consume_service(agreement_id, service_endpoint, account, files, destination_folder, index=None)

Call the brizo endpoint to get access to the different files that form the asset.

Parameters
  • agreement_id – Service Agreement Id, hex str

  • service_endpoint – Url to consume, str

  • account – Account instance of the consumer signing this agreement, hex-str

  • files – List containing the files to be consumed, list

  • index – Index of the document that is going to be downloaded, int

  • destination_folder – Path, str

Returns

True if was downloaded, bool

static delete_compute_job(agreement_id, job_id, service_endpoint, account_address, signature)
Parameters
  • agreement_id – hex str Service Agreement Id

  • job_id – str id of compute job that was returned from start_compute_job

  • service_endpoint – str url of the provider service endpoint for compute service

  • account_address – hex str the ethereum address of the consumer’s account

  • signature – hex str signed message to allow the provider to authorize the consumer

Returns

bool whether the job was deleted successfully

static encrypt_files_dict(files_dict, encrypt_endpoint, asset_id, account_address, signed_did)
static get_brizo_url(config)

Return the Brizo component url.

Parameters

config – Config

Returns

Url, str

static get_compute_endpoint(config)

Return the url to execute the asset.

Parameters

config – Config

Returns

Url, str

static get_consume_endpoint(config)

Return the url to consume the asset.

Parameters

config – Config

Returns

Url, str

static get_encrypt_endpoint(config)

Return the url to encrypt the asset.

Parameters

config – Config

Returns

Url, str

static restart_compute_job(agreement_id, job_id, service_endpoint, account_address, signature)
Parameters
  • agreement_id – hex str Service Agreement Id

  • job_id – str id of compute job that was returned from start_compute_job

  • service_endpoint – str url of the provider service endpoint for compute service

  • account_address – hex str the ethereum address of the consumer’s account

  • signature – hex str signed message to allow the provider to authorize the consumer

Returns

bool whether the job was restarted successfully

static set_http_client(http_client)

Set the http client to something other than the default requests

static start_compute_job(agreement_id, service_endpoint, account_address, signature, algorithm_did=None, algorithm_meta=None, output=None, job_id=None)
Parameters
  • agreement_id – Service Agreement Id, hex str

  • service_endpoint

  • account_address – hex str the ethereum address of the consumer executing the compute job

  • signature – hex str signed message to allow the provider to authorize the consumer

  • algorithm_did – str – the asset did (of algorithm type) which consist of did:op: and the assetId hex str (without 0x prefix)

  • algorithm_meta – see OceanCompute.execute

  • output – see OceanCompute.execute

  • job_id – str id of compute job that was started and stopped (optional, use it here to start a job after it was stopped)

Returns

job_info dict with jobId, status, and other values

static stop_compute_job(agreement_id, job_id, service_endpoint, account_address, signature)
Parameters
  • agreement_id – hex str Service Agreement Id

  • job_id – str id of compute job that was returned from start_compute_job

  • service_endpoint – str url of the provider service endpoint for compute service

  • account_address – hex str the ethereum address of the consumer’s account

  • signature – hex str signed message to allow the provider to authorize the consumer

Returns

bool whether the job was stopped successfully

static write_file(response, destination_folder, file_name)

Write the response content in a file in the destination folder. :param response: Response :param destination_folder: Destination folder, string :param file_name: File name, string :return: bool