Queuing of multiple CryoSparc Live sessions

Here at the facility we use Cryosparc Live extensively to evaluate more or less all data collections we perform and it has been extremely useful, both from the facility side and for our users/customers. We use individual 4 GPU PCs for this purpose, one for each microscope. With the increased throughput of the new range of detectors and the use of EPU Multigrid we however now very often perform multiple data collections in an overnight run.

Especially, the screening process of new samples now often includes multiple preliminary data collections, reflecting different sample/grid preparation methods, followed by the selection of the best based on live processing.

It would therefore be very useful to be able to que multiple Cryosparc Live runs, such that when coming back to work in the morning, results (up to at least 2D-classification) are immediately available for all datasets which were collected.

While creating multiple live sessions and starting them of course already can be done, I think more specifically what is still needed is:

(1) Time-out function so that a live session will stop after a specified amount of time after the corresponding data collection has finished (in order to free up GPUs for the next session)

(2) The possibility to enable 2D-classification to automatically start after a certain number of particles have been extracted.

Addition of those two functions I think would be very helpful in enabling us to live process multiple collections in a completey unattended way.

Best regards

SciLifeLab Cryo-EM Facility

Welcome to the forum Michael.
A team member let me know that this is already possible, and how it’s done:
Regarding (1) cryosparcm icli
opens an interactive python environment with some relevant cryoSPARC Live modules already loaded. Inside that environment,
rtp.get_session('<project_uid>', '<session_uid>', 'stats')
outputs status information for the given cryoSPARC Live session.
One may monitor
rtp.get_session('<project_uid>', '<session_uid>', 'stats')['stats']['total_ready']
to decide when it’s a good time to
rtp.pause_session('<project_uid>', '<session_uid>')

As an alternative to cryosparcm icli, one may interact with cryoSPARC Live with a python script, but must first do some setup in- and outside the script. For (2), one may write a script delay_start_2d_class.py:

import os
import sys
import time

from cryosparc_compute import client

host = os.environ['CRYOSPARC_MASTER_HOSTNAME']
command_rtp_port = int(os.environ['CRYOSPARC_COMMAND_RTP_PORT'])
rtp = client.CommandClient(host=host, port=command_rtp_port)

def get_total_extracted_particles(project_uid, session_uid):
    session_doc = rtp.get_session(project_uid, session_uid, 'stats.total_extracted_particles')
    return session_doc['stats']['total_extracted_particles']

def start_2d_after_num_particles_extracted(project_uid, session_uid, num_particles=100000, wait_time=30):
    while get_total_extracted_particles(project_uid, session_uid) <= num_particles:
    print(f'Starting Streaming 2D Classification in {project_uid} {session_uid}')
    rtp.phase2_class2D_start(project_uid, session_uid)

if __name__ == '__main__':
    start_2d_after_num_particles_extracted(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])

and run the script in an appropriate environment:

eval $(cryosparcm env)
python delay_start_2d_class.py P50 S2 100000 30