Error in get_project_file using cryosparc-tools

Hi,
I’m trying to get particles by using cryosparc-tools, but experience this error.
Could you please help me?

Error:

project = cs.find_project(“P3”)
job = project.find_job(“J2108”)
particles = job.load_output(“particles”)
Traceback (most recent call last):
File “”, line 1, in
File “/home/cryosparc_user/cryosparc-tools/cryosparc/job.py”, line 461, in load_output
datasets = [self.cs.download_dataset(self.project_uid, f) for f in metafiles]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/cryosparc_user/cryosparc-tools/cryosparc/job.py”, line 461, in
datasets = [self.cs.download_dataset(self.project_uid, f) for f in metafiles]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/cryosparc_user/cryosparc-tools/cryosparc/tools.py”, line 682, in download_dataset
with self.download(project_uid, path) as response:
File “/home/cryosparc_user/miniconda3/lib/python3.11/contextlib.py”, line 137, in enter
return next(self.gen)
^^^^^^^^^^^^^^
File “/home/cryosparc_user/cryosparc-tools/cryosparc/command.py”, line 226, in make_request
raise CommandError(error_reason, url=url, code=code, data=resdata)
cryosparc.errors.CommandError: *** (http://XXXXXXXX:39003/get_project_file, code 500) HTTP Error 500 INTERNAL SERVER ERROR; please check cryosparcm log command_vis for additional information.
Response from server: b’\n500 Internal Server Error\n

Internal Server Error

\n

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

\n’

cryosparcm log:
[2024-04-25 16:01:34,577] ERROR in app: Exception on /get_project_file [POST]
Traceback (most recent call last):
File “/cryosparc/cryosparc_master/deps/anaconda/envs/cryosparc_master_env/lib/python3.8/site-packages/flask/app.py”, line 2447, in wsgi_app
response = self.full_dispatch_request()
File “/cryosparc/cryosparc_master/deps/anaconda/envs/cryosparc_master_env/lib/python3.8/site-packages/flask/app.py”, line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/cryosparc/cryosparc_master/deps/anaconda/envs/cryosparc_master_env/lib/python3.8/site-packages/flask/app.py”, line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File “/cryosparc/cryosparc_master/deps/anaconda/envs/cryosparc_master_env/lib/python3.8/site-packages/flask/_compat.py”, line 39, in reraise
raise value
File “/cryosparc/cryosparc_master/deps/anaconda/envs/cryosparc_master_env/lib/python3.8/site-packages/flask/app.py”, line 1950, in full_dispatch_request
rv = self.dispatch_request()
File “/cryosparc/cryosparc_master/deps/anaconda/envs/cryosparc_master_env/lib/python3.8/site-packages/flask/app.py”, line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File “/cryosparc/cryosparc_master/cryosparc_command/command_vis/viscommon.py”, line 58, in request_handler
res = func(*args, **kwargs)
TypeError: get_project_file() got an unexpected keyword argument ‘path’
2024-04-25 16:01:58,813 request_handler INFO | Received request for get_project_file
[2024-04-25 16:01:58,814] ERROR in app: Exception on /get_project_file [POST]
Traceback (most recent call last):
File “/cryosparc/cryosparc_master/deps/anaconda/envs/cryosparc_master_env/lib/python3.8/site-packages/flask/app.py”, line 2447, in wsgi_app
response = self.full_dispatch_request()
File “/cryosparc/cryosparc_master/deps/anaconda/envs/cryosparc_master_env/lib/python3.8/site-packages/flask/app.py”, line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/cryosparc/cryosparc_master/deps/anaconda/envs/cryosparc_master_env/lib/python3.8/site-packages/flask/app.py”, line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File “/cryosparc/cryosparc_master/deps/anaconda/envs/cryosparc_master_env/lib/python3.8/site-packages/flask/_compat.py”, line 39, in reraise
raise value
File “/cryosparc/cryosparc_master/deps/anaconda/envs/cryosparc_master_env/lib/python3.8/site-packages/flask/app.py”, line 1950, in full_dispatch_request
rv = self.dispatch_request()
File “/cryosparc/cryosparc_master/deps/anaconda/envs/cryosparc_master_env/lib/python3.8/site-packages/flask/app.py”, line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File “/cryosparc/cryosparc_master/cryosparc_command/command_vis/viscommon.py”, line 58, in request_handler
res = func(*args, **kwargs)
TypeError: get_project_file() got an unexpected keyword argument ‘path’

Hi @menmt, this error happens when using a develop of cryosparc-tools cloned or downloaded from GitHub, rather than the latest release installed from pip. Could you confirm this is the case? If not, how did you install cryosparc-tools and which version of CryoSPARC are you running?

If you downloaded a release tarball, you can download the latest available version here: Release v4.4.1 · cryoem-uoft/cryosparc-tools · GitHub

If you cloned from GitHub, check out the correct release branch from your version of cryosparc and rebuild. Example for CryoSPARC v4.4.x versions:

cd cryosparc-tools
git fetch
git checkout release-v4.4
python -m setup build_ext -i

Hi,

My CryoSPARC is v4.4.1+240110.
I installed cryosparc-tools from pip and the version is also 4.4.1.
However, this error happens.

What should I do next?

@menmt

A few more troubleshooting questions:

  • How did the /home/cryosparc_user/cryosparc-tools folder get on your system? Did you create this yourself?
  • Could you share the link to the instructions you followed when setting up cryosparc-tools?
  • What is the full path to the .py file that contains your cryosparc-tools script?
  • What exact commands do you use to run the script? Please include every command you run after logging in from a terminal to run the script, including any directory change commands and conda environment activations. Ideally, please copy in the entire contents of the terminal up until running the script (obfuscating any sensitive data like your host name)
  1. I created /home/cryosparc_user/cryosparc-tools folder myself.

  2. I followed this instruction.
    Getting Started — cryosparc-tools

  3. The full path for the .py file is
    /home/cryosparc_user/cryosparc-tools/cryosparc

  4. The command I used is

project = cs.find_project(“P3”)
job = project.find_job(“J2108”)
These went through without any error.

Then, I did this and the got the error.
particles = job.load_output(“particles”)

I tested other jobs having particles and got the same errors.

@menmt my apologies, I was not clear, for (4) I meant the terminal commands you use to run the script, not the contents of the Python script. For example, here are the commands I use run a tools .py script on my machine:

cd scripts
conda activate tools
pip install cryosparc-tools
python my_tools_script.py

Could you tell me what your commands look like?

My guess is that /home/cryosparc_user/cryosparc-tools is downloaded directly from GitHub and not installed from pip. Your script should be using the pip version, but instead it is using this folder. This is not valid.

I suggest you move your Python script to a different location, delete the /home/cryosparc_user/cryosparc-tools folder, and redo the cryosparc-tools installation from the “Prerequisites” section.