DCAN-Labs / DCAN-Labs/BIBSnet

Test possible bugs with --overwrite flag & possibly default to clearing old outputs until this is resolved

Open
#44 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
13
Forks
11
Avg merge
1m
Merged PRs (30d)
1

Description

### 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?

```shell
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_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.