Skip to content

Commit ac5a946

Browse files
authored
Use srun for job execution on Slurm (#171)
* Use srun for job execution on Slurm * Use sstat for resource stat collection * Add step_nodes to resource requirements for multi-node srun steps * Add slurm_stats table
1 parent 614fa54 commit ac5a946

File tree

187 files changed

+7118
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+7118
-383
lines changed

.github/scripts/gh-pages-commit.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
# Shared commit-and-push for gh-pages deployments.
3+
# Must be run from inside the gh-pages-deploy directory.
4+
#
5+
# Usage: gh-pages-commit.sh "Commit message"
6+
set -e
7+
8+
COMMIT_MSG="${1:?Usage: gh-pages-commit.sh \"commit message\"}"
9+
10+
git add -A
11+
if git diff --cached --quiet; then
12+
echo "No changes to deploy"
13+
else
14+
git commit -m "$COMMIT_MSG"
15+
git push origin gh-pages
16+
fi

.github/scripts/gh-pages-setup.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
# Shared setup for gh-pages deployments.
3+
# Configures git and clones (or initializes) the gh-pages branch into ./gh-pages-deploy.
4+
#
5+
# Required environment variables:
6+
# GITHUB_TOKEN — access token for pushing to the repository
7+
# GITHUB_REPOSITORY — owner/repo (e.g., NatLabRockies/torc)
8+
set -e
9+
10+
REPO_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
11+
12+
git config --global user.name "github-actions[bot]"
13+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
14+
15+
git clone --depth 1 --branch gh-pages "$REPO_URL" gh-pages-deploy 2>/dev/null || {
16+
# Branch doesn't exist yet — create it
17+
mkdir gh-pages-deploy
18+
cd gh-pages-deploy
19+
git init
20+
git checkout -b gh-pages
21+
git remote add origin "$REPO_URL"
22+
cd ..
23+
}
24+
25+
cd gh-pages-deploy
26+
touch .nojekyll

.github/workflows/docs.yml

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ on:
88
- 'docs/**'
99
- '.github/workflows/docs.yml'
1010

11+
# contents:write is required to push to the gh-pages branch directly
12+
# (the previous pages:write + id-token:write approach used the Pages API instead)
1113
permissions:
12-
contents: read
13-
pages: write
14-
id-token: write
14+
contents: write
1515

1616
concurrency:
1717
group: "pages"
1818
cancel-in-progress: false
1919

2020
jobs:
21-
build:
21+
deploy:
2222
runs-on: ubuntu-latest
2323
steps:
2424
- name: Checkout repository
@@ -35,23 +35,43 @@ jobs:
3535
- name: Build documentation
3636
run: |
3737
cd docs
38+
# Override site-url for versioned path
39+
sed -i 's|site-url = "/torc/"|site-url = "/torc/latest/"|' book.toml
3840
mdbook build
3941
40-
- name: Setup Pages
41-
uses: actions/configure-pages@v5
42+
- name: Setup gh-pages branch
43+
run: .github/scripts/gh-pages-setup.sh
44+
env:
45+
GITHUB_TOKEN: ${{ github.token }}
4246

43-
- name: Upload artifact
44-
uses: actions/upload-pages-artifact@v4
45-
with:
46-
path: 'docs/book'
47+
- name: Deploy latest docs
48+
run: |
49+
cd gh-pages-deploy
4750
48-
deploy:
49-
environment:
50-
name: github-pages
51-
url: ${{ steps.deployment.outputs.page_url }}
52-
runs-on: ubuntu-latest
53-
needs: build
54-
steps:
55-
- name: Deploy to GitHub Pages
56-
id: deployment
57-
uses: actions/deploy-pages@v4
51+
# One-time: clean legacy Sphinx content
52+
rm -rf _static _sources _images genindex.html objects.inv searchindex.js \
53+
py-modindex.html search.html .buildinfo
54+
55+
# Replace latest/ with new build
56+
rm -rf latest
57+
cp -r ../docs/book latest
58+
59+
# Root redirect
60+
cp ../docs/redirect.html index.html
61+
62+
# Initialize versions.json if it doesn't exist
63+
if [ ! -f versions.json ]; then
64+
cat > versions.json << 'VJSON'
65+
{
66+
"latest_release": null,
67+
"versions": [
68+
{"version": "latest", "label": "latest (dev)", "path": "/torc/latest/"}
69+
]
70+
}
71+
VJSON
72+
fi
73+
74+
- name: Commit and push
75+
run: |
76+
cd gh-pages-deploy
77+
../.github/scripts/gh-pages-commit.sh "Deploy docs from ${GITHUB_SHA::8}"

.github/workflows/release.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,136 @@ jobs:
234234
tags: |
235235
${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.version }}
236236
${{ steps.meta.outputs.image }}:latest
237+
238+
deploy-docs:
239+
name: Deploy Versioned Docs
240+
runs-on: ubuntu-latest
241+
if: startsWith(github.ref, 'refs/tags/v')
242+
concurrency:
243+
group: "pages"
244+
cancel-in-progress: false
245+
steps:
246+
- name: Checkout code
247+
uses: actions/checkout@v6
248+
249+
- name: Extract version from tag
250+
id: version
251+
run: echo "version=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
252+
253+
- name: Setup mdBook
254+
uses: peaceiris/actions-mdbook@v2
255+
with:
256+
mdbook-version: '0.4.52'
257+
258+
- name: Install mdbook-mermaid
259+
run: cargo install mdbook-mermaid@0.16.0
260+
261+
- name: Build documentation
262+
run: |
263+
cd docs
264+
VERSION="${{ steps.version.outputs.version }}"
265+
# Override site-url and edit-url for this release version
266+
sed -i "s|site-url = \"/torc/\"|site-url = \"/torc/${VERSION}/\"|" book.toml
267+
sed -i "s|edit-url-template = \"https://github.com/NatLabRockies/torc/edit/main/docs/{path}\"|edit-url-template = \"https://github.com/NatLabRockies/torc/tree/${VERSION}/docs/{path}\"|" book.toml
268+
mdbook build
269+
270+
- name: Setup gh-pages branch
271+
run: .github/scripts/gh-pages-setup.sh
272+
env:
273+
GITHUB_TOKEN: ${{ github.token }}
274+
275+
- name: Deploy versioned docs
276+
run: |
277+
cd gh-pages-deploy
278+
VERSION="${{ steps.version.outputs.version }}"
279+
280+
# Copy build into versioned subdirectory
281+
rm -rf "${VERSION}"
282+
cp -r ../docs/book "${VERSION}"
283+
284+
# Root redirect (only if missing)
285+
if [ ! -f index.html ]; then
286+
cp ../docs/redirect.html index.html
287+
fi
288+
289+
# Update versions.json using inline Python
290+
python3 << 'PYEOF'
291+
import json, os, re, shutil
292+
293+
version = os.environ.get("VERSION", "${{ steps.version.outputs.version }}")
294+
versions_file = "versions.json"
295+
296+
# Load existing or create new
297+
if os.path.exists(versions_file):
298+
with open(versions_file) as f:
299+
data = json.load(f)
300+
else:
301+
data = {"latest_release": None, "versions": []}
302+
303+
# Ensure "latest (dev)" entry exists
304+
has_latest = any(v["version"] == "latest" for v in data["versions"])
305+
if not has_latest:
306+
data["versions"].insert(0, {
307+
"version": "latest",
308+
"label": "latest (dev)",
309+
"path": "/torc/latest/"
310+
})
311+
312+
# Remove existing entry for this version if present
313+
data["versions"] = [v for v in data["versions"] if v["version"] != version]
314+
315+
# Add new version entry after "latest"
316+
new_entry = {
317+
"version": version,
318+
"label": version,
319+
"path": f"/torc/{version}/"
320+
}
321+
322+
# Find insertion point: after "latest", before other versions
323+
insert_idx = 1 # after "latest"
324+
data["versions"].insert(insert_idx, new_entry)
325+
326+
# Sort release versions by semver (descending), keep "latest" first
327+
def semver_key(v):
328+
if v["version"] == "latest":
329+
return (999, 999, 999)
330+
# Extracts major.minor.patch; pre-release suffixes are ignored for sorting
331+
m = re.match(r"v?(\d+)\.(\d+)\.(\d+)", v["version"])
332+
if m:
333+
return (int(m.group(1)), int(m.group(2)), int(m.group(3)))
334+
return (0, 0, 0)
335+
336+
data["versions"].sort(key=semver_key, reverse=True)
337+
338+
# Update latest_release
339+
data["latest_release"] = version
340+
341+
# Keep at most MAX_VERSIONS release versions (plus "latest").
342+
# Older versions beyond this limit are pruned from versions.json and disk.
343+
MAX_VERSIONS = 5
344+
release_versions = [v for v in data["versions"] if v["version"] != "latest"]
345+
if len(release_versions) > MAX_VERSIONS:
346+
pruned = release_versions[MAX_VERSIONS:]
347+
data["versions"] = [v for v in data["versions"] if v not in pruned]
348+
# Delete directories for pruned versions
349+
for p in pruned:
350+
dir_name = p["version"]
351+
if os.path.isdir(dir_name):
352+
shutil.rmtree(dir_name)
353+
print(f"Pruned old version: {dir_name}")
354+
355+
with open(versions_file, "w") as f:
356+
json.dump(data, f, indent=2)
357+
f.write("\n")
358+
359+
print(f"Updated versions.json: {json.dumps(data, indent=2)}")
360+
PYEOF
361+
env:
362+
VERSION: ${{ steps.version.outputs.version }}
363+
364+
- name: Commit and push
365+
run: |
366+
cd gh-pages-deploy
367+
../.github/scripts/gh-pages-commit.sh "Deploy docs ${VERSION} from ${GITHUB_SHA::8}"
368+
env:
369+
VERSION: ${{ steps.version.outputs.version }}

.sqlx/query-0291cd3dd8e309e938cfe237e35b063cc711231c548e5f6639e772d8d5105475.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

.sqlx/query-7e43d4a9d643a88c115257b2322787c50bbe005116b12e5241e53b97c5ea7ff9.json renamed to .sqlx/query-0989ad3f15c5274e2b67e11a9257fdb56e697113caf2e1698a8404318f9b4dcb.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-126f3aa6e9eb3d3a3b5a326e061c69a201a335d325c3694c80ba971d9a8e1b47.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-7cdf5958511c15ecf013ea0e7aacd7526ca9cf52de9f2368b0fa28e2f4298b89.json renamed to .sqlx/query-13dc4eb4d1c680947e5ece023e163fd67ceb605435690129654a16cb1ab622f7.json

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)