Skip to content

CLI reference

Tip

You can define some options by setting environment variables. This is probably the most convenient way.

run command

To execute jobs synchronously (wait for their completion and get their result), you have to use the run CLI command.

$ smartjob run --help

Usage: smartjob run [OPTIONS] NAME

Arguments:
  NAME  Name of the job  [required]

Options:
  --docker-image TEXT             Docker image to use
  --override-command-and-args TEXT
                                  Override docker image command and arguments
  --add-env TEXT                  Add a new env var in the container
                                  environment (format: key=value, can be used
                                  multiple times)
  --staging-bucket TEXT           staging bucket (starting with gs://) for
                                  loading python_script_path (cloudrun or
                                  vertex only)  [env var:
                                  SMARTJOB_STAGING_BUCKET]
  --python-script-path TEXT       local path to python script to execute in
                                  the container
  --cpu FLOAT                     Number of CPUs (cloudrun only)
  --memory-gb FLOAT               Memory in Gb (cloudrun only)
  --local-path-input TEXT         Local path input (format:
                                  filename=local_path, can be used multiple
                                  times)
  --gcs-input TEXT                GCS path input (format:
                                  filename=full_source_gcs_path, can be used
                                  multiple times)
  --log-level TEXT                log level  [env var: LOG_LEVEL; default:
                                  INFO]
  --namespace TEXT                namespace (simple string)  [env var:
                                  SMARTJOB_NAMESPACE; default: default]
  --project TEXT                  GCP project  [env var: SMARTJOB_PROJECT]
  --region TEXT                   GCP region  [env var: SMARTJOB_REGION]
  --executor TEXT                 executor type ('vertex', 'cloudrun',
                                  'cloudbatch' or 'docker')  [default:
                                  cloudrun]
  --service-account TEXT          GCP service account to use  [env var:
                                  SMARTJOB_SERVICE_ACCOUNT]
  --max-attempts INTEGER          Number of attempts (if failure), must be >=
                                  1  [default: 1]
  --vpc-connector-network TEXT    VPC connector network (cloudrun only)
  --vpc-connector-subnetwork TEXT
                                  VPC connector subnetwork (cloudrun only)
  --machine-type TEXT             Machine type (vertex only)
  --timeout-seconds INTEGER       No. of seconds before the job times out
                                  [default: 3600]
  --sidecars-container-images TEXT
                                  Sidecars container images (format:
                                  image_name, can be used multiple times)
  --help                          Show this message and exit.

schedule command

To execute jobs in a "fire and forget" way, you have to use the schedule CLI command.

$ smartjob schedule --help

Usage: smartjob schedule [OPTIONS] NAME

Arguments:
  NAME  Name of the job  [required]

Options:
  --docker-image TEXT             Docker image to use
  --override-command-and-args TEXT
                                  Override docker image command and arguments
  --add-env TEXT                  Add a new env var in the container
                                  environment (format: key=value, can be used
                                  multiple times)
  --staging-bucket TEXT           staging bucket (starting with gs://) for
                                  loading python_script_path (cloudrun or
                                  vertex only)  [env var:
                                  SMARTJOB_STAGING_BUCKET]
  --python-script-path TEXT       local path to python script to execute in
                                  the container
  --cpu FLOAT                     Number of CPUs  [default: 1.0]
  --memory-gb FLOAT               Memory in Gb  [default: 0.5]
  --local-path-input TEXT         Local path input (format:
                                  filename=local_path, can be used multiple
                                  times)
  --gcs-input TEXT                GCS path input (format:
                                  filename=full_source_gcs_path, can be used
                                  multiple times)
  --log-level TEXT                log level  [env var: LOG_LEVEL; default:
                                  INFO]
  --namespace TEXT                namespace (simple string)  [env var:
                                  SMARTJOB_NAMESPACE; default: default]
  --project TEXT                  GCP project  [env var: SMARTJOB_PROJECT]
  --region TEXT                   GCP region  [env var: SMARTJOB_REGION]
  --executor TEXT                 executor type ('vertex', 'cloudrun',
                                  'cloudbatch' or 'docker')  [default:
                                  cloudrun]
  --service-account TEXT          GCP service account to use  [env var:
                                  SMARTJOB_SERVICE_ACCOUNT]
  --max-attempts INTEGER          Number of attempts (if failure), must be >=
                                  1  [default: 1]
  --vpc-connector-network TEXT    VPC connector network (cloudrun only)
  --vpc-connector-subnetwork TEXT
                                  VPC connector subnetwork (cloudrun only)
  --machine-type TEXT             Machine type (vertex only)
  --timeout-seconds INTEGER       No. of seconds before the job times out
                                  [default: 3600]
  --sidecars-container-images TEXT
                                  Sidecars container images (format:
                                  image_name, can be used multiple times)
  --help                          Show this message and exit.

Tip

You can define the executor type: cloudrun, vertex or docker with the option --executor (cloudrun will be used by default).