Starting cryosparc live sessions with Jupyter notebook

Hello,

I am currently trying to setup the ability to launch CS live sessions through a standardized python script or Jupyter notebook.

I found this tutorial: Managing a CryoSPARC Live Session from the CLI | CryoSPARC Guide and also this other post Can cryosparc-tools be used to start CryoSPARC-Live sessions?

I am trying to run this in a Jupyter Notebook on the headnode where Cryosparc runs. I cannot get the first imports to work:

import os
from cryosparc_compute import client

host = os.environ['CRYOSPARC_MASTER_HOSTNAME']
command_core_port = int(os.environ['CRYOSPARC_COMMAND_CORE_PORT'])
command_rtp_port = int(os.environ['CRYOSPARC_COMMAND_RTP_PORT'])

It cannot find the cryosparc_compute.

I was able to create a conda environment where cryosparc.tools was installed as explaind here: Getting Started — cryosparc-tools.

import os
from cryosparc.tools import CryoSPARC
from cryosparc.command import CommandClient

Is cryosparc_compute deprecated ? How can I do the equivalent as explained in that guide but with cryosparc.tools.

Thanks,

William J Nicolas

Hi William,

Suppose you have a conda environment that includes

  1. cryosparc-tools compatible with the software version of your CryoSPARC instance
  2. jupyter notebook or jupyter lab

Then you may start a CryoSPARC Live session inside a notebook by using commands similar to those shown in the guide.
In the notebook, you could instantiate a CryoSPARC object

from cryosparc.tools import CryoSPARC
cs = CryoSPARC(..)

and subsequently run cli as well as rtp commands like

cs.cli.get_id_by_email(..)
cs.rtp.update_compute_configuration(..)

Caution: This mode of interacting with cli commands, rtp commands and CryoSPARC Live sessions is unstable, that is, a future CryoSPARC release will likely break code based on this approach.