Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KrisThielemans opened this issue Oct 9, 2024 · 2 comments

Comments

@KrisThielemans
Copy link
Member

We have

PETRIC/petric.py

Lines 39 to 41 in bbb048f

OUTDIR = Path(f"/o/logs/{TEAM}/{VERSION}" if TEAM and VERSION else "./output")
if not (SRCDIR := Path("/mnt/share/petric")).is_dir():
SRCDIR = Path("./data")

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 #117 (comment)), 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

this_directory = os.path.dirname(__file__)
repo_directory = os.path.dirname(this_directory)
ORG_DATA_PATH = os.path.join(repo_directory, 'orgdata')
DATA_PATH = os.path.join(repo_directory, 'data')

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
Copy link
Member

how about this?

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

@KrisThielemans
Copy link
Member Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants