Skip to content

Commit

Permalink
Merge pull request #17 from hep-cce/lorenzm/CI
Browse files Browse the repository at this point in the history
Draft PR for code review
  • Loading branch information
dingp authored Aug 29, 2024
2 parents 5f22917 + 5f2778e commit ce8560f
Show file tree
Hide file tree
Showing 47 changed files with 4,725 additions and 64 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/CI_python.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Python Code Checks

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
cd ./hmatools
python -m pip install --use-pep517 -e .
python -m pip install black flake8 pylint mypy pytest
python -m pip install types-seaborn pandas-stubs matplotlib-stubs
- name: Format code with Black
run: |
cd ./hmatools/python
black --check .
- name: Lint with Flake8
run: |
cd ./hmatools/python
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics
- name: Lint with Pylint
run: |
cd ./hmatools/python
pylint .
- name: Type check with Mypy
run: |
cd ./hmatools/python
mypy . --explicit-package-bases
- name: Run tests
run: |
pytest
51 changes: 51 additions & 0 deletions .github/workflows/OVERVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# GitHub Actions Workflows Overview

## 1. Run FastCaloSim Benchmarking (`benchmarking.yaml`)

The `benchmarking.yaml` workflow is designed to automate the benchmarking of FastCaloSim on different environments, including Perlmutter and Exalearn. Steps:

- **Build and Push Images**:
- This step is optional and controlled via workflow dispatch (`run_build` input).
- If triggered, the job builds and pushes Docker images using a self-hosted runner, and logs are uploaded for review.

- **Run FastCaloSim**:
- This job runs FastCaloSim on different platforms using a matrix strategy to handle multiple configurations (Perlmutter and Exalearn).
- It sets up environment variables specific to each runner and executes the simulation scripts.
- Log files from each run are compressed into tarballs and uploaded for later use.

- **Postprocess Log Files**:
- This job depends on the completion of the `run` job.
- It downloads log files from the previous runs, decompresses them, and runs a postprocessing script using HMATools.
- The processed logs and resulting JSON files are uploaded as artifacts.

- **Plot Results**:
- This job depends on the completion of the `postprocess` job.
- It downloads the processed JSON files and runs a plotting script using HMATools.
- The generated plots and associated logs are uploaded for analysis.

For postprocessing, and plotting, a docker container with HMATools is built and run to execute the steps.

## 2. Python Code Checks (`Python_CI.yaml`)

The `Python_CI.yaml` workflow is a Continuous Integration (CI) pipeline focused on ensuring code quality and correctness in the HMATools project. It includes the following steps:

- **Checkout Code**:
- The repository is checked out to the runner for subsequent operations.

- **Set Up Python**:
- Python 3.11 is installed and configured for the environment.

- **Install Dependencies**:
- All necessary Python packages, including project dependencies and development tools like `black`, `flake8`, `pylint`, `mypy`, and `pytest`, are installed.

- **Code Formatting with Black**:
- The codebase is checked for compliance with `black` formatting standards.

- **Linting with Flake8 and Pylint**:
- Code is linted to catch syntax errors, enforce coding standards, and assess code complexity.

- **Type Checking with Mypy**:
- Static type checking is performed to catch type-related errors before runtime.

- **Run Tests**:
- Unit tests are executed using `pytest` to ensure the functionality is working as expected.
198 changes: 198 additions & 0 deletions .github/workflows/benchmarking.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
name: Run FastCaloSim Benchmarking

