Skip to main content

gravi-model-client

Python client for Gravitate's demand and supply optimization models.

Installation

pip install gravi-model-client

Usage

from gravi_model_client import GraviModelClient, ModelRunRequest, OptimizationInput

async with GraviModelClient(api_key="your-api-key", base_url="https://...") as client:
    # Health check
    await client.health_check()

    # Run demand model (synchronous)
    result = await client.run_demand_model(request)

    # Run TSD (supply) model (synchronous)
    result = await client.run_tsd_model(optimization)

Async (queue-based) models: VRP and OSA

VRP (tank wagon turn) and OSA (order-based supply) runs are queued and processed by a worker. run_vrp_model / run_osa_model handle the whole queue → poll → fetch lifecycle and block until the result is ready:

from gravi_model_client import GraviModelClient, VrpModelRunRequest, OsaInput

async with GraviModelClient(api_key="your-api-key") as client:
    vrp_result = await client.run_vrp_model(vrp_request)   # -> VrpModelResultResponse
    osa_result = await client.run_osa_model(osa_input)     # -> OsaAPIResponse

They raise ModelRunError if the run fails or is cancelled, and ModelRunTimeout if it doesn't finish within timeout (default 300s; tune poll_interval too).

For fire-and-forget / webhook workflows, use the primitives instead: queue_vrp_model returns a job id, get_job_status / get_osa_job_status return a JobStatus, and get_vrp_model_run_response / get_osa_model_run_response fetch the finished result.

Models

This package is the single source of truth for all pydantic models used by both the client and the server. Import models directly:

from gravi_model_client.demand import ModelRunRequest, StoreRequest, TankRequest, VolumeRange
from gravi_model_client.tsd import OptimizationInput, Directive, Site, Tank

Download files

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

Source Distribution

gravi_model_client-0.8.0.tar.gz (37.6 kB view details)

Uploaded Source

Built Distribution

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

gravi_model_client-0.8.0-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file gravi_model_client-0.8.0.tar.gz.

File metadata

  • Download URL: gravi_model_client-0.8.0.tar.gz
  • Upload date:
  • Size: 37.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for gravi_model_client-0.8.0.tar.gz
Algorithm Hash digest
SHA256 1dbd8a5773336c68ee57430e2d95157c342fe2c6eae6aa67b2db7a3a4fe404f6
MD5 791a85191ad877faae4b4c41c66f41f4
BLAKE2b-256 edd2cdcf059f7a6db9595ca7681259c7e640b02812c910b58bfabc78076afd08

See more details on using hashes here.

Provenance

The following attestation bundles were made for gravi_model_client-0.8.0.tar.gz:

Publisher: publish-gravi-model-client.yml on gravitate-energy/demand_only_model

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gravi_model_client-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gravi_model_client-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 720f9e2371e759829406f087b9a71776503f6aae43d3ec8286442d8e39f6f041
MD5 34a5074a07367798406cacc9d5642ebc
BLAKE2b-256 66702a63f4553b5641c3ff5da3f89e9f04197da6720a2f1734b6e598bf093c49

See more details on using hashes here.

Provenance

The following attestation bundles were made for gravi_model_client-0.8.0-py3-none-any.whl:

Publisher: publish-gravi-model-client.yml on gravitate-energy/demand_only_model

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

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