3. API

3.1. REANA API client

REANA REST API base client.

class reana_commons.api_client.BaseAPIClient(service, http_client=None)

REANA API client code.

class reana_commons.api_client.JobControllerAPIClient(service, http_client=None)

REANA-Job-Controller http client class.

check_if_cached(job_spec, step, workflow_workspace)

Check if job result is in cache.

check_status(job_id)

Check status of a job.

get_logs(job_id)

Get logs of a job.

submit(workflow_uuid='', experiment='', image='', cmd='', prettified_cmd='', workflow_workspace='', job_name='', cvmfs_mounts='false')

Submit a job to RJC API.

Parameters:
  • name – Name of the job.
  • experiment – Experiment the job belongs to.
  • image – Identifier of the Docker image which will run the job.
  • cmd – String which represents the command to execute. It can be modified by the workflow engine i.e. prepending cd /some/dir/.
Prettified_cmd:

Original command submitted by the user.

Workflow_workspace:
 

Path to the workspace of the workflow.

Cvmfs_mounts:

String with CVMFS volumes to mount in job pods.

Returns:

Returns a dict with the job_id.

reana_commons.api_client.get_current_api_client(component)

Proxy which returns current API client for a given component.

3.2. REANA Kubernetes API client

Kubernetes API Client.

reana_commons.k8s.api_client.create_api_client(api='BatchV1')

Create Kubernetes API client using config.

Parameters:api – String which represents which Kubernetes API to spawn. By default BatchV1.
Returns:Kubernetes python client object for a specific API i.e. BatchV1.

REANA Kubernetes volumes.

reana_commons.k8s.volumes.get_k8s_cephfs_volume()

Return k8s CephFS volume template.

Returns:k8s CephFS volume spec as a dictionary.
reana_commons.k8s.volumes.get_k8s_cvmfs_volume(repository)

Render k8s CVMFS volume template.

Parameters:repository – CVMFS repository to be mounted.
Returns:k8s CVMFS volume spec as a dictionary.
reana_commons.k8s.volumes.get_k8s_hostpath_volume(root_path)

Render k8s HostPath volume template.

Parameters:root_path – Root path in the host machine to be mounted.
Returns:k8s HostPath spec as a dictionary.
reana_commons.k8s.volumes.get_shared_volume(workflow_workspace, shared_volume_root)

Get shared CephFS/hostPath volume to a given job spec.

Parameters:
  • workflow_workspace – Absolute path to the job’s workflow workspace.
  • shared_volume_root – Root path in the underlying storage backend.
Returns:

Tuple consisting of the Kubernetes volumeMount and the volume.

3.3. REANA AMQP Publisher

REANA-Commons module to manage AMQP connections on REANA.

class reana_commons.publisher.BasePublisher(queue, routing_key, connection=None, exchange=None, durable=False)

Base publisher to MQ.

close()

Close connection.

class reana_commons.publisher.WorkflowStatusPublisher(**kwargs)

Progress publisher to MQ.

publish_workflow_status(workflow_uuid, status, logs='', message=None)

Publish workflow status using the configured.

Parameters:
  • workflow_uudid – String which represents the workflow UUID.
  • status – Integer which represents the status of the workflow, this is defined in the reana-db Workflow models.
  • logs – String which represents the logs which the workflow has produced as output.
  • message – Dictionary which includes additional information can be attached such as the overall progress of the workflow.
class reana_commons.publisher.WorkflowSubmissionPublisher(**kwargs)

Workflow submission publisher.

publish_workflow_submission(user_id, workflow_id_or_name, parameters)

Publish workflow submission parameters.

3.4. REANA AMQP Consumer

REANA-Commons module to manage AMQP consuming on REANA.

class reana_commons.consumer.BaseConsumer(queue=None, connection=None, message_default_format=None)

Base RabbitMQ consumer.

get_consumers(Consumer, channel)

Map consumers to specific queues.

Parameters:
on_message(body, message)

Implement this method to manipulate the data received.

Parameters:

3.5. REANA Serial workflow utilities

REANA Workflow Engine Serial implementation utils.

reana_commons.serial.serial_load(workflow_file, specification, parameters=None, original=None)

Validate and return a expanded REANA Serial workflow specification.

Parameters:workflow_file – A specification file compliant with REANA Serial workflow specification.
Returns:A dictionary which represents the valid Serial workflow with all parameters expanded.

3.6. REANA utilities

REANA-Commons utils.

reana_commons.utils.build_caching_info_message(job_spec, job_id, workflow_workspace, workflow_json, result_path)

Build the caching info message with correct formatting.

reana_commons.utils.build_progress_message(total=None, running=None, finished=None, failed=None, cached=None)

Build the progress message with correct formatting.

reana_commons.utils.calculate_file_access_time(workflow_workspace)

Calculate access times of files in workspace.

reana_commons.utils.calculate_hash_of_dir(directory, file_list=None)

Calculate hash of directory.

reana_commons.utils.calculate_job_input_hash(job_spec, workflow_json)

Calculate md5 hash of job specification and workflow json.

reana_commons.utils.click_table_printer(headers, _filter, data)

Generate space separated output for click commands.

reana_commons.utils.copy_openapi_specs(output_path, component)

Copy generated and validated openapi specs to reana-commons module.

reana_commons.utils.create_cvmfs_persistent_volume_claim(cvmfs_volume)

Create CVMFS persistent volume claim.

reana_commons.utils.create_cvmfs_storage_class(cvmfs_volume)

Create CVMFS storage class.

reana_commons.utils.get_workflow_status_change_verb(status)

Give the correct verb conjugation depending on status tense.

Parameters:status – String which represents the status the workflow changed to.
reana_commons.utils.get_workspace_disk_usage(workspace, summarize=False)

Retrieve disk usage information of a workspace.

reana_commons.utils.render_cvmfs_pvc(cvmfs_volume)

Render REANA_CVMFS_PVC_TEMPLATE.

reana_commons.utils.render_cvmfs_sc(cvmfs_volume)

Render REANA_CVMFS_SC_TEMPLATE.

3.7. REANA errors

REANA Commons errors.

exception reana_commons.errors.MissingAPIClientConfiguration

REANA Server URL is not set.