From 572b9a9ac5f51a2e6d2d52117a125f871313f4c1 Mon Sep 17 00:00:00 2001 From: Marco Giacalone Date: Mon, 11 Nov 2024 13:10:50 +0100 Subject: [PATCH 1/4] Create clean-ci.yml Added GitHub action to restart PR builds --- .github/workflows/clean-ci.yml | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/clean-ci.yml diff --git a/.github/workflows/clean-ci.yml b/.github/workflows/clean-ci.yml new file mode 100644 index 000000000..aa5364983 --- /dev/null +++ b/.github/workflows/clean-ci.yml @@ -0,0 +1,39 @@ +--- +name: Clean PR builds + +'on': + workflow_dispatch: + inputs: + pr: + description: PR number in this repo to be cleaned + type: string # can't use number here + required: true + + # Warning: GitHub limits the total number of inputs to 10, so a maximum of + # 9 checks is allowed here! + # Warning: the check_* keys are magic and must consist of the string + # "check_" followed by the applicable check name exactly. The + # "description" field is only the human-readable label for the input. + 'check_build/O2DPG/sim/o2': + description: build/O2DPG/sim/o2 + type: boolean + default: true + 'check_build/O2DPG/O2fst/o2': + description: build/O2DPG/O2fst/o2 + type: boolean + default: true + +permissions: {} + +jobs: + clean: + name: Clean PR checks + uses: alisw/ali-bot/.github/workflows/clean-pr-checks.yml@master + with: + owner: ${{ github.event.repository.owner.login }} + repo: ${{ github.event.repository.name }} + pr: ${{ github.event.inputs.pr }} + checks: ${{ toJSON(github.event.inputs) }} + permissions: + pull-requests: read # to get last commit for pr (octokit/graphql-action) + statuses: write # for set-github-status From 1ce8e05f8f76a31a056b78e059b6301d6f1f7c1a Mon Sep 17 00:00:00 2001 From: Marco Giacalone Date: Fri, 15 Nov 2024 14:41:37 +0100 Subject: [PATCH 2/4] Script for hybrid JSON template generation --- MC/bin/o2_hybrid_gen.py | 112 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100755 MC/bin/o2_hybrid_gen.py diff --git a/MC/bin/o2_hybrid_gen.py b/MC/bin/o2_hybrid_gen.py new file mode 100755 index 000000000..b6812b8f1 --- /dev/null +++ b/MC/bin/o2_hybrid_gen.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 + +import argparse +import json + +def main(): + parser = argparse.ArgumentParser(description='Create a JSON file from command line flags.') + parser.add_argument('--gen', type=str, nargs='+', required=True, help='List of generators to be used') + parser.add_argument('--output', type=str, required=True, help='Output JSON file path') + + args = parser.parse_args() + + # put in a list all the elementes in the gen flag + noConfGen = ["pythia8pp", "pythia8hf", "pythia8hi", "pythia8powheg"] + gens = [] + for gen in args.gen: + # if gen is equal to pythia8, then get the Pythia8GenConfig struct from GeneratorPythia8Param.h + if gen == "pythia8": + gens.append({ + 'name': 'pythia8', + 'config': { + "config": "$O2_ROOT/share/Generators/egconfig/pythia8_inel.cfg", + "hooksFileName": "", + "hooksFuncName": "", + "includePartonEvent": False, + "particleFilter": "", + "verbose": 0 + } + }) + elif gen == "external": + gens.append({ + 'name': 'external', + 'config': { + "fileName": "${O2DPG_ROOT}/MC/config/PWGDQ/external/generator/GeneratorParamPromptJpsiToElectronEvtGen_pp13TeV.C", + "funcName": "GeneratorParamPromptJpsiToElectronEvtGen_pp13TeV()" + } + }) + elif gen == "extkinO2": + gens.append({ + 'name': 'extkinO2', + 'config': { + "skipNonTrackable": True, + "continueMode": False, + "roundRobin": False, + "randomize": False, + "rngseed": 0, + "randomphi": False, + "fileName": "/path/to/filename.root" + } + }) + elif gen == "hepmc": + gens.append({ + "name": "hepmc", + "config": { + "configcmd": { + "fileNames": "", + "cmd": "" + }, + "confighepmc": { + "version": 2, + "eventsToSkip": 0, + "fileName": "/path/to/filename.hepmc", + "prune": False + } + } + }) + elif gen == "boxgen": + gens.append({ + "name": "boxgen", + "config": { + "pdg": 13, + "number": 1, + "eta": [ + -4, + -2.5 + ], + "prange": [ + 0.1, + 5 + ], + "phirange": [ + 0, + 360 + ] + } + }) + elif gen in noConfGen: + gens.append({ + "name": gen, + "config": "" + }) + else: + print(f"Generator {gen} not found in the list of available generators") + exit(1) + + # fill fractions with 1 for each generator + fractions = [1] * len(gens) + + # Put gens and fractions in the data dictionary + data = { + "generators": gens, + "fractions": fractions + } + + # Write the data dictionary to a JSON file + with open(args.output, 'w') as f: + json.dump(data, f, indent=2) + + print(f"JSON file created at {args.output}") + +if __name__ == "__main__": + main() \ No newline at end of file From 913ab519b4f9627426101f07b77826c97393e4ee Mon Sep 17 00:00:00 2001 From: Marco Giacalone Date: Fri, 15 Nov 2024 14:44:48 +0100 Subject: [PATCH 3/4] Removed comment --- MC/bin/o2_hybrid_gen.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MC/bin/o2_hybrid_gen.py b/MC/bin/o2_hybrid_gen.py index b6812b8f1..61ba8cd0e 100755 --- a/MC/bin/o2_hybrid_gen.py +++ b/MC/bin/o2_hybrid_gen.py @@ -14,7 +14,6 @@ def main(): noConfGen = ["pythia8pp", "pythia8hf", "pythia8hi", "pythia8powheg"] gens = [] for gen in args.gen: - # if gen is equal to pythia8, then get the Pythia8GenConfig struct from GeneratorPythia8Param.h if gen == "pythia8": gens.append({ 'name': 'pythia8', @@ -109,4 +108,4 @@ def main(): print(f"JSON file created at {args.output}") if __name__ == "__main__": - main() \ No newline at end of file + main() From a6fe17c305b7219b1db93184f395f116ac1b4a30 Mon Sep 17 00:00:00 2001 From: Marco Giacalone Date: Wed, 20 Nov 2024 13:37:07 +0100 Subject: [PATCH 4/4] Added description and example --- MC/bin/o2_hybrid_gen.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MC/bin/o2_hybrid_gen.py b/MC/bin/o2_hybrid_gen.py index 61ba8cd0e..12b5b7c73 100755 --- a/MC/bin/o2_hybrid_gen.py +++ b/MC/bin/o2_hybrid_gen.py @@ -1,5 +1,12 @@ #!/usr/bin/env python3 +# This script creates a template JSON file for the configuration of the hybrid generator +# The generators to be used are passed as a list of strings via the --gen flag, while the +# output filename is set using --output. All the generators available in O2sim are supported. +# Example: +# $O2DPG_ROOT/MC/bin/o2_hybrid_gen.py --gen pythia8 boxgen external extkinO2 hepmc pythia8hf \ +# --output config.json + import argparse import json