-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
260 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,194 @@ | ||
name: benchmarks | ||
|
||
env: | ||
TARDIS_VER: release-2023.06.18 | ||
|
||
on: | ||
push: | ||
branches: | ||
- "*" | ||
pull_request: | ||
branches: | ||
- "*" | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- labeled # benchmarks label required | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
jobs: | ||
build: | ||
if: github.event_name == 'push' || github.event_name == 'pull_request' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Restore Atom Data | ||
uses: actions/cache/restore@v3 | ||
id: atom-data-restore | ||
with: | ||
path: benchmarks/kurucz_cd23_chianti_H_He.h5 | ||
key: atom-data | ||
|
||
- name: Download Atom Data | ||
if: steps.atom-data-restore.outputs.cache-hit != 'true' | ||
run: | | ||
REPO_URL="https://dev.azure.com/tardis-sn/TARDIS/_apis/git/repositories/tardis-refdata" | ||
wget -q "$REPO_URL/items?path=atom_data/kurucz_cd23_chianti_H_He.h5&versionType=branch&version=master&resolveLfs=true" -O benchmarks/kurucz_cd23_chianti_H_He.h5 | ||
- name: Save Atom Data | ||
uses: actions/cache/save@v3 | ||
if: ${{ steps.atom-data-restore.cache-hit != 'true' && always() || false }} | ||
id: atom-data-cache-save | ||
with: | ||
path: benchmarks/kurucz_cd23_chianti_H_He.h5 | ||
key: atom-data | ||
|
||
- name: Install asv | ||
run: pip install asv==0.5.* | ||
|
||
- name: Accept all asv questions | ||
run: asv machine --yes | ||
|
||
- name: Download TARDIS dependencies | ||
run: | | ||
LOCK_URL="https://github.com/tardis-sn/tardis/raw/${{ env.TARDIS_VER }}/tardis_env3.yml" | ||
wget -q "$LOCK_URL" | ||
- name: Add TARDIS install command to asv config file | ||
run: | | ||
TARDIS_INSTALL_CMD="pip install git+https://github.com/tardis-sn/tardis.git@${{ env.TARDIS_VER }}" | ||
cat <<< $(jq '.build_command |= [$TARDIS_INSTALL_CMD] + .' --arg TARDIS_INSTALL_CMD "${TARDIS_INSTALL_CMD}" asv.conf.json) > asv.conf.json | ||
- name: Run benchmarks for last 5 commits if not PR | ||
if: github.event_name != 'pull_request' | ||
run: | | ||
git log -n 5 --pretty=format:"%H" >> tag_commits.txt | ||
asv run -v HASHFILE:tag_commits.txt | tee asv-output.log | ||
if grep -q failed asv-output.log; then | ||
echo "Some benchmarks have failed!" | ||
exit 1 | ||
fi | ||
- name: Generate Graphs and HTML | ||
if: github.event_name != 'pull_request' | ||
run: asv publish | ||
|
||
- name: Delete env files | ||
run: rm -r .asv/env | ||
|
||
- name: Create results html on dest repo | ||
if: github.event_name != 'pull_request' | ||
continue-on-error: true | ||
uses: cpina/github-action-push-to-another-repository@main | ||
env: | ||
API_TOKEN_GITHUB: ${{ secrets.BOT_TOKEN }} | ||
with: | ||
source-directory: ".asv/html" | ||
destination-github-username: "tardis-sn" | ||
destination-repository-name: "stardis-benchmarks" | ||
user.email: [email protected] | ||
target-branch: main | ||
|
||
- name: Push misc data to dest repo | ||
if: github.event_name != 'pull_request' | ||
continue-on-error: true | ||
uses: cpina/github-action-push-to-another-repository@main | ||
env: | ||
API_TOKEN_GITHUB: ${{ secrets.BOT_TOKEN }} | ||
with: | ||
source-directory: ".asv/results" | ||
destination-github-username: "tardis-sn" | ||
destination-repository-name: "stardis-benchmarks" | ||
user.email: [email protected] | ||
target-branch: main | ||
target-directory: "misc" | ||
|
||
- name: Compare HEAD with main if PR | ||
if: github.event_name == 'pull_request' | ||
continue-on-error: true # TODO: step failed sporadically while testing | ||
run: | | ||
asv continuous ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | tee asv-cont-output.log | ||
if grep -q failed asv-cont-output.log; then | ||
echo "Some benchmarks have errors!" | ||
exit 1 | ||
fi | ||
- run: asv compare ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | tee asv-compare-output.log | ||
- run: asv compare ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} --only-changed | tee asv-compare-changed-output.log | ||
|
||
- name: asv output 1 | ||
id: asv_pr_vs_main | ||
uses: juliangruber/[email protected] | ||
with: | ||
path: asv-compare-output.log | ||
|
||
- name: asv output 2 | ||
id: asv_pr_vs_main_changed | ||
uses: juliangruber/[email protected] | ||
with: | ||
path: asv-compare-changed-output.log | ||
|
||
- name: Find Comment | ||
if: always() && github.event_name == 'pull_request' | ||
uses: peter-evans/find-comment@v1 | ||
id: fc | ||
with: | ||
issue-number: ${{ github.event.number }} | ||
comment-author: "tardis-bot" | ||
body-includes: I ran benchmarks as you asked | ||
|
||
- name: Post comment | ||
if: github.event_name == 'pull_request' | ||
uses: peter-evans/create-or-update-comment@v2 | ||
with: | ||
token: ${{ secrets.BOT_TOKEN }} | ||
issue-number: ${{ github.event.number }} | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
edit-mode: replace | ||
body: | | ||
*\*beep\* \*bop\** | ||
Hi human, | ||
I ran benchmarks as you asked comparing main (${{ github.event.pull_request.base.sha }}) and the latest commit (${{ github.event.pull_request.head.sha }}). | ||
Here are the logs produced by ASV. | ||
Results can also be downloaded as artifacts [**here**](${{ env.URL }}). | ||
Significantly changed benchmarks: | ||
<details> | ||
```diff | ||
${{ steps.asv_pr_vs_main_changed.outputs.content }} | ||
``` | ||
</details> | ||
All benchmarks: | ||
<details> | ||
```diff | ||
${{ steps.asv_pr_vs_main.outputs.content }} | ||
``` | ||
</details> | ||
env: | ||
URL: https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }}?check_suite_focus=true | ||
|
||
- name: Save results artifact | ||
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: asv-benchmark-results-${{ runner.os }} | ||
path: | | ||
.asv/results | ||
asv-cont-output.log | ||
asv-compare-output.log | ||
asv-compare-changed-output.log |
This file contains 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,21 @@ | ||
|
||
{ | ||
"version": 1, | ||
"project": "stardis", | ||
"project_url": "https://tardis-sn.github.io/tardis", | ||
"repo": ".", | ||
"install_command": ["in-dir={env_dir} python -mpip install {wheel_file}"], | ||
"uninstall_command": ["return-code=any python -mpip uninstall -y {project}"], | ||
"build_command": [ | ||
"python setup.py build", | ||
"PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}" | ||
], | ||
"branches": ["main"], | ||
"environment_type": "conda", | ||
"show_commit_url": "https://github.com/tardis-sn/stardis/commit", | ||
"conda_environment_file": "tardis_env3.yml", | ||
"benchmark_dir": "benchmarks", | ||
"env_dir": ".asv/env", | ||
"results_dir": ".asv/results", | ||
"html_dir": ".asv/html" | ||
} |
Empty file.
This file contains 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,20 @@ | ||
stardis_config_version: 1.0 | ||
atom_data: kurucz_cd23_chianti_H_He.h5 | ||
model: | ||
type: marcs | ||
fname: sun.mod | ||
final_atomic_number: 30 | ||
opacity: | ||
file: | ||
Hminus_bf: h_minus_cross_section_wbr.dat | ||
bf: | ||
H_I: {} | ||
ff: | ||
H_I: {} | ||
disable_electron_scattering: False | ||
line: | ||
disable: False | ||
broadening: [radiation, linear_stark, quadratic_stark, van_der_waals] | ||
min: 6500 AA | ||
max: 6600 AA | ||
no_of_thetas: 20 |
This file contains 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 @@ | ||
../docs/quickstart/h_minus_cross_section_wbr.dat |
This file contains 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,23 @@ | ||
# Import necessary code | ||
|
||
import os | ||
import numpy as np | ||
from stardis.base import run_stardis | ||
from astropy import units as u | ||
|
||
|
||
class BenchmarkRunStardis: | ||
""" | ||
Class to benchmark run_stardis function. | ||
""" | ||
|
||
timeout = 1800 # Worst case timeout of 30 mins | ||
|
||
def setup(self): | ||
base_dir = os.path.abspath(os.path.dirname(__file__)) | ||
self.config = os.path.join(base_dir, "benchmark_config.yml") | ||
self.tracing_lambdas = np.arange(6540, 6590, 0.01) * u.Angstrom | ||
os.chdir(base_dir) | ||
|
||
def time_run_stardis(self): | ||
run_stardis(self.config, self.tracing_lambdas) |
This file contains 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 @@ | ||
../docs/quickstart/sun.mod |