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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gravi_model_client-0.6.0.tar.gz.
File metadata
- Download URL: gravi_model_client-0.6.0.tar.gz
- Upload date:
- Size: 36.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48dfbc7244b0a48b0be2403fad326dc371e5e958499bd849f0b7c1b2bc7d96be
|
|
| MD5 |
bc96b830554834e22bee03dcc1f0ed44
|
|
| BLAKE2b-256 |
889a567d9fc0f7bb2e7ac9250f9685a5fe2e35d9ab4dd118b05dce42e174616c
|
Provenance
The following attestation bundles were made for gravi_model_client-0.6.0.tar.gz:
Publisher:
publish-gravi-model-client.yml on gravitate-energy/demand_only_model
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gravi_model_client-0.6.0.tar.gz -
Subject digest:
48dfbc7244b0a48b0be2403fad326dc371e5e958499bd849f0b7c1b2bc7d96be - Sigstore transparency entry: 2518082939
- Sigstore integration time:
-
Permalink:
gravitate-energy/demand_only_model@2550d1af6034531175427f03ca1a631a77c81a3c -
Branch / Tag:
refs/tags/gravi-model-client-v0.6.0 - Owner: https://github.com/gravitate-energy
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-gravi-model-client.yml@2550d1af6034531175427f03ca1a631a77c81a3c -
Trigger Event:
push
-
Statement type:
File details
Details for the file gravi_model_client-0.6.0-py3-none-any.whl.
File metadata
- Download URL: gravi_model_client-0.6.0-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56345fd7a23997f14f7a4a421c9cd159f609f365747314b2042c2ccc2cfc8d79
|
|
| MD5 |
e645b24cc3bb4564f660f182d101682e
|
|
| BLAKE2b-256 |
6d669684c18ecc1bae6fa8c40b5d0bda49e2cc4d103895c5d178f4b4d2d1106c
|
Provenance
The following attestation bundles were made for gravi_model_client-0.6.0-py3-none-any.whl:
Publisher:
publish-gravi-model-client.yml on gravitate-energy/demand_only_model
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gravi_model_client-0.6.0-py3-none-any.whl -
Subject digest:
56345fd7a23997f14f7a4a421c9cd159f609f365747314b2042c2ccc2cfc8d79 - Sigstore transparency entry: 2518083705
- Sigstore integration time:
-
Permalink:
gravitate-energy/demand_only_model@2550d1af6034531175427f03ca1a631a77c81a3c -
Branch / Tag:
refs/tags/gravi-model-client-v0.6.0 - Owner: https://github.com/gravitate-energy
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-gravi-model-client.yml@2550d1af6034531175427f03ca1a631a77c81a3c -
Trigger Event:
push
-
Statement type: