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

CI: Add python formatting to pre-commit and make all files comply #398

Merged
merged 5 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 12 additions & 9 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cvmfs-contrib/github-action-cvmfs@v3.1
- uses: actions/checkout@v4
- uses: cvmfs-contrib/github-action-cvmfs@v4
- uses: aidasoft/run-lcg-view@v4
with:
release-platform: LCG_101/x86_64-centos7-clang12-opt
container: el9
view-path: /cvmfs/sw-nightlies.hsf.org/key4hep
run: |
export PYTHONPATH=$(python -m site --user-site):$PYTHONPATH
export PATH=/root/.local/bin:$PATH
pip install --upgrade --user pip
pip install pre-commit --user
# Use virtualenv from the LCG release
pip uninstall --yes virtualenv
python -m venv /root/pre-commit-venv
source /root/pre-commit-venv/bin/activate
pip install pre-commit
export PYTHONPATH=$VIRTUAL_ENV/lib/python3.$(python3 -c 'import sys; print(f"{sys.version_info[1]}")')/site-packages:$PYTHONPATH
# Newer versions of git are more cautious around the github runner
# environment and without this git rev-parse --show-cdup in pre-commit
# fails
git config --global --add safe.directory $(pwd)
pre-commit run --show-diff-on-failure \
--color=always \
--all-files
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ repos:
rev: v4.5.0
hooks:
- id: check-xml
- repo: local
hooks:
- id: ruff-format
name: ruff-format
entry: ruff format --force-exclude
types: [python]
language: system
10 changes: 10 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
target-version = "py311"
andresailer marked this conversation as resolved.
Show resolved Hide resolved

line-length = 99

[format]
# Make things format the same way as black
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
21 changes: 13 additions & 8 deletions CaloTB/CaloTB_EPT_AHCAL/TBModel2015_steering.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,38 @@
SIM.compactFile = "../../DD4HEP/compact/TBModel2015.xml"
SIM.runType = "batch"
SIM.macroFile = "vis.mac"
#SIM.inputFiles = "mcparticles.slcio"
# SIM.inputFiles = "mcparticles.slcio"
SIM.outputFile = "DD4hep_mu-_8GeV_QGSP_BERT_10k.slcio"

SIM.numberOfEvents = 10000
SIM.skipNEvents = 0
SIM.physicsList = "QGSP_BERT"
SIM.dumpSteeringFile = "TBModel2015_dump.xml"
SIM.enableDetailedShowerMode=True
SIM.enableDetailedShowerMode = True

SIM.random.seed = "0123456789"
SIM.field.eps_min = 1*mm
SIM.part.minimalKineticEnergy = 1*MeV
SIM.field.eps_min = 1 * mm
SIM.part.minimalKineticEnergy = 1 * MeV

SIM.action.calo = "Geant4ScintillatorCalorimeterAction"

## set the particle.tbl file to add extra particles to DDsim (B-Baryons)
## use the power of python to get the file from DD4hep wherever it is
import os
if os.path.exists( os.path.join( os.environ.get("DD4hepINSTALL"), "examples/DDG4/examples/particle.tbl") ):
SIM.physics.pdgfile = os.path.join( os.environ.get("DD4hepINSTALL"), "examples/DDG4/examples/particle.tbl")

if os.path.exists(
os.path.join(os.environ.get("DD4hepINSTALL"), "examples/DDG4/examples/particle.tbl")
):
SIM.physics.pdgfile = os.path.join(
os.environ.get("DD4hepINSTALL"), "examples/DDG4/examples/particle.tbl"
)


SIM.enableGun = True
SIM.gun.particle = "mu-"
SIM.gun.energy = 8*GeV
SIM.gun.energy = 8 * GeV
SIM.gun.position = "0, 0, -1000"
SIM.gun.direction = "0,0,1"

#SIM.gun.isotrop
# SIM.gun.isotrop
SIM.gun.multiplicity = 1
14 changes: 7 additions & 7 deletions CaloTB/run_sim/ddsim_steering_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
SIM.compactFile = "../compact/MainTestBeamSetup.xml"
SIM.dumpSteeringFile = "dumpSteering00.xml"

SIM.field.eps_min = 1*mm
SIM.field.eps_min = 1 * mm

SIM.part.minimalKineticEnergy = 1*MeV
SIM.part.minimalKineticEnergy = 1 * MeV

SIM.physicsList = "QGSP_BERT"
SIM.enableDetailedShowerMode=True

SIM.enableDetailedShowerMode = True

SIM.enableGun = True

SIM.gun.energy = 10*GeV
SIM.gun.energy = 10 * GeV
SIM.gun.particle = "pi+"
#SIM.gun.multiplicity
# SIM.gun.multiplicity
SIM.gun.position = "0,0,-1000"
#SIM.gun.isotrop
# SIM.gun.isotrop
SIM.gun.direction = "0,0,1"
Loading