Skip to main content

law logo

Documentation status CI Docker images Python version Package version License DOI

Use law (luigi analysis workflow) to build complex and large-scale task workflows. It is built on top of luigi and adds abstractions for run locations, storage locations and software environments. Law strictly disentangles these building blocks and ensures they remain interchangeable and resource-opportunistic.

Key features:

  • CLI with auto-completion and interactive status and dependency inspection
  • Remote targets with automatic retries and local caching
    • WebDAV, HTTP, Dropbox, SFTP, all WLCG protocols (srm, xrootd, dcap, gsiftp, webdav, ...)
  • Automatic submission to batch systems from within tasks
    • HTCondor, LSF, gLite, ARC, Slurm, CMS-CRAB
  • Environment sandboxing, configurable on task level
    • Docker, Singularity, Sub-Shells, Virtual envs

Version 0.1 (with Python support down to 2.7) continues to be available via the v0.1.x branch and all v0.1.* tags.

Contents

First steps

Installation and dependencies

Install via pip

pip install law

or conda / (micro)mamba

conda install -c conda-forge law

Remote targets use gfal2 and its Python bindings gfal2-python, which must be installed separately. The gfal2-util command-line tools are useful as well.

conda install -c conda-forge gfal2 gfal2-python gfal2-util

Usage at CERN

See the wiki.

Overcomplete example config

See law.cfg.example.

Projects using law

  • CMS Di-Higgs Inference Tools
    • Basis for statistical analysis for all Di-Higgs searches in CMS, starting at datacard-level
    • repo, docs
  • columnflow (+ all analyses using it)
    • Python-based, fully automated, columnar framework, including job submission, resolution of systematics and ML pipelines, starting at NanoAOD-level with an optimized multi-threaded column reader
    • repo, docs, task structure
  • CMS B-Tag SF Measurement
    • Automated workflow for deriving shape-calibrating b-tag scale factors, starting at MiniAOD-level
    • repo
  • CMS Tau POG ML Tools
    • Preprocessing pipeline for ML trainings in the TAU group
    • repo
  • CMS HLT Config Parser
    • Collects information from various databases (HLT, bril, etc.) and shows menus, trigger paths, filter names for configurable MC datasets or data runs
    • repo
  • RWTH-CMS Analysis Framework
    • Basis for multiple CMS analyses ranging from Di-Higgs, to single Higgs and b-tag SF measurements, starting at NanoAOD-level and based on coffea processors
    • repo
  • CIEMAT-CMS Analysis Framework
    • Python- and RDataFrame-based framework starting from NanoAOD and targeting multiple CMS analyses
    • repo
  • CMS 3D Z+jet 13 TeV analysis
    • Analysis workflow management from ntuple production to final plots and fits
    • repo
  • NP-correction derivation tool
    • MC generation with Herwig and analysis of generated events with Rivet
    • repo
  • CMS SUSY Searches at DESY
    • Analysis framework for CMS SUSY searches going from custom NanoAODs -> ntuple production -> DNN-based inference -> final plots and fits
    • repo
  • Kingmaker (CMS ntuple production with CROWN)
    • Conversion from CMS NanoAOD to analysis ntuples using the CROWN framework. Also includes the training of an event classifier on those ntuples.
    • repo, CROWN

If your project uses law but is not yet listed here, feel free to open a pull request or mention your project details in a new issue and it will be added.

Examples

Most examples can be run in a dedicated Docker container via

docker run -ti riga/law:example <example_name>

Further topics

Auto completion on the command-line

bash

source "$( law completion )"

zsh

zsh is able to load and evaluate bash completion scripts via bashcompinit. In order for bashcompinit to work, you should run compinstall to enable completion scripts:

autoload -Uz compinstall && compinstall

After following the instructions, these lines should be present in your ~/.zshrc:

# The following lines were added by compinstall
zstyle :compinstall filename '~/.zshrc'

autoload -Uz +X compinit && compinit
autoload -Uz +X bashcompinit && bashcompinit
# End of lines added by compinstall

If this is the case, just source the law completion script (which internally enables bashcompinit) and you're good to go:

source "$( law completion )"

Development

  • Source hosted at GitHub
  • Report issues, questions, feature requests on GitHub Issues
  • The current Python version for development is 3.13.

Linting, type checking & tests

The full testing pipeline is based on pre-commit. Run the following to install development dependencies and set it up:

# inside the cloned repository
git lfs install
pip install -e .[dev,test]
pre-commit install

Now, every time you make a commit, the pre-commit and pre-push hooks will automatically run linting, type checking and unit tests. To run them manually, use

# for linting, type checking and additional checks on all files
pre-commit run --all-files

# only for staged files
pre-commit run

# or run unit tests standalone
pytest

Docker images

Various riga/law Docker images are available on Docker Hub, corresponding to different OS and Python versions (based on micromamba).

OS Python Tags
AlmaLinux 9 3.14 a9-py314, py314
AlmaLinux 9 3.13 a9-py313, a9-py3, a9, py313, py3, latest
AlmaLinux 9 3.12 a9-py312, py312
AlmaLinux 9 3.11 a9-py311, py311
AlmaLinux 9 3.10 a9-py310, py310
AlmaLinux 9 3.9 a9-py39, py39

Start them via

docker run -ti riga/law:<the_tag>

Contributors

Marcel Rieger
Marcel Rieger

💻 👀 🚧 📖
Peter Fackeldey
Peter Fackeldey

💻
Yannik Rath
Yannik Rath

💻
Jaime Leon Holgado
Jaime Leon Holgado

💻
Louis Moureaux
Louis Moureaux

💻
Lukas Geiger
Lukas Geiger

💻
Valentin Iovene
Valentin Iovene

💻
Cedric Verstege
Cedric Verstege

💻

This project follows the all-contributors specification.

Cite law

M. Rieger, "End-to-End Analysis Automation over Distributed Resources with Luigi Analysis Workflows", EPJ Web of Conferences 295 (2024) 05012, arXiv:2402.17949

Metadata

Release files for law 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for law 0.2.1
File Size Uploaded Provenance Actions
law-0.2.1.tar.gz 455.8 kB Without provenance Details for law-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for law 0.2.1
File Interpreter ABI Platform Actions
law-0.2.1-py3-none-any.whl Python 3 none any Details for law-0.2.1-py3-none-any.whl

Total release size: 915.1 kB

Release files / law-0.2.1.tar.gz

Download URL law-0.2.1.tar.gz
Size 455.8 kB
Tags Source
SHA-256 checksum
How to use checksums
fd09eed70cb324db2e170ade8578b18969b7684712b86b7798152a641aa8ff67
BLAKE2b-256 checksum
How to use checksums
b315c9e64a04959476cec77038c44699db795058c1490f3e020da2a75d2026f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / law-0.2.1-py3-none-any.whl

Download URL law-0.2.1-py3-none-any.whl
Size 459.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41850eb62d2c576f3d714ff3c97e28a2783813f349d245dd6a26428adf4090fe
BLAKE2b-256 checksum
How to use checksums
073fc4a66fc886dfb804f685dd572b6c4b09c9dc2657dae428f517e38426931c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for law 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page