Skip to content

Commit

Permalink
Merge branch 'main' of github.com:acts-project/acts into feat-actuall…
Browse files Browse the repository at this point in the history
…y-estimate-params-at-surface
  • Loading branch information
andiwand committed Nov 22, 2024
2 parents 5a9eb62 + edad4c9 commit e5b7a35
Show file tree
Hide file tree
Showing 422 changed files with 7,157 additions and 4,125 deletions.
4 changes: 4 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ DO NOT USE @-MENTIONS HERE!
--- END COMMIT MESSAGE ---

Any further description goes here, @-mentions are ok here!

- Use a *conventional commits* prefix: [quick summary](https://www.conventionalcommits.org/en/v1.0.0/#summary)
- We mostly use `feat`, `fix`, `refactor`, `docs`, `chore` and `build` types.
- A milestone will be assigned by one of the maintainers
12 changes: 11 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ jobs:
- name: Check
run: >
CI/check_spelling
math_macros:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Check
run: >
CI/check_math_macros.py . --exclude "thirdparty/*"
missing_includes:
runs-on: ubuntu-latest
steps:
Expand All @@ -135,7 +145,7 @@ jobs:
python-version: '3.12'
- name: Install dependencies
run: >
pip install -r CI/requirements_fpe_masks.txt
pip install -r CI/fpe_masks/requirements.txt
- name: Check
run: >
CI/check_fpe_masks.py --token ${{ secrets.GITHUB_TOKEN }}
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/milestone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Check PR milestone

on:
pull_request_target:
types: [milestoned, demilestoned, opened, reopened]
branches:
- main

jobs:
check_milestone:
if: ${{ github.event.issue.pull_request || github.event.pull_request }}

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: "Check for milestone on PR"
uses: actions/github-script@v7
with:
script: |
let milestone = context.payload.pull_request.milestone;
if(context.payload.action === 'opened' || context.payload.action === 'reopened') {
if(milestone !== null) {
core.notice(`Milestone is ${milestone.title}`);
} else {
const milestones = await github.rest.issues.listMilestones({
owner: context.repo.owner,
repo: context.repo.repo,
state: "open"
});
for (const default_milestone of milestones.data) {
if (default_milestone.title === "next") {
core.notice(`No milestone set, setting default milestone: ${default_milestone.title}`);
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
milestone: default_milestone.number
});
return;
}
}
core.warning("Could not find default milestone named 'next'");
}
}
else {
if(milestone !== null) {
core.notice(`Milestone is ${milestone.title}`);
} else {
core.setFailed("No milestone: Please add a version milestone");
}
}
76 changes: 76 additions & 0 deletions .github/workflows/update-pip-requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Update Pip Requirements

on:
workflow_dispatch: # Allow running on-demand
schedule:
# Runs every Sunday at 1:23 UTC
- cron: '23 1 * * 0'

jobs:
update-pip-requirements:
# This action checks all monitored (specified in `folder_list` below) requirements.in
# files and generates a new requirements.txt file with pip-compile. If any
# requirements changed, a PR is created with the changes.
runs-on: ubuntu-latest
env:
# This branch will receive updates each time the workflow runs
# It doesn't matter if it's deleted when merged, it'll be re-created
BRANCH_NAME: auto-dependency-upgrades
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install pip-tools
run: pip install pip-tools

- name: Compile all requirements.txt
run: |
# Update this list after adding/removing requirements-files
folder_list=(
CI/clang_tidy
CI/fpe_masks
docs
Examples/Python/tests/
Examples/Scripts
)
for folder in "${folder_list[@]}"; do
pip-compile "${folder}/requirements.in" > "${folder}/requirements.txt"
done
- name: Detect changes
id: changes
run:
# This output boolean tells us if the dependencies have actually changed
echo "count=$(git status --porcelain=v1 2>/dev/null | wc -l)" >> $GITHUB_OUTPUT

- name: Commit & push changes
# Only push if changes exist
if: steps.changes.outputs.count > 0
run: |
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Weekly Update: Regenerate requirements.txt"
git push -f origin ${{ github.ref_name }}:$BRANCH_NAME
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Open pull request if needed
if: steps.changes.outputs.count > 0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Only open a PR if the branch is not attached to an existing one
run: |
PR=$(gh pr list --head $BRANCH_NAME --json number -q '.[0].number')
if [ -z $PR ]; then
gh pr create \
--head $BRANCH_NAME \
--title "chore: automated python requirements upgrades" \
--body "Full log: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
else
echo "Pull request already exists, won't create a new one."
fi
4 changes: 1 addition & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ clang_tidy:
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_C_COMPILER=clang
-DPython_EXECUTABLE=$(which python3)
-DACTS_RUN_CLANG_TIDY=ON
-DACTS_BUILD_ODD=OFF
# Main clang-tidy run during cmake compilation
- CI/clang_tidy/run_clang_tidy.sh clang-tidy build
Expand Down Expand Up @@ -168,7 +166,7 @@ build_exatrkx:
# - git clone $CLONE_URL src
# - cd src
# - git checkout $HEAD_SHA
# - pip3 install -r Examples/Python/tests/requirements_ubuntu2004.txt
# - pip3 install -r Examples/Python/tests/requirements.txt
# - nvidia-smi
# - pytest -rFsv -k test_exatrkx

Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ repos:
name: Leftover conflict markers
language: system
entry: git diff --staged --check

