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

Add validation installation to the just commands and rename the dir #1441

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 9 additions & 25 deletions Validation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,10 @@ Python package focused on comparing two or more "similar" LDMX event or histogra
One may use this python module either inside or outside the ldmx-sw development container.

### Inside `ldmx`
Since the environment inside of the container is a bit more restrictive, we need to
specifically tell `pip` some extra information that it cannot deduce on its own.
Run the dedicated `just` command to install
```
ldmx python3 -m pip install Validation/ \
--upgrade \
--target install/python/ \
--no-cache
just install-validation
```
`python3 -m pip install Validation/` is the standard `pip` install method.
We add `--upgrade` to tell `pip` it should overwrite the package if it already has been
installed before which is helpful in the case where someone is updating the code and running
the new code within the container. The `--target install/python/` arguments tell `pip`
where to install the package. This directory is where we currently store our python modules
and is where the container expects them to be. The `--no-cache` argument tells `pip` to
not use a cache for downloading any dependencies from the internet which is necessary since
`pip` will not be able to write to the cache location within the container.

### Outside `ldmx`
Outside container it is helpful to put the Validation module inside a virtual environment.
Expand All @@ -44,39 +32,35 @@ Using Validation without a virtual environment and outside of the container is n


## Usage
This module _cannot_ be run from ldmx-sw directory.
`import Validation` prefers the local directory instead of the installed path so it tries to
load from the `ldmx-sw/Validation` directory.

We could fix this by renaming the package inside Validation or renaming the directory.

### CLI
The Validation module is constructed to do some common tasks quickly on the command line.
Printing out its help message shows how to run it and gives you the details on what
parameters to provide.
```
python3 -m Validation -h
cd Validation/src
denv python3 -m Validate -h
tvami marked this conversation as resolved.
Show resolved Hide resolved
```
which should be run with `ldmx` if the module was installed in the container.

For example if you would like to compare the ECAL shower features, put the input histograms into a directory,
e.g. `compareDir` with names that are separated with an underscore, e.g. `histo_new.root` and `histo_ref.root`,
then run the following command.
```
ldmx python3 -m Validation compareDir/ --systems ecal.shower_feats
denv python3 -m Validate compareDir/ --systems ecal.shower_feats
```
This will produce plots in the `compareDir` directory and will include "new" and "ref" in the plot legend.

### In Script
Similar to the CLI, you can develop your own python script using Validation.
Simply `import Validation` where you want to be using it.
Similar to the CLI, you can develop your own python script using Validate.
Simply `import Validate` where you want to be using it.
**Remember**: The plotting functions assume the user is in an interactive notebook
unless the `out_dir` parameter is provided.

### In Notebook
Again, accessing this module post-installation is the same as other modules `import Validation`.
Again, accessing this module post-installation is the same as other modules `import Validate`.
This can help you develop plots that don't come pre-made within the Validation module.
**If you are developing Validation and testing within a notebook**, you will need to reboot
**If you are developing Validate and testing within a notebook**, you will need to reboot
the python kernel anytime you wish to test changes to the Validation module. This is necessary
because Jupyter keeps modules cached in memory during normal running in order to save time
when re-executing cells with `import` statements.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,15 @@ compile ncpu=num_cpus() *CONFIG='': (configure CONFIG) (build ncpu)

# re-build ldmx-sw and then run a config
recompFire config_py *ARGS: build (fire config_py ARGS)

# install the validation module
# `python3 -m pip install Validation/` is the standard `pip` install method.
# We add `--upgrade` to tell `pip` it should overwrite the package if it already has been
# installed before which is helpful in the case where someone is updating the code and running
# the new code within the container. The `--target install/python/` arguments tell `pip`
# where to install the package. This directory is where we currently store our python modules
# and is where the container expects them to be. The `--no-cache` argument tells `pip` to
# not use a cache for downloading any dependencies from the internet which is necessary since
# `pip` will not be able to write to the cache location within the container.
tvami marked this conversation as resolved.
Show resolved Hide resolved
install-validation:
denv python3 -m pip install Validation/ --upgrade --target install/python/ --no-cache
Loading