Skip to content

Commit

Permalink
Merge branch 'acts-project:main' into alignment_group
Browse files Browse the repository at this point in the history
  • Loading branch information
LaraCalic authored Dec 2, 2023
2 parents 1a3eb5e + 81351f1 commit a9ae0b3
Show file tree
Hide file tree
Showing 349 changed files with 4,369 additions and 3,408 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,13 @@ jobs:
- name: Check
run: >
CI/check_fpe_masks.py --token ${{ secrets.GITHUB_TOKEN }}
unused_files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Check
run: >
CI/check_unused_files.py
7 changes: 6 additions & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"name": "Xiaocong Ai"
},
{
"affiliation": "Universitaet Freiburg",
"affiliation": "Universitaet Regensburg",
"name": "Benjamin Huth"
},
{
Expand Down Expand Up @@ -113,6 +113,11 @@
"name": "Stephen Nicholas Swatman",
"orcid": "0000-0002-3747-3229"
}
{
"affiliation": "CERN / TU Wien",
"name": "Felix Russo",
"orcid": "0009-0005-8975-2245"
}
],
"access_right": "open",
"related_identifiers": [
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The following people have contributed to the project (in alphabetical order):
- Fabian Klimpel, CERN
- Robert Langenberg, UMass
- Alexander J. Pfleger, CERN, University of Graz
- Felix Russo, CERN, TU Wien
- Andreas Salzburger, CERN
- Bastian Schlag, CERN, JGU Mainz
- Andreas Stefl, CERN, TU Wien
Expand Down
228 changes: 228 additions & 0 deletions CI/check_unused_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
#!/usr/bin/env python3

from pathlib import Path
import os
import sys
import subprocess


def file_can_be_removed(searchstring, scope):
cmd = "grep -IR '" + searchstring + "' " + " ".join(scope)

p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
output, _ = p.communicate()
return output == b""


def count_files(path=".", exclude_dirs=(), exclude_files=()):
count = 0
for root, dirs, files in os.walk(path):
dirs[:] = [d for d in dirs if d not in exclude_dirs]
files[:] = [f for f in files if f not in exclude_files]
count += len(files)

return count


def main():
print("\033[32mINFO\033[0m Start check_unused_files.py ...")
exclude_dirs = (
"Scripts",
"thirdparty",
"CI",
"git",
"cmake",
".git",
".github",
".",
".idea",
)
exclude_files = (
"acts_logo_colored.svg",
".gitignore",
"README.md",
"CMakeLists.txt",
"DetUtils.h",
"CommandLineArguments.h",
# Filename not completed in source
"vertexing_event_mu20_beamspot.csv",
"vertexing_event_mu20_tracks.csv",
"vertexing_event_mu20_vertices_AMVF.csv",
# TODO Move the following files to a better place?
"Magfield.ipynb",
"SolenoidField.ipynb",
# TODO Add README next to the following files?
"default-input-config-generic.json",
"geoSelection-openDataDetector.json",
"alignment-geo-contextualDetector.json",
)

suffix_header = (
".hpp",
".cuh",
)
suffix_source = (
".ipp",
".cpp",
".cu",
)
suffix_image = (
".png",
".svg",
".jpg",
".gif",
)
suffix_python = (".py",)
suffix_doc = (
".md",
".rst",
)
suffix_other = (
"",
".csv",
".css",
".gdml",
".hepmc3",
".in",
".ipynb",
".json",
".j2",
".onnx",
".root",
".toml",
".txt",
".yml",
)
suffix_allowed = (
suffix_header
+ suffix_source
+ suffix_image
+ suffix_python
+ suffix_doc
+ suffix_other
)

exit = 0

dirs_base = next(os.walk("."))[1]
dirs_base[:] = [d for d in dirs_base if d not in exclude_dirs]
dirs_base_docs = ("docs",)
dirs_base_code = [d for d in dirs_base if d not in dirs_base_docs]

# Collectors
wrong_extension = ()
unused_files = ()

# walk over all files
for root, dirs, files in os.walk("."):
dirs[:] = [d for d in dirs if d not in exclude_dirs]
files[:] = [f for f in files if f not in exclude_files]

# Skip base-directory
if str(Path(root)) == ".":
continue

# Print progress
if root[2:] in dirs_base:
processed_files = 0
current_base_dir = root
number_files = count_files(root, exclude_dirs, exclude_files)
# print empty to start a new line
print("")

# Skip "white-paper-figures"
# TODO Find a more elegant way
if str(root).find("white_papers/figures") != -1:
processed_files += count_files(root, exclude_dirs, exclude_files)
continue

# Skip "DD4hep-tests" since their cmake looks a bit different
# TODO Find a more elegant way
if str(root).find("Tests/UnitTests/Plugins/DD4hep") != -1:
processed_files += count_files(root, exclude_dirs, exclude_files)
continue

root = Path(root)
for filename in files:
processed_files += 1
# get the full path of the file
filepath = root / filename

# Check for wrong extensions
if filepath.suffix not in suffix_allowed:
wrong_extension += (str(filepath),)

# Check header files and remove
if filepath.suffix in suffix_header + suffix_source:
if file_can_be_removed(filepath.stem, dirs_base_code):
unused_files += (str(filepath),)
remove_cmd = "rm " + str(filepath)
os.system(remove_cmd)

# TODO Find test to check python files
if filepath.suffix in suffix_python:
continue

# Check documentation files (weak tests)
# TODO find more reliable test for this
if filepath.suffix in suffix_doc:
if file_can_be_removed(filepath.stem, dirs_base_docs):
unused_files += (str(filepath),)
remove_cmd = "rm " + str(filepath)
os.system(remove_cmd)

# Check and print other files
if filepath.suffix in suffix_image + suffix_other:
if file_can_be_removed(filename, dirs_base):
unused_files += (str(filepath),)
remove_cmd = "rm " + str(filepath)
os.system(remove_cmd)

# Print the progress in place
progress = int(20 * processed_files / number_files)
sys.stdout.write("\r")
sys.stdout.write(
"Checked [%-20s] %d/%d files in %s"
% ("=" * progress, processed_files, number_files, current_base_dir)
)
sys.stdout.flush()

if len(wrong_extension) != 0:
print(
"\n\n\033[31mERROR\033[0m "
+ f"The following {len(wrong_extension)} files have an unsupported extension:\n\n"
+ "\033[31m"
+ "\n".join(wrong_extension)
+ "\033[0m"
+ "\nCheck if you can change the format to one of the following:\n"
+ "\n".join(suffix_allowed)
+ "\nIf you really need that specific extension, add it to the list above.\n"
)

exit += 1

if len(unused_files) != 0:
print(
"\n\n\033[31mERROR\033[0m "
+ f"The following {len(unused_files)} files seem to be unused:\n"
+ "\033[31m"
+ "\n".join(unused_files)
+ "\033[0m"
+ "\nYou have 3 options:"
+ "\n\t- Remove them"
+ "\n\t- Use them (check proper include)"
+ "\n\t- Modify the ignore list of this check\n"
)

exit += 1

if exit == 0:
print(
"\n\n\033[32mINFO\033[0m Finished check_unused_files.py without any errors."
)

return exit


if "__main__" == __name__:
sys.exit(main())
56 changes: 0 additions & 56 deletions CI/physmon/particles_final_config.yml

This file was deleted.

37 changes: 10 additions & 27 deletions CI/physmon/phys_perf_mon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,38 +217,21 @@ function simulation() {
config="CI/physmon/simulation_config.yml"

Examples/Scripts/generic_plotter.py \
$outdir/particles_initial_${suffix}.root \
$outdir/particles_${suffix}.root \
particles \
$outdir/particles_initial_${suffix}_hist.root \
$outdir/particles_${suffix}_hist.root \
--silent \
--config CI/physmon/particles_initial_config.yml
--config $config
ec=$(($ec | $?))

# remove ntuple file because it's large
rm $outdir/particles_initial_${suffix}.root
rm $outdir/particles_${suffix}.root

run_histcmp \
$outdir/particles_initial_${suffix}_hist.root \
$refdir/particles_initial_${suffix}_hist.root \
"Particles inital ${suffix}" \
particles_initial_${suffix}

Examples/Scripts/generic_plotter.py \
$outdir/particles_final_${suffix}.root \
particles \
$outdir/particles_final_${suffix}_hist.root \
--silent \
--config CI/physmon/particles_final_config.yml
ec=$(($ec | $?))

# remove ntuple file because it's large
rm $outdir/particles_final_${suffix}.root

run_histcmp \
$outdir/particles_final_${suffix}_hist.root \
$refdir/particles_final_${suffix}_hist.root \
"Particles final ${suffix}" \
particles_final_${suffix}
$outdir/particles_${suffix}_hist.root \
$refdir/particles_${suffix}_hist.root \
"Particles ${suffix}" \
particles_${suffix}
}

if [[ "$mode" == "all" || "$mode" == "fullchains" ]]; then
Expand Down Expand Up @@ -294,7 +277,7 @@ if [[ "$mode" == "all" || "$mode" == "fullchains" ]]; then
vertexing \
$outdir/performance_amvf_ttbar_hist.root \
--silent \
--config CI/physmon/vertexing_config.yml
--config CI/physmon/vertexing_ttbar_config.yml
ec=$(($ec | $?))

Examples/Scripts/generic_plotter.py \
Expand Down Expand Up @@ -327,7 +310,7 @@ if [[ "$mode" == "all" || "$mode" == "fullchains" ]]; then
vertexing \
$outdir/performance_amvf_gridseeder_ttbar_hist.root \
--silent \
--config CI/physmon/vertexing_config.yml
--config CI/physmon/vertexing_ttbar_config.yml
ec=$(($ec | $?))

# remove ntuple file because it's large
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ambi_orthogonal.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ambi_seeded.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ambi_ttbar.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_gridseeder_seeded_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_gridseeder_ttbar_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_orthogonal_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_seeded_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_truth_estimated_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_truth_smeared_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_ttbar_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_orthogonal.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_seeded.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_truth_estimated.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_truth_smeared.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_ttbar.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_gsf.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ivf_orthogonal_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ivf_seeded_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ivf_truth_estimated_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ivf_truth_smeared_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_seeding_orthogonal.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_seeding_seeded.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_seeding_truth_estimated.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_seeding_ttbar.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_truth_tracking.root
Binary file not shown.
Loading

0 comments on commit a9ae0b3

Please sign in to comment.