Skip to content

Setup

This guide will walk you through the process of setting up the Umami-Preprocessing Python package on your system.

Environment Setup#

Creating a virtual environment helps keep your Python environment isolated and organized. While it's not essential, we highly recommend using one. You can set up a virtual environment using either Conda or Python's venv. UPP requires Python 3.8 or later.

Set up a fresh conda or mamba environment:

mamba create -n upp python
mamba activate upp

venv is a lightweight solution for creating virtual python environments, however it is not as fully featured as a fully fledged package manager such as conda. Create a fresh virtual environment and activate it using

python3 -m venv env
source env/bin/activate

If you don't want to use conda environments on lxplus, you can setup python via

setupATLAS
lsetup "python 3.9.18-x86_64-el9"

You can also set up conda on lxplus

PyPi installation#

A simple installation can be done via pip from Python Packade Index:

python -m pip install umami-preprocessing

On lxplus you may have to use python3

After this installation all the fuctionality for the user is available. The further steps are only useful for the development of the package.

Get the code#

Start by cloning the Umami-Preprocessing repository and navigating into the project directory using the following commands in your terminal:

git clone https://github.com/umami-hep/umami-preprocessing.git
cd umami-preprocessing

Install package from code#

Install the package as in editable mode if you would like to develop the code:

python -m pip install -e .[dev]

Or do a simple installation if you only plan to use the provided functionality as is

python -m pip install .

Note for running on lxplus

Again, you may have to use python3 here.

You may also see a warning like this:

WARNING: The script preprocess is installed in '/afs/cern.ch/user/X/Y/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

if you do, you can add the directory to your path using

export PATH=$PATH:/afs/cern.ch/user/X/Y/.local/bin

Alternatively, you can just run the scripts by pointing to the main.py

python3 upp/main.py

Run the tests (Optional)#

To ensure that the package is working correctly, you can run tests using the pytest framework. Additionally, you can install coverage to generate a coverage report.

Use pytest to run the tests to make sure the package works

pytest tests 

If you want to measure test coverage, first install coverage, and then run tests as follows:

coverage run --source upp -m pytest tests --show-capture=stdout
coverage report 

Last update: April 9, 2024
Created: April 9, 2024