I processed a dataset remotely at the microscope in CS Live, then imported the project locally. Previously I would have updated the symlinks to the exposures and gain file from my session using rtpcli, but I can’t figure out how to do it now. Can anyone give guidance for this?
I was able to get this done using cryosparcm icli with api.projects.symlink:
import os
import time
old_prefix = ‘/my/old/file/prefix’
new_prefix = ‘/my/new/file/prefix’
project_dir = ‘/my/CS/project/dir’
project_number = 'P102' #for example
links = api.projects.get_symlinks(project_number) #my project number
to_fix= [l for l in links if l.target.startswith(old_prefix)]
print(f"Found {len(to_fix)} symlinks to fix")
succeeded = [ ]
failed = [ ]
missing_source = [ ]
start = time.time()
for i, l in enumerate(to_fix, 1):
rel_path = l.path[len(project_dir) + 1:]
new_source = l.target.replace(old_prefix, new_prefix, 1)
if not os.path.exists(new_source):
missing_source.append((l.path, new_source))
continue
try:
os.unlink(l.path) #remove the broken symlink
api.projects.symlink(project_number, source=new_source, path=rel_path) #create the new symlink
succeeded.append(l.path)
except Exception as e:
failed.append((l.path, str(e)))
#update progress, it can take a little while
if i % 500 == 0 or i == len(to_fix):
elapsed = time.time() - start
rate = i / elapsed if elapsed > 0 else 0
print(f"[{i}/{len(to_fix)}] ok={len(succeeded)} failed={len(failed)} missing_source= len(missing_source)} ({rate:.1f}/sec)")
print(“\nDone.”)
print(f"Succeeded: {len(succeeded)}“)
print(f"Failed: {len(failed)}”)
print(f"Missing source (target file doesn’t exist at new path): {len(missing_source)}")
if failed:
print(“\nFirst few failures:”)
for path, err in failed[:5]:
print(f" {path}: {err}")
if missing_source:
print(“\nFirst few missing-source entries (symlink NOT touched, old broken link left in place):”)
for path, src in missing_source[:5]:
print(f" {path} → expected {src}")