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 for stdout output with responsive design.

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 CloudOS 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 CloudOS 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 CloudOS 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 - ‘lustreFileSystem’: Lustre filesystem 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)[source]

Creates a formatted job list table for stdout output with responsive design.

The table automatically adapts to terminal width by showing different column sets: - Very narrow (<60 chars): Essential columns only (status, name, pipeline, id) - Narrow (<90 chars): + Important columns (project, owner, run_time, cost) - Medium (<120 chars): + Useful columns (submit_time, end_time, commit) - Wide (≥120 chars): + Extended columns (resources, storage_type)

Status symbols are displayed with colors: - Green ✓ for completed jobs - Grey ◐ for running jobs - Red ✗ for failed jobs - Orange ■ for aborted jobs - Grey ○ for initialising jobs - Grey ? for unknown status

Parameters:
  • jobs (list) – List of job dictionaries from the CloudOS API.

  • cloudos_url (str) – The CloudOS service URL for generating job links.

  • pagination_metadata (dict, optional) – Pagination metadata from the API response containing: - ‘Pagination-Count’: Total number of jobs matching the filter - ‘Pagination-Page’: Current page number - ‘Pagination-Limit’: Page size

  • selected_columns (str or list, optional) – Column names to display. Can be: - None: Auto-responsive based on terminal width - String: Comma-separated column names (e.g., “status,name,cost”) - List: List of column names Valid columns: ‘status’, ‘name’, ‘project’, ‘owner’, ‘pipeline’, ‘id’, ‘submit_time’, ‘end_time’, ‘run_time’, ‘commit’, ‘cost’, ‘resources’, ‘storage_type’

Returns:

Prints the formatted table to console with pagination information.

Return type:

None

Raises:

ValueError – If invalid column names are provided in selected_columns.

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.