Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Launching Automated Workflows using scripts (v5.1+)

Automated Workflows in CryoSPARC provide a powerful mechanism for processing single particle cryo-EM data in an unattended fashion, making use of the CryoSPARC Workflows UI feature to streamline the creation, connection, and launching of jobs into a single click.

In CryoSPARC v5.1, Workflows can be created, edited, and launched programatically using the CryoSPARC API, which allows workflows to be triggered automatically, for example when new data is available, or when a CryoSPARC Live session completes, etc.

Connecting to the CryoSPARC API

The CryoSPARC API can be accessed in multiple ways, all explained here. The simplest way is to use the interactive CryoSPARC command line, which can be started on the CryoSPARC master node, by running cryosparcm icli . Once inside this interactive Python shell, you can type Python commands and execute them. You can also write Python scripts that use the API.

Workflows API

The full documentation for the Workflows API can be found here. The API is simple to use, with a few Python examples given here:

List saved Workflows

workflows = api.workflows.find(limit=10)
for workflow in workflows:
    print(workflow.title)

Fetch a workflow

workflow = api.workflows.find(limit=10)[0]
workflow = api.workflows.find_one(workflow.id)

Apply a workflow

This example uses cryosparc-tools to connect to the API.

from cryosparc.tools import CryoSPARC
from cryosparc.models.blueprint import BlueprintParameter
from cryosparc.models.workflow import ApplyWorkflowRequest, WorkflowParameter
from cryosparc.models.workspace import JobGroupCreate, JobGroupUpdate

cs = CryoSPARC("<https://cryosparc.example.com>")
api = cs.api

workflow = api.workflows.find(limit=10)[0]
workflow = api.workflows.find_one(workflow.id)
api.workflows.apply(
    ApplyWorkflowRequest(
        workflow=workflow,
        parent_juids=[],  # supply existing J-UIDs if the workflow has parents
        lane=None,        # set a lane name to enqueue created jobs
    ),
    project_uid="P1",
    workspace_uid="W1",
)

Change a parameter for a job in workflow that has been saved

Last updated