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-job-optimizer

Usage

from rabbit_bq_job_optimizer import RabbitBQOptimizer, OptimizationConfig

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

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

optimization_config = OptimizationConfig(
    type="reservation_assignment",
    config={
        "defaultPricingMode": "on_demand",
        "reservationIds": [
            "my-project:US.my-reservation-us",
            "my-project:EU.my-reservation-eu"
        ]
    }
)

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

# Access the optimized configuration
optimized_config = result.optimizedJob

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

Error Handling

The client raises exceptions for API errors:

from rabbit_bq_job_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.5.tar.gz (7.3 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.5-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rabbit_bq_job_optimizer-0.1.5.tar.gz
  • Upload date:
  • Size: 7.3 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.5.tar.gz
Algorithm Hash digest
SHA256 0d2ce7e262b5106d277ddc82f8beffc263e756554d1fba4367531ed246dd0f5f
MD5 b97d8b725b9e9d2b367a0df0f8e3e7f9
BLAKE2b-256 dfabacf8585aa8b18624357eb4471f8281fb69a071019efd8129eb6cebace06c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rabbit_bq_job_optimizer-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 448f2d5a4779cf11648b10645fc024919d30e335ffcef28d9f48d50311a39722
MD5 7f4c4dce754175798e87dc727854a03a
BLAKE2b-256 91bf377d4bfa608d555f5b50a3fd3f819b93575a462e9deee5cc528330286cf4

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