Skip to main content

Python client for Rabbit BigQuery Job Optimizer API

Project description

Rabbit BigQuery Job Optimizer Python Client

This is the official Python client library for the Rabbit BigQuery Job Optimizer API.

Installation

pip install rabbit-bq-optimizer

Usage

from rabbit_bq_optimizer import RabbitBQOptimizer

# Initialize the client
client = RabbitBQOptimizer(
    api_key="your-api-key",
    base_url="https://api.rabbit.com/v1"  # Optional, defaults to production URL
)

# Optimize a BigQuery job configuration
job_config = {
    "query": {
        "query": "SELECT * FROM my_table",
        "useLegacySql": False,
        "priority": "INTERACTIVE"
    }
}

optimization_config = {
    "type": "reservation_assignment",
    "defaultPricingMode": "on_demand",
    "config": {
        "reservationIds": [
            "projects/my-project/locations/US/reservations/my-reservation-us",
            "projects/my-project/locations/EU/reservations/my-reservation-eu"
        ]
    }
}

# Optimize the job
result = client.optimize_job(
    configuration=job_config,
    enabled_optimizations=[optimization_config]
)

# Access the optimized configuration
optimized_config = result.optimized_configuration

# Access optimization results
for optimization in result.optimization_results:
    print(f"Type: {optimization.type}")
    print(f"Applied: {optimization.performed}")
    print(f"Estimated Savings: {optimization.estimated_savings}")

Error Handling

The client raises exceptions for API errors:

from rabbit_bq_optimizer import RabbitBQOptimizerError

try:
    result = client.optimize_job(job_config)
except RabbitBQOptimizerError as e:
    print(f"Error: {e.message}")
    print(f"Status Code: {e.status_code}")

Development

To install the package in development mode:

pip install -e .

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rabbit_bq_job_optimizer-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rabbit_bq_job_optimizer-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file rabbit_bq_job_optimizer-0.1.0.tar.gz.

File metadata

  • Download URL: rabbit_bq_job_optimizer-0.1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for rabbit_bq_job_optimizer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5382c6f028f3f900ed5d084e7a2eb569a1eeb8aabcb2ae15e02010c34dcf4a31
MD5 d633fc781e8981298f21c0350e160613
BLAKE2b-256 20bce6b4e784b7ee5e21615efcd4e316c98458745d4f84e959c985294d1f30ae

See more details on using hashes here.

File details

Details for the file rabbit_bq_job_optimizer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rabbit_bq_job_optimizer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a25c6bf49f593395150147ea5fb36d21a81b3a10fbeef0dad65b653d1bd5d463
MD5 a754cf5615a83ae94d08b5e1f0e6d0f1
BLAKE2b-256 3637cf31f59373fcd2b9300a05118d82fada7107c0fb802f22c40582afdea58c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page