Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 0.2.7 instead.
Reason given by maintainers: Contains bugs

gc-batch

A command-line interface and Python client for managing Google Cloud Batch jobs, with support for job creation, monitoring, logging, GCS bucket mounts, local SSD storage, and filtering by labels.

Installation

pip install gc-batch

Or, for development, using uv:

git clone https://github.com/empirico-oss/gc-batch.git
cd gc-batch
uv sync

Requires Python 3.10 or newer, and credentials for a Google Cloud project with the Batch API enabled (gcloud auth application-default login).

Quick start

# Create a job
gc-batch --project-id my-project create \
  --job-name my-first-job \
  --docker-image gcr.io/my-project/my-image:latest \
  --command "python /app/main.py"

# List jobs, or just your own
gc-batch --project-id my-project list-jobs
gc-batch --project-id my-project list-my-jobs

# Check status and read logs
gc-batch --project-id my-project status --job-name my-first-job-1234567890
gc-batch --project-id my-project logs --job-name my-first-job-1234567890

The project is resolved from --project-id, then $GOOGLE_PROJECT, then the default_project_id setting. If none is set, the command exits with an error rather than guessing.

Use as a Python library

The same functionality is importable, so scripts, notebooks, and orchestration code can submit and monitor jobs without shelling out to the CLI:

import time

from gc_batch import BatchClientConfig, BatchJobConfig, GCBatchClient, JobRequest
from gc_batch.utils import is_job_finished

client = GCBatchClient(BatchClientConfig(project_id="my-project", location="us-central1"))

job = client.create_job(
    JobRequest(
        job_name="my-first-job",
        docker_image="gcr.io/my-project/my-image:latest",
        command="python /app/main.py",
        config=BatchJobConfig(
            machine_type="n2-standard-4",
            boot_disk_type="pd-balanced",
            input_bucket="my-bucket/datasets",
            output_bucket="my-bucket/results",
        ),
        labels={"team": "data-science"},
    )
)

# create_job timestamps the name, so read the submitted one off the job
short_name = job.name.split("/")[-1]

while not is_job_finished(job := client.get_job(short_name)):
    time.sleep(30)

print(job.status.state.name)
if job.status.state.name == "FAILED":
    print(client.get_failure_message(job))
    print(client.get_cloud_logging_url(job, severity="ERROR"))

Listing, cancelling, and log retrieval are all available too:

jobs = client.list_jobs(labels={"team": "data-science"}, status="RUNNING")
client.cancel_job(job.name)  # full resource path, not the short name

# Logs, from Cloud Logging or from the bucket when the job used logs_bucket
client.batch_logging.print_logs_for_job(job)
client.gcs_logging.print_logs_for_job(job)

See the Python API guide for job profiles, mounts, local SSD, settings, fan-out, and error handling.

Configuration

Values that differ between deployments — the job-name prefix, the created-using label, and named job profiles — are resolved in this order, highest precedence first:

  1. explicit arguments
  2. GC_BATCH_* environment variables
  3. a TOML config file (--config-file, $GC_BATCH_CONFIG_FILE, ./gc-batch.toml, or $XDG_CONFIG_HOME/gc-batch/config.toml)
  4. neutral defaults

Restricted VPC environments

gc-batch ships a built-in all-of-us job profile for the All of Us Researcher Workbench, which runs jobs inside a restricted VPC:

gc-batch --project-id my-project create \
  --job-profile all-of-us \
  --job-name my-job \
  --docker-image gcr.io/my-project/my-image:latest \
  --command "python /app/main.py"

You can define additional profiles in the config file. See the Configuration guide.

Documentation

Full documentation: https://empirico-oss.github.io/gc-batch/stable/

Contributing

See CONTRIBUTING.md. Security issues should be reported per SECURITY.md.

License

MIT — see LICENSE.

Metadata

Release files for gc-batch 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gc-batch 0.2.2
File Size Uploaded Provenance Actions
gc_batch-0.2.2.tar.gz 65.4 kB With provenance Details for gc_batch-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gc-batch 0.2.2
File Interpreter ABI Platform Actions
gc_batch-0.2.2-py3-none-any.whl Python 3 none any Details for gc_batch-0.2.2-py3-none-any.whl

Total release size: 115.7 kB

Release files / gc_batch-0.2.2.tar.gz

Download URL gc_batch-0.2.2.tar.gz
Size 65.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4bfcf74eb832894daf42e852002f1f350b042f4b0c5217b9ab0934ca45b153f4
BLAKE2b-256 checksum
How to use checksums
f9b9970e659c8e51a9a00cd8fe24c236199c09a6bed882b8ace4a9c513de7d1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / gc_batch-0.2.2-py3-none-any.whl

Download URL gc_batch-0.2.2-py3-none-any.whl
Size 50.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c2242193c549e778a78533cb8d7b92ae9f3361cb3a033ec9d254fd6aed6cf2c
BLAKE2b-256 checksum
How to use checksums
ff1e43e8ca84bf1575b82caeebbb46daf9407a8c509a4df515433cd12df17af2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Security for gc-batch 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gc_batch-0.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page