- repo: local
hooks:
- id: math_macros
name: math_macros
language: system
entry: CI/check_math_macros.py
files: \.(cpp|hpp|ipp|cu|cuh)$
6 changes: 5 additions & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@
"affiliation": "CERN / University of Amsterdam",
"name": "Stephen Nicholas Swatman",
"orcid": "0000-0002-3747-3229"
}
},
{
"affiliation": "CERN / TU Wien",
"name": "Felix Russo",
"orcid": "0009-0005-8975-2245"
},
{
"affiliation": "UC Berkeley",
"name": "Carlo Varni"
}
],
"access_right": "open",
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ The following people have contributed to the project (in alphabetical order):
- Andreas Stefl, CERN, TU Wien
- Stephen Nicholas Swatman, CERN, University of Amsterdam
- Roman Urmanov, Weizmann Institute of Science
- Carlo Varni, UC Berkeley
120 changes: 120 additions & 0 deletions CI/check_math_macros.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/env python3

from pathlib import Path
import os
import argparse
from fnmatch import fnmatch
import re
import sys


math_constants = [
("M_PI", "std::numbers::pi"),
("M_PI_2", "std::numbers::pi / 2."),
("M_PI_4", "std::numbers::pi / 4."),
("M_1_PI", "std::numbers::inv_pi"),
("M_2_PI", "2. * std::numbers::inv_pi"),
("M_2_SQRTPI", "2. * std::numbers::inv_sqrtpi"),
("M_E", "std::numbers::e"),
("M_LOG2E", "std::numbers::log2e"),
("M_LOG10E", "std::numbers::log10e"),
("M_LN2", "std::numbers::ln2"),
("M_LN10", "std::numbers::ln10"),
("M_SQRT2", "std::numbers::sqrt2"),
("M_SQRT1_2", "1. / std::numbers::sqrt2"),
("M_SQRT3", "std::numbers::sqrt3"),
("M_INV_SQRT3", "std::numbers::inv_sqrt3"),
("M_EGAMMA", "std::numbers::egamma"),
("M_PHI", "std::numbers::phi"),
]


github = "GITHUB_ACTIONS" in os.environ


def handle_file(
file: Path, fix: bool, math_const: tuple[str, str]
) -> list[tuple[int, str]]:
ex = re.compile(rf"(?<!\w){math_const[0]}(?!\w)")

content = file.read_text()
lines = content.splitlines()

changed_lines = []

for i, oline in enumerate(lines):
line, n_subs = ex.subn(rf"{math_const[1]}", oline)
lines[i] = line
if n_subs > 0:
changed_lines.append((i, oline))

if fix and len(changed_lines) > 0:
file.write_text("\n".join(lines) + "\n")

return changed_lines


def main():
p = argparse.ArgumentParser()
p.add_argument("input", nargs="+")
p.add_argument("--fix", action="store_true", help="Attempt to fix M_* macros.")
p.add_argument("--exclude", "-e", action="append", default=[])

args = p.parse_args()

exit_code = 0

inputs = []

if len(args.input) == 1 and os.path.isdir(args.input[0]):
# walk over all files
for root, _, files in os.walk(args.input[0]):
root = Path(root)
for filename in files:
# get the full path of the file
filepath = root / filename
if filepath.suffix not in (
".hpp",
".cpp",
".ipp",
".h",
".C",
".c",
".cu",
".cuh",
):
continue

if any([fnmatch(str(filepath), e) for e in args.exclude]):
continue

inputs.append(filepath)
else:
for file in args.input:
inputs.append(Path(file))

for filepath in inputs:
for math_const in math_constants:
changed_lines = handle_file(
file=filepath, fix=args.fix, math_const=math_const
)
if len(changed_lines) > 0:
exit_code = 1
print()
print(filepath)
for i, oline in changed_lines:
print(f"{i}: {oline}")

if github:
print(
f"::error file={filepath},line={i+1},title=Do not use macro {math_const[0]}::Replace {math_const[0]} with std::{math_const[1]}"
)

if exit_code == 1 and github:
print(f"::info You will need in each flagged file #include <numbers>")

return exit_code


if "__main__" == __name__:
sys.exit(main())
20 changes: 10 additions & 10 deletions CI/clang_tidy/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@
#
# pip-compile CI/clang_tidy/requirements.in
#
annotated-types==0.6.0
annotated-types==0.7.0
# via pydantic
appdirs==1.4.4
# via fs
codereport==0.3.2
codereport==0.4.0
# via -r CI/clang_tidy/requirements.in
fs==2.4.16
# via codereport
jinja2==3.1.2
jinja2==3.1.4
# via codereport
markdown-it-py==3.0.0
# via rich
markupsafe==2.1.3
markupsafe==3.0.2
# via jinja2
mdurl==0.1.2
# via markdown-it-py
pydantic==2.5.2
pydantic==2.9.2
# via -r CI/clang_tidy/requirements.in
pydantic-core==2.14.5
pydantic-core==2.23.4
# via pydantic
pygments==2.17.2
pygments==2.18.0
# via
# codereport
# rich
python-slugify==6.1.2
# via codereport
pyyaml==6.0.1
pyyaml==6.0.2
# via -r CI/clang_tidy/requirements.in
rich==13.7.0
rich==13.9.4
# via -r CI/clang_tidy/requirements.in
six==1.16.0
# via fs
text-unidecode==1.3
# via python-slugify
typing-extensions==4.8.0
typing-extensions==4.12.2
# via
# pydantic
# pydantic-core
Expand Down
File renamed without changes.
Loading

0 comments on commit e5b7a35

Please sign in to comment.