Because of the computational intensity of model runs, Tyba's API follows a "Schedule & Receive" process. This page describes that process.


Scheduling a Model Run

There are three functions to schedule the various types of model runs (once the model has been defined):

from tyba_client.client import Client

#PV-Only Runs
client.schedule_pv(PVModel)

#PV+Storage Runs
client.schedule_pv_storage(PVStorageModel)

#PV+Storage Runs
client.schedule_storage(Storagemodel)

For more details on the model definitions, see the model pages.

The response will be an id, for example:

print(res.json())

#returns
{"id":"d08b1e8e-6c68-40cf-b29c-0b6da18cd777"}

Checking on Status

Run the following to check the status of a scheduled run:

status = client.get_status(id).json()["status"]
print(status)

This request can be run in a loop to wait for results to complete. For example:

complete = False
while not complete:
    res = client.get_status(id).json()
    if res["status"] == "complete":
        complete = True
        print(res.keys())
    else:
        time.sleep(2)

The two main statuses are "scheduled" and "complete." A full list is here.

Receiving Results

When a model run is "complete" the response will have two values, the status (which is "complete") and the "result."