client.commands.validation

Validation helper functions.

Helper functions for validating user permissions and workflow state: - Username validation - Workflow validation - ID chunking utilities

Functions

validate_username(→ None)

Validate that the user is approved to make changes to a workflow.

validate_workflow(→ jobmon.core.constants.WorkflowStatus)

Validate that task IDs belong to a valid workflow.

chunk_ids(→ List[List[int]])

Chunk a list of IDs into smaller lists.

Module Contents

client.commands.validation.validate_username(workflow_id: int, username: str, requester: jobmon.core.requester.Requester) None

Validate that the user is approved to make changes to a workflow.

Parameters:
  • workflow_id – The workflow ID to check permissions for

  • username – The username to validate

  • requester – Server requester object

Raises:

AssertionError – If the user is not allowed to modify the workflow

client.commands.validation.validate_workflow(task_ids: List[int], requester: jobmon.core.requester.Requester) jobmon.core.constants.WorkflowStatus

Validate that task IDs belong to a valid workflow.

Validates that the task_ids provided belong to the expected workflow, and the workflow status is in expected status unless we want to force it through.

Parameters:
  • task_ids – List of task IDs to validate

  • requester – Server requester object

Returns:

The workflow status

Raises:

AssertionError – If validation fails (wrong workflow status or mixed workflows)

client.commands.validation.chunk_ids(ids: List[int], chunk_size: int = 100) List[List[int]]

Chunk a list of IDs into smaller lists.

Useful for avoiding HTTP request size limits.

Parameters:
  • ids – list of IDs to chunk

  • chunk_size – the size of each chunk; default to 100

Returns:

A list of lists, each containing at most chunk_size IDs