SyneRBI / PETRIC

PET Image Reconstruction Challenge 2024
https://www.ccpsynerbi.ac.uk/events/petric/
8 stars 2 forks source link

SRCDIR, OUTDIR in petric.py when running SIRF_data_preparation functionality #128

Open KrisThielemans opened 1 week ago

KrisThielemans commented 1 week ago

We have https://github.com/SyneRBI/PETRIC/blob/bbb048f7e56385512332bed080edf02a2137dbfe/petric.py#L39-L41 this means that whenever we run many of the utilities in SIRF_data_preparation, we will get an output folder from wherever we run it. That folder will often contain Tensorboard stuff (due to https://github.com/SyneRBI/PETRIC/issues/117#issuecomment-2403422102), but also the OSEM/BSREM reconstructions. It means I have to hunt for where everything is, unless I make sure everything gets always run from the same cwd.

As opposed to using relative directories, I suggest we follow the "relative to repo" strategy https://github.com/SyneRBI/PETRIC/blob/bbb048f7e56385512332bed080edf02a2137dbfe/SIRF_data_preparation/data_utilities.py#L18-L21 for SRCDIR and OUTDIR.

Note however that this means the SRCDIR will likely always exist, and therefore importing petric.py is quite slow #117

casperdcl commented 1 week ago

how about this?

OUTDIR = Path(os.getenv("PETRIC_OUTDIR", f"/o/logs/{TEAM}/{VERSION}" if TEAM and VERSION else "./output"))
KrisThielemans commented 1 week ago

I find the "current directory" strategy very brittle. It is there for running things outside the runner, but it is surprising. It also applies to SRCDIR.

repo_directory = os.path.dirname(__file__) 
OUTDIR = Path(os.getenv("PETRIC_OUTDIR", 
                                          f"/o/logs/{TEAM}/{VERSION}" if TEAM and VERSION else os.path.join(repo_directory, "output"))
if not (SRCDIR := Path("/mnt/share/petric")).is_dir(): 
     SRCDIR = Path(os.path.join(repo_directory, "./data"))
SRCDIR = Path(os.getenv("PETRIC_SRCDIR", str(SRCDIR))

Of course, then we need to adapt data_utilities to use petric.SRCDIR etc (and I guess use the same strategy for data_utilities.ORG_DATA_PATH).