Async Runs

Toolchest supports async execution for every tool. Async runs are useful long running commands, because you do not need to keep an open terminal or connection while Toolchest is executing.

We've seen people use async runs from AWS Lambda functions, custom automated pipelines, and manual calls from IDEs.

Launching an Async Run

To launch an async run, ad the is_async parameter with the value True in your function call. For example, using the test function:

my_run = toolchest.test(
    inputs = INPUT,
    output_path = OUTPUT_DIR,
    tool_args = "",
    is_async = TRUE

Handling an async run automatically

After the Toolchest run is initialized and all file transfers are complete, the Toolchest call returns an output object containing a run ID.

You can check your run status using the returned run ID (e.g. my_run.run_id).

Handling an async run manually

Once the upload is complete, the following messages are printed, which contain your printed run ID:

Async Toolchest initiation is complete! Your run ID is included in the returned object.

To check the status of this run, call get_status(run_id="{YOUR_PRINTED_RUN_ID}").
Once it's ready to download, call download(run_id="{YOUR_PRINTED_RUN_ID}", ...) within 7 days

Once you see this, Toolchest is executing your run in the background, and you're safe to close your terminal. (Be sure to record the run ID!)

Checking Run Status

To check the status of your async run, call the get_status function with your run ID.

>>> toolchest.get_status(run_id=YOUR_RUN_ID)
>>> toolchest$get_status(run_id = YOUR_RUN_ID)

get_status returns a string. Once the status is ready_to_transfer_to_client, the run has finished execution and is ready to download.

Statuses enum

There's an enum – Status – that contains all statuses returned from get_status(). You can check statuses against this enum for custom error handling, progress tracking, or whatever you're building.

status = toolchest.get_status(run_id=YOUR_RUN_ID)
if status == toolchest.Status.COMPLETE:
  print("AlphaFold run finished! Sending email to reseacher...")

To check all possible enum values, you can print the enum as a list:

>>> list(toolchest.Status)
[<Status.INITIALIZED: 'initialized'>, ...

Downloading Output

To download the output manually, call the download function with your run ID and output directory.
    run_id = YOUR_RUN_ID,
    output_path = OUTPUT_PATH

This downloads the run's output file(s) into the output directory. You can run download for 7 days after starting the run.

Did this page help you?