-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/asv workflow #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
prasad-sawantdesai
wants to merge
38
commits into
iterorganization:develop
Choose a base branch
from
prasad-sawantdesai:feature/asv_workflow
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
4eaf3bf
added asv workflow
prasad-sawantdesai dc6b820
added workflow dispatch
prasad-sawantdesai dfcf172
ci: fix ASV benchmarks for GitHub Actions with Zenodo test data and r…
prasad-sawantdesai f77f66e
fixed trailing slashes for netcdf
prasad-sawantdesai 4aecfb6
provided one relevant netcdf file which has all variables
prasad-sawantdesai 55d9c4c
provide appropriate scenario file
prasad-sawantdesai d09c3bb
fix: resolve ASV CI issues with permissions, branch resolution and te…
prasad-sawantdesai c4f4638
fix: use profiles_1d[:] instead of [0:100] in benchmark paths
prasad-sawantdesai c7f23c7
fix: create local branches for asv publish using fetch refspec syntax
prasad-sawantdesai ae3fdbe
do not update PR
prasad-sawantdesai 1970b0e
show --split log
prasad-sawantdesai e801b74
deploy only on pull request
prasad-sawantdesai 4763d86
removed test script
prasad-sawantdesai fd7bb37
fix: bamboo upstream branches for benchmarks
prasad-sawantdesai 1fca973
fix: bamboo_planRepository_branch
prasad-sawantdesai ec2aa0b
fix set script variables
prasad-sawantdesai 0a21855
fix for spdx
prasad-sawantdesai bb4d015
fix toml
prasad-sawantdesai 8cbdab9
fix forbuild command for main branch
prasad-sawantdesai a6d9be5
fix: install pbr in ASV venv to shadow EasyBuild's pbr and fix pkg_re…
prasad-sawantdesai ba9a723
fixed ci script and reverted asv config
prasad-sawantdesai fe91a60
pinned documentation requirements
prasad-sawantdesai 51f0ce9
fix pytest
prasad-sawantdesai 47fa382
fix e2e test
prasad-sawantdesai 4504a64
fix cross-env: command not found issue
prasad-sawantdesai 121bb48
provide xvfb
prasad-sawantdesai 741132e
added xvfb
prasad-sawantdesai 1d4d00a
Merge branch 'develop' into feature/asv_workflow
prasad-sawantdesai 46126ad
added readthedocs
prasad-sawantdesai 9f2717c
fixed license file and warning
prasad-sawantdesai efa161b
fixed warnings
prasad-sawantdesai 86dea57
added gitkeep
prasad-sawantdesai 3041f1a
fixed comments from jwasikpsnc
prasad-sawantdesai 96d8165
updated links and added documentation link
prasad-sawantdesai c744207
fixed how_to_launch page
prasad-sawantdesai da1fd69
fixed version and removed license
prasad-sawantdesai f38d137
fixed exception test
prasad-sawantdesai 31b5c69
Fix ASV build failure
prasad-sawantdesai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| name: ASV Benchmarks | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, develop] | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| benchmark: | ||
| runs-on: ubuntu-22.04 | ||
| permissions: | ||
| contents: write # needed to push HTML report to gh-pages branch | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Display Python version | ||
| run: python -c "import sys; print(sys.version)" | ||
|
|
||
| - name: Install dependencies | ||
| working-directory: backend | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| # virtualenv required by asv to create per-commit benchmark environments | ||
| pip install asv virtualenv | ||
|
|
||
| - name: Download test data from Zenodo | ||
| run: | | ||
| mkdir -p test_data | ||
| # iter_scenario_53298_seq1_DD4: ~14 MB, DD 4.0.0, contains core_profiles + equilibrium | ||
| # (required by all benchmark node paths). The 123364 file is a SOLPS edge | ||
| # simulation with no core_profiles/equilibrium so is not used for benchmarks. | ||
| wget -q -O test_data/iter_scenario_53298_seq1_DD4.nc \ | ||
| "https://zenodo.org/records/17062700/files/iter_scenario_53298_seq1_DD4.nc?download=1" | ||
| echo "Downloaded files:" | ||
| ls -lh test_data/ | ||
|
|
||
| - name: Configure ASV regression threshold for CI | ||
| run: | | ||
| # On GitHub Actions: only flag regressions >2x slower in the HTML report, | ||
| # matching the --factor 2.0 used in asv continuous below. | ||
| # On Bamboo/local, asv.conf.json is used as-is (default ASV threshold of 5%). | ||
| python - <<'EOF' | ||
| import pathlib | ||
| conf_path = pathlib.Path('asv.conf.json') | ||
| conf = conf_path.read_text() | ||
| # Insert threshold entry before the final closing brace | ||
| assert conf.rstrip().endswith('}'), "Unexpected asv.conf.json ending" | ||
| patched = conf.rstrip()[:-1].rstrip().rstrip(',') + ',\n "regressions_thresholds": {".*": 2.0}\n}\n' | ||
| conf_path.write_text(patched) | ||
| print("CI: regressions_thresholds set to 2.0") | ||
| EOF | ||
|
|
||
| - name: Run ASV continuous benchmarks | ||
| id: asv | ||
| # continue-on-error so we can post the PR comment before re-failing the job | ||
| continue-on-error: true | ||
| env: | ||
| # Tells benchmarks/__init__.py where the test data lives | ||
| IBEX_TEST_DATA_DIR: ${{ github.workspace }}/test_data | ||
| run: | | ||
| asv machine --yes | ||
|
|
||
| if [ "${{ github.event_name }}" = "pull_request" ]; then | ||
| # Compare base branch vs PR head — both on the same runner, same hardware | ||
| BASELINE="origin/${{ github.base_ref }}" | ||
| CONTENDER="${{ github.sha }}" | ||
| else | ||
| # Compare previous commit vs current commit on push/manual trigger | ||
| # Guard: skip if there is no previous commit (e.g. initial branch push) | ||
| if ! git rev-parse HEAD~1 >/dev/null 2>&1; then | ||
| echo "No previous commit to compare against — skipping benchmark comparison." | ||
| exit 0 | ||
| fi | ||
| BASELINE="HEAD~1" | ||
| CONTENDER="HEAD" | ||
| fi | ||
|
|
||
| # Resolve to full SHAs for clarity in the log | ||
| BASELINE_SHA=$(git rev-parse "${BASELINE}" 2>/dev/null || echo "${BASELINE}") | ||
| CONTENDER_SHA=$(git rev-parse "${CONTENDER}" 2>/dev/null || echo "${CONTENDER}") | ||
| echo "Comparing commits:" | ||
| echo " BASELINE : ${BASELINE} → ${BASELINE_SHA}" | ||
| echo " CONTENDER : ${CONTENDER} → ${CONTENDER_SHA}" | ||
|
|
||
| # --factor 2.0: only flag as regression if a benchmark is >2x slower | ||
| # (filters out GitHub runner hardware noise, ~20-50% typical variance) | ||
| asv continuous --quick --show-stderr --factor 2.0 "${BASELINE_SHA}" "${CONTENDER_SHA}" \ | ||
| 2>&1 | tee asv_output.txt | ||
|
|
||
| # Print a direct before/after comparison table (ratio per benchmark). | ||
| # This makes it easy to see which benchmarks changed and by how much. | ||
| echo "" | ||
| echo "=== Before vs After comparison ===" | ||
| asv compare --factor 2.0 --split "${BASELINE_SHA}" "${CONTENDER_SHA}" 2>&1 | tee -a asv_output.txt | ||
|
|
||
| - name: Fail job if regression detected | ||
| if: steps.asv.outcome == 'failure' | ||
| run: | | ||
| echo "FAILED: Performance regression detected (>2x threshold). See benchmark output above." | ||
| exit 1 | ||
|
|
||
| - name: Generate HTML results | ||
| # Only meaningful on push to develop/main — asv publish builds the branch | ||
| # timeline, so PR commits (not yet on any branch) are simply skipped with | ||
| # "Couldn't find <sha> in branches". Run only after a merge to avoid noise. | ||
| if: github.event_name != 'pull_request' | ||
| run: | | ||
| # asv publish resolves branch names from asv.conf.json via git rev-list. | ||
| # On PR checkouts only the PR branch is a local ref. Using | ||
| # refspec <remote>:<local> creates local branches directly so that | ||
| # git rev-list develop / main succeeds (plain fetch only makes | ||
| # remotes/origin/develop which asv does not resolve). | ||
| git fetch origin develop:develop 2>/dev/null || true | ||
| git fetch origin main:main 2>/dev/null || true | ||
| asv publish | ||
|
|
||
| - name: Deploy HTML report to GitHub Pages | ||
| # Only run on push to develop/main, same reasoning as Generate HTML above. | ||
| if: github.event_name != 'pull_request' | ||
| uses: peaceiris/actions-gh-pages@v3 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| publish_dir: .asv/html | ||
| destination_dir: benchmarks | ||
| keep_files: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| version: 2 | ||
|
|
||
| build: | ||
| os: ubuntu-24.04 | ||
| tools: | ||
| python: "3.11" | ||
|
|
||
| sphinx: | ||
| configuration: docs/source/conf.py | ||
| fail_on_warning: true | ||
|
|
||
| python: | ||
| install: | ||
| - method: pip | ||
| path: backend | ||
| extra_requirements: | ||
| - docs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,20 @@ | ||
| import os | ||
| from pathlib import Path | ||
|
|
||
| uris_label = ["pulsefile uri"] | ||
| uris = [ | ||
| "imas:mdsplus?user=public;database=ITER;pulse=134173;run=106;version=3", # 871 slices | ||
| "imas:hdf5?user=public;database=ITER;pulse=134173;run=106;version=3", # 871 slices | ||
| "imas:hdf5?path=/work/imas/shared/imasdb/ITER/3/105070/2", # 4183 slices | ||
| ] | ||
|
|
||
| if os.environ.get("GITHUB_ACTIONS") == "true": | ||
| # On GitHub Actions: use publicly available Zenodo datasets (CC-BY 4.0) | ||
| # https://zenodo.org/records/17062700 | ||
| # Downloaded by the workflow into IBEX_TEST_DATA_DIR before benchmarks run. | ||
| _data_dir = Path(os.environ["IBEX_TEST_DATA_DIR"]) | ||
| uris = [ | ||
| str(_data_dir / "iter_scenario_53298_seq1_DD4.nc"), # ~14 MB, DD 4.0.0, core_profiles+equilibrium | ||
| ] | ||
| else: | ||
| # Local / ITER infrastructure: use internal IMAS data sources directly | ||
| uris = [ | ||
| "imas:mdsplus?user=public;database=ITER;pulse=134173;run=106;version=3", # 871 slices | ||
| "imas:hdf5?user=public;database=ITER;pulse=134173;run=106;version=3", # 871 slices | ||
| "imas:hdf5?path=/work/imas/shared/imasdb/ITER/3/105070/2", # 4183 slices | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.