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.2.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.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rabbit_bq_job_optimizer-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 6c90a8a5ddfe9c30aa1d45c1ad10be68cec6585432fc5512fc0cf35fce4b4338
MD5 d04338b212264717a2a213bcf2b4ff67
BLAKE2b-256 a3f2682a1129a83af42006866fc3f82ef3a3f913178dafd924dc940f516dc22f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rabbit_bq_job_optimizer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c9e328f866e1b7bd7415cc053d65d3965a800f10e4af9a992aa79a7ae286ad5a
MD5 3f553d30b503aba65f62924b097c13cd
BLAKE2b-256 1d48f59b227f4e91ed04d9f1d4b11e15f5e6731ad6d1118d42acde2c582c7ac1

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