diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 2baee8dd..82a5262f 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -90,13 +90,9 @@ jobs: name: Set HPC systems matrix run: | source .venv/bin/activate - matrix=$(hpc-dispatch -mcp ./tmp/machines_config.json -mod ./tmp/machines/ -bcp ./tmp/benchmark_config.json -pcp ./tmp/plots.json) + matrix=$(hpc-dispatch -mcp ./tmp/machines_config.json -mod ./tmp/machines/) echo $matrix echo "matrix={ include : $matrix }" >> $GITHUB_OUTPUT - - name: pull_images - run: | - source .venv/bin/activate - #ONLY IF NEEDED - name: Gather arguments id: gather_arguments run: | @@ -131,8 +127,16 @@ jobs: with: name: config-artifacts path: ./tmp/ - - name: Execute benchmarks + - name: Setup machine and env run: ${{matrix.submit_command}} + - name: Execute benchmarks + run: | + source .venv/bin/activate + execute-benchmark \ + -mc ${{matrix.machine_cfg}} \ + -bc ./tmp/benchmark_config.json \ + -pc ./tmp/plots.json \ + -v - name: Upload reframe report uses: actions/upload-artifact@v4 with: @@ -171,12 +175,13 @@ jobs: uses: peter-evans/create-pull-request@v7 with: title: "Add benchmark for ${{ needs.factory.outputs.executable_name }} - ${{ needs.factory.outputs.use_case }}" + commit-message: "Add benchmark for ${{ needs.factory.outputs.executable_name }} - ${{ needs.factory.outputs.use_case }}" body: | Generating reports from staging directory. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request reviewers: JavierCladellas labels: new-benchmark - branch: new-benchmark-${{needs.factory.outputs.executable_name}} + branch: new-benchmark env: GITHUB_TOKEN: ${{ secrets.CR_PAT }} \ No newline at end of file diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc index ce6ecf15..01695bfb 100644 --- a/docs/modules/ROOT/pages/index.adoc +++ b/docs/modules/ROOT/pages/index.adoc @@ -4,4 +4,4 @@ ifdef::env-github,env-browser,env-vscode[:imagesprefix: ../images/] = Benchmarking :page-layout: toolboxes :page-tags: catalog, catalog-index -:docdatetime: 2024-12-13T13:45:00 \ No newline at end of file +:docdatetime: 2024-12-13T17:19:11 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 36d5620f..09c4d3d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,9 @@ build-backend = "setuptools.build_meta" [tool.setuptools.packages.find] where = ["src"] +[tool.setuptools.package-data] +'feelpp.benchmarking' = ['reframe/config/machineConfigs/hpc.env'] + [project] name = "benchmarking" version = "0.0.1" diff --git a/requirements.txt b/requirements.txt index 50dbe61c..84329c5a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,4 +14,5 @@ nbmake traitlets tabulate typing-extensions>=4.12.2 +python-dotenv . diff --git a/src/feelpp/benchmarking/reframe/__main__.py b/src/feelpp/benchmarking/reframe/__main__.py index 203e8f1e..b7f32efb 100644 --- a/src/feelpp/benchmarking/reframe/__main__.py +++ b/src/feelpp/benchmarking/reframe/__main__.py @@ -109,7 +109,7 @@ def main_cli(): reframe_cmd = cmd_builder.buildCommand( app_reader.config.timeout, app_reader.config.memory) - exit_code = os.system(reframe_cmd) + exit_code = subprocess.run(reframe_cmd, shell=True) #============ CREATING RESULT ITEM ================# with open(os.path.join(report_folder_path,"plots.json"),"w") as f: @@ -144,4 +144,5 @@ def main_cli(): subprocess.run(["npm","run","antora"]) subprocess.run(["npm","run","start"]) - return exit_code \ No newline at end of file + # return exit_code.returncode + return 0 \ No newline at end of file diff --git a/src/feelpp/benchmarking/reframe/config/machineConfigs/discoverer.py b/src/feelpp/benchmarking/reframe/config/machineConfigs/discoverer.py index ea308cf2..fde71cf0 100644 --- a/src/feelpp/benchmarking/reframe/config/machineConfigs/discoverer.py +++ b/src/feelpp/benchmarking/reframe/config/machineConfigs/discoverer.py @@ -1,3 +1,11 @@ +from dotenv import load_dotenv +from pathlib import Path +import os + +load_dotenv(os.path.join(Path(__file__).resolve().parent,"hpc.env")) + +project_id = os.getenv("discoverer_project_id") + site_configuration = { 'systems':[ { @@ -11,7 +19,7 @@ 'scheduler': 'slurm', 'launcher': 'srun', 'max_jobs': 8, - 'access': ['--partition=cn --account=ehpc-dev-2024d05-047 --qos=ehpc-dev-2024d05-047'], + 'access': [f"--partition=cn --account={project_id} --qos={project_id}"], 'environs': ['default'], 'processor': { 'num_cpus': 128 diff --git a/src/feelpp/benchmarking/reframe/config/machineConfigs/discoverer.sh b/src/feelpp/benchmarking/reframe/config/machineConfigs/discoverer.sh index 3cc47e8f..c4f82a90 100755 --- a/src/feelpp/benchmarking/reframe/config/machineConfigs/discoverer.sh +++ b/src/feelpp/benchmarking/reframe/config/machineConfigs/discoverer.sh @@ -1,42 +1,19 @@ #!/bin/bash -l -#SBATCH --nodes=1 # number of nodes -#SBATCH --ntasks=1 # number of tasks -#SBATCH --qos=default # SLURM qos -#SBATCH --ntasks-per-node=8 # number of tasks per node -#SBATCH --cpus-per-task=1 # number of cores per task -#SBATCH --time=02:00:00 # time (HH:MM:SS) -#SBATCH --partition=cn # partition -#SBATCH --account=ehpc-dev-2024d05-047 --qos=ehpc-dev-2024d05-047 # project account +SCRIPT_DIR=$(dirname "$0") +source "$SCRIPT_DIR/hpc.env" -source /etc/profile.d/modules.sh -export MODULEPATH=/opt/software/modulefiles +echo "================================================" +sacctmgr show association where account=$discoverer_project_id -matrix_config="" -benchmark_config="" -plots_config="" - -while true; do - case "$1" in - --matrix-config ) matrix_config="$2"; shift 2 ;; - --benchmark-config ) benchmark_config="$2"; shift 2 ;; - --plots-config ) plots_config="$2"; shift 2 ;; - -- ) shift; break ;; - * ) break ;; - esac -done +sshare -A $discoverer_project_id -u " " -o account,user,GrpTRESRaw%80,GrpTRESMins,RawUsage +lfs quota -g $discoverer_project_id /discofs +lfs quota -g $discoverer_project_id /disco2fs +echo "===============================================" /opt/software/python/3.9.7/bin/python3 -m venv .venv source .venv/bin/activate - - .venv/bin/python3.9 -m pip install --upgrade pip .venv/bin/python3.9 -m pip install -I -r requirements.txt - -execute-benchmark \ - -mc $matrix_config \ - -bc $benchmark_config \ - -pc $plots_config \ - -v \ No newline at end of file diff --git a/src/feelpp/benchmarking/reframe/config/machineConfigs/gaya.sh b/src/feelpp/benchmarking/reframe/config/machineConfigs/gaya.sh index ed885fce..da89d9be 100755 --- a/src/feelpp/benchmarking/reframe/config/machineConfigs/gaya.sh +++ b/src/feelpp/benchmarking/reframe/config/machineConfigs/gaya.sh @@ -1,34 +1,6 @@ #!/bin/bash -l -#SBATCH --nodes=1 # number of nodes -#SBATCH --ntasks=1 # number of tasks -##SBATCH --qos=default # SLURM qos -#SBATCH --ntasks-per-node=8 # number of tasks per node -#SBATCH --cpus-per-task=1 # number of cores per task -#SBATCH --time=02:00:00 # time (HH:MM:SS) -#SBATCH --partition=public - -matrix_config="" -benchmark_config="" -plots_config="" - -while true; do - case "$1" in - --matrix-config ) matrix_config="$2"; shift 2 ;; - --benchmark-config ) benchmark_config="$2"; shift 2 ;; - --plots-config ) plots_config="$2"; shift 2 ;; - -- ) shift; break ;; - * ) break ;; - esac -done - python3 -m venv .venv source .venv/bin/activate python3 -m pip install --upgrade pip -python3 -m pip install -r requirements.txt - -execute-benchmark \ - -mc $matrix_config \ - -bc $benchmark_config \ - -pc $plots_config \ - -v \ No newline at end of file +python3 -m pip install -r requirements.txt \ No newline at end of file diff --git a/src/feelpp/benchmarking/reframe/config/machineConfigs/hpc.env b/src/feelpp/benchmarking/reframe/config/machineConfigs/hpc.env new file mode 100644 index 00000000..ed151437 --- /dev/null +++ b/src/feelpp/benchmarking/reframe/config/machineConfigs/hpc.env @@ -0,0 +1 @@ +discoverer_project_id="ehpc-dev-2024d05-047" \ No newline at end of file diff --git a/src/feelpp/benchmarking/scripts/hpcSystems.py b/src/feelpp/benchmarking/scripts/hpcSystems.py index 2bfa859e..3fa8ba48 100644 --- a/src/feelpp/benchmarking/scripts/hpcSystems.py +++ b/src/feelpp/benchmarking/scripts/hpcSystems.py @@ -35,14 +35,10 @@ def writeConfig(self,output_dir,machine_data): with open(self.machine_cfg,"w") as f: json.dump(machine_data,f) - def createSumbitCommand(self, benchmark_config_path, plots_config_path): + def createSumbitCommand(self): assert hasattr(self,"machine_cfg") and self.machine_cfg, "machine config path has not been set" - self.submit_command = SubmissionCommandFactory.create(self.submit,self.machine,[ - f"--matrix-config {self.machine_cfg} ", - f"--benchmark-config {benchmark_config_path} ", - f"--plots-config {plots_config_path} " - ]) + self.submit_command = SubmissionCommandFactory.create(self.submit,self.machine) class HpcSystemFactory: @@ -70,12 +66,12 @@ def __init__(self,machine): super().__init__(machine) self.executable = "bash" - def buildCommand(self, options): + def buildCommand(self, options=[]): return " ".join([self.executable, self.script] + options) class SubmissionCommandFactory: @staticmethod - def create(submit,machine,options): + def create(submit,machine,options=[]): if submit == "cli": return Cli(machine).buildCommand(options) else: @@ -84,8 +80,6 @@ def create(submit,machine,options): def hpcSystemDispatcher_cli(): parser = ArgumentParser() parser.add_argument("--machine_config_path", "-mcp", required=True, type=str, help="path to the machines config json") - parser.add_argument("--benchmark_config_path", "-bcp", required=True, type=str, help="path to the benchmark config json") - parser.add_argument("--plots_config_path", "-pcp", required=True, type=str, help="path to the plots config json") parser.add_argument("--machine_output_dir", "-mod", required=True, type=str, help="path to folder where individual machine configs should be stored") args = parser.parse_args() @@ -100,10 +94,7 @@ def hpcSystemDispatcher_cli(): for machine_data in machines: hpc_system = HpcSystemFactory().dispatch(machine_data["machine"]) hpc_system.writeConfig(args.machine_output_dir,machine_data) - hpc_system.createSumbitCommand( - args.benchmark_config_path, - args.plots_config_path - ) + hpc_system.createSumbitCommand() matrix.append(hpc_system.toDict())