-
-
Save lebovic/72fbb857119f1667c7959a4d7e28cd50 to your computer and use it in GitHub Desktop.
Running Toolchest asynchronously using the run_id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import toolchest_client as toolchest | |
toolchest.set_key("YOUR_KEY_HERE") | |
# | |
# Toolchest call #1: initiate the run | |
# | |
toolchest_run = toolchest.kraken2( | |
tool_args="--minimum-base-quality 25", | |
read_one="s3://toolchest-demo-data/SRR16201572_R1.fastq", | |
custom_database_path="s3://toolchest-fsx-databases/kraken2/k2_viral_20210517/", | |
is_async=True, | |
) | |
run_id = toolchest_run.run_id | |
run_status = toolchest.get_status(run_id=run_id) | |
while run_status != toolchest.Status.READY_TO_TRANSFER_TO_CLIENT: | |
print("Current run status: ", run_status) | |
print("Run not done yet. Waiting another fifteen seconds before checking again...") | |
time.sleep(15) | |
# | |
# Key Toolchest call #2: check status | |
# | |
run_status = toolchest.get_status(run_id=run_id) | |
if run_status == toolchest.Status.FAILED: | |
print("Toolchest run failed. See logs for more details.") | |
print("Done! Downloading...") | |
# | |
# Key Toolchest call #3: download the files | |
# | |
toolchest.download( | |
output_path='/tmp', | |
run_id=run_id, | |
) | |
print("Downloaded!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment