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 of a job.


Get logs of a job.

submit(workflow_uuid='', experiment='', image='', cmd='', prettified_cmd='', workflow_workspace='', job_name='', cvmfs_mounts='false', compute_backend=None, kerberos=False, kubernetes_uid=None, unpacked_img=False, voms_proxy=False)

Submit a job to RJC API.

  • job_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/.

Original command submitted by the user.


Path to the workspace of the workflow.


String with CVMFS volumes to mount in job pods.


Job compute backend.


Decides if kerberos should be provided for job container.


Decides if grid proxy should be provided for job container.


Overwrites the default user id in the job container.


Decides if unpacked iamges should be used.


Returns a dict with the job_id.


Proxy which returns current API client for a given component.

3.2. REANA Kubernetes API client

Kubernetes API Client.


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.


Render k8s CVMFS volume template.

Parameters:repository – CVMFS repository to be mounted.
Returns:k8s CVMFS volume spec as a dictionary.

Return REANA shared volume as k8s spec.

Depending on the configured storage backend REANA will use just a local volume in the host VM or a persistent volume claim which provides access to a network file system.

Returns:k8s shared volume spec as a dictionary.

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

Parameters:workflow_workspace – Absolute path to the job’s workflow workspace.
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 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.

  • 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.

on_message(body, message)

Implement this method to manipulate the data received.


3.5. REANA Serial workflow utilities

REANA Workflow Engine Serial implementation utils.

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

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.build_unique_component_name(component_type, id=None)

Use REANA component type and id build a human readable component name.

  • component_type – One of reana_commons.config.REANA_COMPONENT_TYPES.
  • id – Unique identifier, if not specified a new UUID4 is created.

String representing the component name, i.e. reana-run-job-123456.


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.


Check connection from workflow engine to job controller.

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.


Create CVMFS persistent volume claim.


Create CVMFS storage class.


Return command in a valid format.


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, block_size=None)

Retrieve disk usage information of a workspace.





3.7. REANA errors

REANA Commons errors.

exception reana_commons.errors.MissingAPIClientConfiguration

REANA Server URL is not set.

exception reana_commons.errors.REANASecretAlreadyExists

The referenced secret already exists.

exception reana_commons.errors.REANASecretDoesNotExist(missing_secrets_list=None)

The referenced REANA secret does not exist.

exception reana_commons.errors.REANAValidationError(message)

Validation error.