Test possible bugs with --overwrite flag & possibly default to clearing old outputs until this is resolved
Opened this issue · 3 comments
What happened?
I was debugging by running the application and had produced all of the prebibsnet outputs up until the point that the prebibsnet output anatomicals are copied into the bibsnet input folder. I ran the application again using the --overwrite
flag (for reasons that aren't relevant here) and it errored at https://github.com/DCAN-Labs/CABINET/blob/main/run.py#L666 because the output file didn't exist yet from the prior run, so when it tries to remove it there is a file not found error
I would suggest that we only run the copy command whether the file exists or not (if it doesn't exist, it will create it and if it does exist from a prior run, it will be overwritten).
So replace:
if j_args["common"]["overwrite"]: # TODO Should --overwrite delete old image file(s)?
os.remove(out_nii_fpath)
if not os.path.exists(out_nii_fpath):
shutil.copy2(transformed_images[f"T{t}w"], out_nii_fpath)
with:
if j_args["common"]["overwrite"]: # TODO Should --overwrite delete old image file(s)?
shutil.copy2(transformed_images[f"T{t}w"], out_nii_fpath)
We'll also want to look through the rest of the code base to make sure this issue doesn't exist elsewhere
What command did you use?
not relevant - logic is apparent in code
What version of CABINET are you using?
2.4.0
Relevant log output
No response
Add any additional information or context about the problem here.
No response
I believe I ran into a similar problem when using the overwrite flag. My command worked without it, but failed with the overwrite flag.
Command that works
singularity run --nv --cleanenv --no-home -B $path/BIBSnet_inputs/:/input -B $path/BIBSnet_outputs:/output $path/infant/BIBSnet/bibsnet.sif /input /output participant -v --participant-label $subnum -z
Command that does not work
singularity run --nv --cleanenv --no-home -B $path/BIBSnet_inputs/:/input -B $path/BIBSnet_outputs:/output $path/infant/BIBSnet/bibsnet.sif /input /output participant -v --participant-label $subnum -z --overwrite
Error
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/bibsnet/bibsnet/sub-019/ses-01/input/sub-019_ses-01_optimal_resized_0000.nii.gz'