Skip to main content

Jobs API reference

Reference of the CGC SDK cgc.sdk.job module: job_create, job_list and job_delete.

To work with the module: import cgc.sdk.job

job_create​

Creates a new job to run a containerized workload.

Signature:

job_create(
name: str,
image_name: str,
cpu: int = 1,
memory: int = 2,
shm_size: int = 0,
gpu: int = 0,
gpu_type: str = "",
volumes: list = [],
volume_full_path: str = "",
startup_command: str = "",
repository_secret: str = "",
cgc_data: list[str] = [],
environment_data: list[str] = [],
arguments_data: list[str] = [],
config_maps_data: list = [],
ttl_seconds_after_finished: Optional[int] = None
) -> dict

Parameters:

  • name (str, required): Unique name for the job
  • image_name (str, required): Docker image to run for the job
  • cpu (int): Number of CPU cores (default: 1)
  • memory (int): Memory in GB (default: 2)
  • shm_size (int): Shared memory size in GB (default: 0)
  • gpu (int): Number of GPUs (default: 0)
  • gpu_type (str): GPU type, canonical name as shown by cgc status - "NVIDIA-RTX-A5000", "NVIDIA-A100-SXM4-80GB", etc. (default: ""). The SDK does not apply the default that the CLI uses for -gt ("NVIDIA-RTX-A5000"); it sends the empty value as it is. With gpu greater than 0 and gpu_type omitted the call still succeeds and the resource runs, but no card is requested by name and the gpu-label column of cgc compute list stays empty, so pass gpu_type explicitly whenever the card matters.
  • volumes (list): List of volume names to mount
  • volume_full_path (str): Mount path for volumes
  • startup_command (str): Override container entrypoint command
  • repository_secret (str): Secret for private container registries
  • cgc_data (list[str]): CGC-specific configuration data
  • environment_data (list[str]): Environment variables as "KEY=value"
  • arguments_data (list[str]): Command line arguments for the job
  • config_maps_data (list): ConfigMap configurations
  • ttl_seconds_after_finished (Optional[int]): Time to live in seconds after job completion

Returns:

  • dict: Response with job creation status
    • code: HTTP status code
    • details: Job creation details

Raises:

  • SDKException: With code -2 if image_name is missing
  • SDKException: With the HTTP status code for every non-200 response, e.g. 422 for an invalid GPU type

job_list​

Lists all jobs in the current context.

Signature:

job_list() -> dict

Returns:

  • dict: Response containing list of jobs
    • code: HTTP status code
    • details: Contains job_list and job_pod_list with job information and status

job_delete​

Deletes an existing job.

Signature:

job_delete(name: str) -> dict

Parameters:

  • name (str, required): Name of job to delete

Returns:

  • dict: Response with deletion status
    • code: HTTP status code
    • details: Job deletion details