DiamondLightSource / httomo

High-throughput tomography pipeline
https://diamondlightsource.github.io/httomo/
BSD 3-Clause "New" or "Revised" License
4 stars 3 forks source link

Fix path to YAML templates in YAML checker when YAML templates are eventually copied during installation #335

Closed yousefmoazzam closed 1 month ago

yousefmoazzam commented 1 month ago

Regardless of if/when #300 is done, there is still something else to deal with.

Assume the root directory for the httomo repo being used for the source for an installation is /scratch/user/httomo, and that the root directory for httomo when installed in a conda env is /dls_sw/apps/httomo/2.0.0rc1/lib/python3.10/site-packages/httomo

The YAML checker file yaml_checker.py is in the subdir /scratch/user/httomo/httomo/yaml_checker.py, and the YAML templates when in version control in the repo are in the root directory /scratch/user/httomo/yaml_templates.

When running httomo locally in dev mode, this allows the following code to correctly find the YAML templates dir relative to the yaml_checker.py file: https://github.com/DiamondLightSource/httomo/blob/8b77eb0776b1ae02d4832e5878752051fce1213d/httomo/yaml_checker.py#L347

However, when httomo is installed via pip install or conda install into /dls_sw, the root directory stuff like /scratch/users/httomo/pyproject.toml is not copied to the conda env, only the contents of /scratch/user/httomo/httomo subdir is copied. Hence, the dir for httomo in the conda env has only the contents of /scratch/user/httomo/httomo in /dls_sw/apps/httomo/2.0.0rc1/lib/python3.10/site-packages/httomo.

This means that the only place to copy the YAML templates would be /dls_sw/apps/httomo/2.0.0rc1/lib/python3.10/site-packages/httomo/yaml_templates.

However, notice in that situation, yaml_checker.py are now adjacent to each other rather than yaml_checker.py being in a dir "below" the YAML templates dir.

Ie, compare:

/dls_sw/apps/httomo/2.0.0rc1/lib/python3.10/site-packages/httomo/yaml_checker.py
/dls_sw/apps/httomo/2.0.0rc1/lib/python3.10/site-packages/httomo/yaml_templates

to

/scratch/user/httomo/httomo/yaml_checker.py
/scratch/user/httomo/yaml_templates

and it becomes clearer that their locations relative to each other will change if the YAML templates are copied to the "root httomo dir" in the conda env.

This essentially requires the path of the YAML templates dir in the YAML checker to be changed to:

parent_dir = Path(__file__).parent

and is what was done to hackily install httomo in /dls_sw to make it work

yousefmoazzam commented 1 month ago

One solution to this would be:

Thus, both:

would have the same relative path from yaml_checker.py to the yaml_templates/ dir.