In addition to scheduling resolver executions, Chalk allows you to trigger resolver executions programmatically via the Chalk Client, CLI and REST API.


​
Trigger a Run via Chalk Client

Using the Chalk Client, you can trigger a resolver run using the trigger_resolver_run command.

from chalk.client import ChalkClient

ChalkClient().trigger_resolver_run(resolver_fqn="load_user_data", store_online=True)

To read more about how to specify parameters like upper_bound, lower_bound, store_online, store_offline, and idempotency_key, check out our API documentation.

​
Wait for a run to finish

trigger_resolver_run returns the run’s id and status. While the run is in progress, its status is received. To wait for the run to finish, call get_run_status with the run ID until the status changes to succeeded or failed:

import time

from chalk.client import ChalkClient

client = ChalkClient()
run = client.trigger_resolver_run(resolver_fqn="load_user_data", store_online=True)

while run.status == "received":
    time.sleep(10)
    run = client.get_run_status(run_id=run.id)

print(run.status)

To check on a run you already triggered, call get_run_status with its ID.


​
Trigger a Run via CLI

The chalk trigger command allows you to trigger a resolver execution via the CLI.

$ chalk trigger --resolver my.module.fn
ID:     e6d90797-5430-4bae-b39d-6c9ce695e6ad
Status: RECEIVED
URL:    https://chalk.ai/projects/<project-id>/environments/<environment-id>/runs/e6d90797-5430-4bae-b39d-6c9ce695e6ad

chalk trigger prints the run’s ID, its status when the run was triggered, and the URL of the run’s page in the dashboard. To follow the run, open the URL. To check the run’s status from a script, pass the ID to get_run_status or to the run status endpoint.

To read more about how to specify flags like deployment, persist-online, persist-offline, and idempotency-key, check out our CLI documentation.


​
Trigger a Run via API

Using the trigger API endpoint allows you to build custom integrations with other data orchestration tools like Airflow.

The trigger endpoint will return within 300 seconds, even if the triggered run takes longer to execute. If the returned status is received, you should poll the v1/runs/{id} endpoint until status transitions to succeeded or failed.

It is also possible to manually trigger resolver executions via the Chalk dashboard, on the details page for the resolver you would like to run. The same input parameters are available in the dashboard.

Note: if you use a user-scoped token (i.e. one that’s derived from chalk login) you will need to specify the environment in which to trigger your resolver via the X-Chalk-Env-id header.

​
Trigger a run

POST
https://api.chalk.ai/v1/runs/trigger
Request Body
resolver_fqnstring

The fully qualified name of the resolver to trigger. Example: ‘neobank.resolvers.offline_get_transactions’.

lower_boundtimestamp

The lower bound timestamp to use when sampling input features to run this resolver on. Example: ‘2021-01-01T00:00:00Z’.

upper_boundtimestamp

The upper bound

max_samplesnumber

The maximum number of samples to pull from the offline store when running this resolver. Example: 1000.

​
Response

Attributes
idstring
ID of the relevant run.
statusenum

One of ‘received’, ‘succeeded’, or ‘failed’

​
Example

curl -XPOST -H "Authorization: Bearer $(chalk token)" \
     -H "X-Chalk-Env-Id: <your-environment-id>" \
     -H "Content-Type: application/json" \
     https://api.chalk.ai/v1/runs/trigger \
     -d '{ "resolver_fqn": "neobank.resolvers.offline_get_transactions" }'

# Returns

{
  "id": "<run-id>",
  "status": "succeeded"
}

​
Query run status

GET
https://api.chalk.ai/v1/runs/:id
Attributes
id
URL Param. ID of the relevant run.

​
Response

Attributes
idstring
ID of the relevant run.
statusenum

One of ‘received’, ‘succeeded’, or ‘failed’

​
Example

curl -H "Authorization: Bearer $(chalk token)" \
     -H "X-Chalk-Env-Id: <your-environment-id>" \
     https://api.chalk.ai/v1/runs/{run_id}
⌂ 换网址