|
| 1 | +# Python Packages |
| 2 | + |
| 3 | +Many Python packages are useful for late stage analysis of data, |
| 4 | +so many are included within this image to make them readily available |
| 5 | +for downstream LDMX collaborators. |
| 6 | + |
| 7 | +## Do you need to use ldmx/dev? |
| 8 | +If you are just using Python and supporting libraries (like `uproot`, `awkward`, and `hist`) |
| 9 | +for your analysis, then you do not need to use this large and heavy image. |
| 10 | +Instead, it is recommended for you to craft your own environment which is lighter (making |
| 11 | +it easier to reproduce and move around clusters) and more nimble (allowing you to upgrade |
| 12 | +packages if you want to). |
| 13 | + |
| 14 | +``` |
| 15 | +cd my-analysis |
| 16 | +denv init python:3.12 # choose python version |
| 17 | +denv pip install scikit-hep # install packages you need |
| 18 | +denv pip freeze > requirements.txt # write packages you've used for later reproducibility |
| 19 | +git add requirements.txt .denv/config # store the configuration in git with your analysis code |
| 20 | +``` |
| 21 | + |
| 22 | +Then, using the code in `my-analysis` on any other computer with `denv` installed would |
| 23 | +get started by |
| 24 | + |
| 25 | +``` |
| 26 | +git clone git@github.com:my-username/my-analysis.git |
| 27 | +cd my-analysis |
| 28 | +denv pip install -r requirements.txt |
| 29 | +``` |
| 30 | +No `denv init` is required since the `.denv/config` is present in the `my-analysis` git repository. |
| 31 | + |
| 32 | +~~~admonish tip title="Necessity of the ldmx/dev Image" |
| 33 | +The only time you **need** to use the Python packages within the ldmx/dev image |
| 34 | +is if you are using PyROOT (`import ROOT`) or the ldmx-sw ROOT dictionary. |
| 35 | +If you use the `scikit-hep` libraries, then you can move to this more nimble |
| 36 | +workflow. |
| 37 | +~~~ |
| 38 | + |
| 39 | +## What's installed? |
| 40 | +Many python packages evolve at a faster rate than we build the ldmx/dev image, |
| 41 | +so many of the packages installed within the ldmx/dev image will be behind what has |
| 42 | +been most recently released. |
| 43 | + |
| 44 | +You can get the full list and specific versions of the Python packages installed |
| 45 | +within your ldmx/dev image by running `denv pip freeze`. |
| 46 | +The table below is just documentation of the packages we request to be installed |
| 47 | +and not the full dependency tree. |
| 48 | + |
| 49 | +- `scikit-hep` |
| 50 | + - Meta-package holding [scikit-hep](https://scikit-hep.org/) libraries |
| 51 | + - Includes (among others) `uproot`, `mplhep`, `hist`, `awkward`, `pandas`, `vector`, and `pylhe` |
| 52 | +- `pyhepmc` |
| 53 | + - IO for the HEPMC data format |
| 54 | +- `pip`, `wheel`, `setuptools` |
| 55 | + - Helpful for packaging and downstream upgrading |
| 56 | +- `Cython` |
| 57 | + - Write C extensions for Python |
| 58 | +- `numba` |
| 59 | + - Pre-compile Python functions for performance improvements |
| 60 | +- `scikit-learn`, `xgboost` |
| 61 | + - Machine Learning libraries |
| 62 | + |
| 63 | + |
0 commit comments