I am trying to use CryoSPARC tools to update parameter fields for particles/exposures but am running into an error that is difficult to debug. Following the examples, I can find the job, load the relevant data, manipulate it, but get an error when saving the results. For debugging purposes, I can replicate the error by just loading the particles/exposures, then saving the exact same dataset.
from cryosparc.tools import CryoSPARC
cs = CryoSPARC(**kwargs)
project30 = cs.find_project("P30")
job15 = project30.find_job("J15")
particles = job15.load_output('particles')
project30.save_external_result(
workspace_uid='W2', dataset=particles, type='particle', name='particles',
slots=['alignments2D', 'alignments3D', 'blob', 'ctf', 'location', 'pick_stats'])
which outputs the following error:
> File ~/.conda/envs/mizimmer/lib/python3.11/site-packages/cryosparc/project.py:278, in Project.save_external_result(self, workspace_uid, dataset, type, name, slots, passthrough, title, desc)
> 196 def save_external_result(
> 197 self,
> 198 workspace_uid: Optional[str],
> (...)
> 205 desc: Optional[str] = None,
> 206 ) -> str:
> 207 """
> 208 Save the given result dataset to the project. Specify at least the
> 209 dataset to save and the type of data.
> (...)
> 276 str: UID of created job where this output was saved
> 277 """
> --> 278 return self.cs.save_external_result(
> 279 self.uid,
> 280 workspace_uid,
> 281 dataset=dataset,
> 282 type=type,
> 283 name=name,
> 284 slots=slots,
> 285 passthrough=passthrough,
> 286 title=title,
> 287 desc=desc,
> 288 )
>
> File ~/.conda/envs/mizimmer/lib/python3.11/site-packages/cryosparc/tools.py:501, in CryoSPARC.save_external_result(self, project_uid, workspace_uid, dataset, type, name, slots, passthrough, title, desc)
> 499 job = self.find_external_job(project_uid, job_uid)
> 500 with job.run():
> --> 501 job.save_output(output, dataset)
> 503 return job.uid
>
> File ~/.conda/envs/mizimmer/lib/python3.11/site-packages/cryosparc/job.py:1323, in ExternalJob.save_output(self, name, dataset, refresh)
> 1302 """
> 1303 Save output dataset to external job.
> 1304
> (...)
> 1320
> 1321 """
> 1322 url = f"/external/projects/{self.project_uid}/jobs/{self.uid}/outputs/{name}/dataset"
> -> 1323 with make_request(self.cs.vis, url=url, data=dataset.stream()) as res:
> 1324 result = res.read().decode()
> 1325 assert res.status >= 200 and res.status < 400, f"Save output failed with message: {result}"
>
> File ~/.conda/envs/mizimmer/lib/python3.11/contextlib.py:137, in _GeneratorContextManager.__enter__(self)
> 135 del self.args, self.kwds, self.func
> 136 try:
> --> 137 return next(self.gen)
> 138 except StopIteration:
> 139 raise RuntimeError("generator didn't yield") from None
>
> File ~/.conda/envs/mizimmer/lib/python3.11/site-packages/cryosparc/command.py:192, in make_request(client, method, url, query, data, headers)
> 189 print(f"*** {type(client).__name__}: ({url}) {error_reason}")
> 190 break
> --> 192 raise CommandClient.Error(client, error_reason, url=url)
>
> Error: *** CommandClient: (http://localhost:39003/external/projects/P30/jobs/J36/outputs/particles/dataset) HTTP Error 422 UNPROCESSABLE ENTITY; please check cryosparcm log command_vis for additional information.
> Response from server: b'Invalid dataset stream'
additionally, for movie exposures, I do:
from cryosparc.tools import CryoSPARC
cs = CryoSPARC(**kwargs)
project1 = cs.find_project("P30")
job1 = project.find_job("J1")
movies = job1.load_output('imported_movies')
new_job = project1.create_external_job("W2", title="import updated movies")
new_job.start()
new_job.save_output("imported_movies", movies)
new_job.stop()
for which I get the following error:
*** CommandClient: (http://localhost:39003/external/projects/P30/jobs/J29/outputs/imported_movies/dataset) URL Error [Errno 32] Broken pipe
Traceback (most recent call last):
File ""
new_job.save_output("imported_movies", movies)
File "/usr/local/ubuntu/.conda/envs/mizimmer/lib/python3.11/site-packages/cryosparc/job.py", line 1323, in save_output
with make_request(self.cs.vis, url=url, data=dataset.stream()) as res:
File "/usr/local/ubuntu/.conda/envs/mizimmer/lib/python3.11/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "/usr/local/ubuntu/.conda/envs/mizimmer/lib/python3.11/site-packages/cryosparc/command.py", line 192, in make_request
raise CommandClient.Error(client, error_reason, url=url)
cryosparc.command.CommandClient.Error: *** CommandClient: (http://localhost:39003/external/projects/P30/jobs/J29/outputs/imported_movies/dataset) URL Error [Errno 32] Broken pipe
In this example, a new job is made in the GUI, but there is no log or additional error.
I am unsure if this is an issue with my networking, or if there is a problem with install/cryosparc save. Thanks in advance for any guidance!