on:
workflow_dispatch:
inputs:
run_build:
description: "Run the build job?"
required: false
default: "false"
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: self-hosted
name: Build and push images
if: ${{ github.event.inputs.run_build == 'true' }}
env:
LOG_DIR: ${{ github.workspace }}/logs/build

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build images
run: |
cd ./scripts/build_scripts
./build_images.sh
- name: Upload log files
uses: actions/upload-artifact@v4
with:
name: Log File - Building and Pushing container images
path: ${{ env.LOG_DIR }}/*.txt

- name: Cleanup workspace
run: rm -rf ${{ github.workspace }}/*


# Idea: Make all permutations of runs
run:
runs-on: ${{ matrix.runner-label }}
name: Run FastCaloSim
strategy:
matrix:
runner-label: [perlmutter, exalearn]
env:
LOG_DIR: ${{ github.workspace }}/logs/run
NERSC_CONTAINER_REGISTRY_USER: ${{ secrets.NERSC_CONTAINER_REGISTRY_USER }}
NERSC_CONTAINER_REGISTRY_PASSWORD: ${{ secrets.NERSC_CONTAINER_REGISTRY_PASSWORD }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run FastCaloSim on Perlmutter
if: contains(runner.name, 'perlmutter')
env:
RUNNER_LABEL: perlmutter
FCS_DATAPATH: /global/cfs/cdirs/atlas/leggett/data/FastCaloSimInputs
run: |
cd ./scripts/run_scripts
./run_images.sh
- name: Run FastCaloSim on exalearn
if: contains(runner.name, 'exalearn')
env:
RUNNER_LABEL: exalearn5
FCS_DATAPATH: /local/scratch/cgleggett/data/FastCaloSimInputs
run: |
cd ./scripts/run_scripts
./run_images.sh
- name: Create tarball of log files
run: |
cd ${{ env.LOG_DIR }}
tar -czf ${{ github.workspace }}/log_files_${{ matrix.runner-label }}.tar.gz ./*.txt
- name: Upload log files
uses: actions/upload-artifact@v4
with:
name: Log Files - ${{ matrix.runner-label }}
path: log_files_${{ matrix.runner-label }}.tar.gz

postprocess:
runs-on: ubuntu-latest
name: Postprocess log files
needs: run
env:
LOG_DIR: ${{ github.workspace }}/logs/postprocess
INPUT_DIR: ${{ github.workspace }}/logs/run
OUTPUT_DIR: ${{ github.workspace }}/logs/postprocess
SCRIPT: ./postprocess.sh

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download perlmutter log files
uses: actions/download-artifact@v4
with:
name: Log Files - perlmutter
path: ${{ env.INPUT_DIR }}

- name: Download exalearn log files
uses: actions/download-artifact@v4
with:
name: Log Files - exalearn
path: ${{ env.INPUT_DIR }}

- name: Untar and uncompress logs
run: |
for runner in perlmutter exalearn; do
tar -xzf /home/runner/work/self_hosted_runner/self_hosted_runner/logs/run/log_files_${runner}.tar.gz -C /home/runner/work/self_hosted_runner/self_hosted_runner/logs/run
done
- name: Debug input directory
run: |
ls -l ${{ env.INPUT_DIR }}
- name: Build hmatools image
run: |
cd ./hmatools/scripts
./build_image.sh
- name: Run hmatools postprocessing
run: |
cd ./hmatools/scripts
./run_image.sh
- name: Upload logfiles
if: always()
uses: actions/upload-artifact@v4
with:
name: Postprocess log file
path: ${{ env.LOG_DIR }}/*.txt

- name: Upload json files
if: always()
uses: actions/upload-artifact@v4
with:
name: FastCaloSim Results (JSON)
path: ${{ env.OUTPUT_DIR }}/*.json

- name: Cleanup workspace
run: rm -rf ${{ github.workspace }}/*

plot:
runs-on: ubuntu-latest
name: Plot results
needs: postprocess
env:
LOG_DIR: ${{ github.workspace }}/logs/plot
INPUT_DIR: ${{ github.workspace }}/logs/postprocess
OUTPUT_DIR: ${{ github.workspace }}/logs/plot
SCRIPT: ./plot.sh

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download json files
uses: actions/download-artifact@v4
with:
name: FastCaloSim Results (JSON)
path: ${{ env.INPUT_DIR }}

- name: Debug input directory
run: |
ls -l ${{ env.INPUT_DIR }}
- name: Build hmatools image
run: |
cd ./hmatools/scripts
./build_image.sh
- name: Run hmatools plotting
run: |
cd ./hmatools/scripts
./run_image.sh
- name: Upload logfiles
if: always()
uses: actions/upload-artifact@v4
with:
name: Plot log file
path: ${{ env.LOG_DIR }}/*.txt

- name: Upload plot files
if: always()
uses: actions/upload-artifact@v4
with:
name: Result plots
path: ${{ env.OUTPUT_DIR }}/*.png
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**/.DS_Store
**/__pycache__/
**/*.egg-info/
**/json/**/*
scripts/run_scripts/*.txt
**/*.txt
**/*.json
**/*.png
**/*.ipynb
!/hmatools/tests/test_data/**
!/hmatools/requirements.txt
Loading

0 comments on commit ce8560f

Please sign in to comment.