cloudos_cli.utils.details

Functions

create_job_details(j_details_h, job_id, ...)

Creates formatted job details output from job data in multiple formats.

create_job_list_table(jobs, cloudos_url[, ...])

Creates a formatted job list table with responsive design and pagination.

create_project_list_table(projects[, ...])

Display projects in a rich formatted table with pagination.

create_queue_list_table(queues[, cloudos_url])

Display job queues in a rich formatted table.

create_workflow_list_table(workflows[, ...])

Display workflows in a rich formatted table with pagination.

get_path(param, param_kind_map, ...[, mode])

Constructs a storage path based on the parameter kind and execution platform.

cloudos_cli.utils.details.create_job_details(j_details_h, job_id, output_format, output_basename, parameters, cloudos_url='https://cloudos.lifebit.ai')[source]

Creates formatted job details output from job data in multiple formats.

This function processes job details from the Lifebit Platform API response and outputs the information in a user-specified format (stdout table, JSON, or CSV). It also optionally creates configuration files with job parameters.

Parameters:
  • j_details_h (dict) –

    A dictionary containing job details from the Lifebit Platform API. Expected keys include:
    • ’jobType’: The type of job executor (e.g., ‘nextflowAWS’, ‘dockerAWS’).

    • ’parameters’: List of parameter dictionaries for the job.

    • ’status’: Current status of the job.

    • ’name’: Name of the job.

    • ’project’: Dictionary containing project information with ‘name’ key.

    • ’user’: Dictionary containing user information with ‘name’ and ‘surname’ keys.

    • ’workflow’: Dictionary containing workflow information.

    • ’startTime’: ISO format timestamp of job start.

    • ’endTime’: ISO format timestamp of job completion.

    • ’computeCostSpent’: Cost in cents (optional).

    • ’masterInstance’: Dictionary containing instance information.

    • ’storageSizeInGb’: Storage size allocated to the job.

    • ’resourceRequirements’: Dictionary with ‘cpu’ and ‘ram’ specifications.

    • Additional platform-specific keys based on jobType.

  • job_id (str) – Unique identifier for the job.

  • output_format (str) –

    Format for output display. Expected values:
    • ’stdout’: Display as a formatted table in the console.

    • ’json’: Save as a JSON file.

    • ’csv’: Save as a CSV file.

  • output_basename (str) – Base name for output files (without extension). Used when output_format is ‘json’ or ‘csv’.

  • parameters (bool) – Whether to create a separate configuration file containing job parameters. If True and parameters exist, creates a ‘.config’ file with Nextflow-style parameter formatting.

  • cloudos_url (str, optional) – The base URL of the Lifebit Platform instance. Defaults to “https://cloudos.lifebit.ai”.

Returns:

This function has side effects only: - Prints formatted output to console (for ‘stdout’ format). - Creates output files (for ‘json’ and ‘csv’ formats). - Optionally creates parameter configuration files. - Prints status messages about file creation.

Return type:

None

Notes

The function handles different job types and execution platforms: - AWS Batch (nextflowAWS, dockerAWS, cromwellAWS) - Azure Batch (nextflowAzure) - Google Cloud Platform (nextflowGcp) - HPC clusters (nextflowHpc) - Kubernetes (nextflowKubernetes)

Parameter processing depends on the parameter kind: - ‘textValue’: Simple text parameters - ‘arrayFileColumn’: Column-based array parameters - ‘globPattern’: File pattern matching parameters - ‘dataItem’: Data file/object parameters

Time calculations assume UTC timezone and convert ISO format timestamps to human-readable duration strings.

cloudos_cli.utils.details.create_job_list_table(jobs, cloudos_url, pagination_metadata=None, selected_columns=None, fetch_page_callback=None)[source]

Creates a formatted job list table with responsive design and pagination.

cloudos_cli.utils.details.create_project_list_table(projects, cloudos_url='https://cloudos.lifebit.ai', page_size=10)[source]

Display projects in a rich formatted table with pagination.

Parameters:
  • projects (list) – A list of dicts, each corresponding to a project.

  • cloudos_url (str) – The Lifebit Platform URL for creating hyperlinks.

  • page_size (int) – Number of projects to display per page. Default is 10.

cloudos_cli.utils.details.create_queue_list_table(queues, cloudos_url='https://cloudos.lifebit.ai')[source]

Display job queues in a rich formatted table.

Parameters:
  • queues (list) – A list of dicts, each corresponding to a job queue.

  • cloudos_url (str) – The Lifebit Platform URL for context (currently not used for hyperlinks).

Returns:

Prints the formatted table to console.

Return type:

None

cloudos_cli.utils.details.create_workflow_list_table(workflows, cloudos_url='https://cloudos.lifebit.ai', page_size=10)[source]

Display workflows in a rich formatted table with pagination.

Parameters:
  • workflows (list) – A list of dicts, each corresponding to a workflow.

  • cloudos_url (str) – The Lifebit Platform URL for creating hyperlinks.

  • page_size (int) – Number of workflows to display per page. Default is 10.

cloudos_cli.utils.details.get_path(param, param_kind_map, execution_platform, storage_provider, mode='parameters')[source]

Constructs a storage path based on the parameter kind and execution platform.

Parameters:
  • param (dict) –

    A dictionary containing parameter details. Expected keys include:
    • ’parameterKind’: Specifies the kind of parameter (e.g., ‘dataItem’, ‘globPattern’).

    • For ‘dataItem’: Contains nested keys such as ‘item’, which includes:
      • ’s3BucketName’, ‘s3ObjectKey’, ‘s3Prefix’ (for AWS Batch).

      • ’blobStorageAccountName’, ‘blobContainerName’, ‘blobName’ (for other platforms).

    • For ‘globPattern’: Contains nested keys such as ‘folder’, which includes:
      • ’s3BucketName’, ‘s3Prefix’ (for AWS Batch).

      • ’blobStorageAccountName’, ‘blobContainerName’, ‘blobPrefix’ (for other platforms).

  • param_kind_map (dict) – A mapping of parameter kinds to their corresponding keys in the param dictionary.

  • execution_platform (str) – The platform on which the execution is taking place. Expected values include “Batch AWS” or other non-AWS platforms.

  • storage_provider (str) – Either s3:// or az://

  • mode (str) – For “parameters” is creating the ‘*.config’ file and it adds the complete path, for “asis” leaves the constructed path as generated from the API

Returns:

str

  • For ‘dataItem’ on AWS Batch: “s3BucketName/s3ObjectKey” or “s3BucketName/s3Prefix”.

  • For ‘dataItem’ on other platforms: “blobStorageAccountName/blobContainerName/blobName”.

  • For ‘globPattern’ on AWS Batch: “s3BucketName/s3Prefix/globPattern”.

  • For ‘globPattern’ on other platforms: “blobStorageAccountName/blobContainerName/blobPrefix/globPattern”.

Return type:

A constructed storage path based on the parameter kind and execution platform.