Skip to content

Commit 3c655e7

Browse files
authored
Merge pull request #60 from nipreps/codex/automate-markdown-update-for-new-assets
Add workflow to update telemetry charts automatically
2 parents a7ad4e5 + 1ad7557 commit 3c655e7

File tree

3 files changed

+91
-2
lines changed

3 files changed

+91
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Update telemetry charts
2+
3+
on:
4+
push:
5+
branches: [mkdocs]
6+
7+
jobs:
8+
update-charts:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
ref: mkdocs
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.12'
18+
cache: pip
19+
- name: Install requirements
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -r requirements.txt
23+
- name: Update telemetry images
24+
run: |
25+
python scripts/update_telemetry_images.py
26+
- name: Commit changes
27+
run: |
28+
git config user.email "nipreps@gmail.com"
29+
git config user.name "nipreps-bot"
30+
if ! git diff --quiet; then
31+
git commit -am "auto: update telemetry charts"
32+
git push
33+
fi

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ We refer to data *directly consumable by analyses* as ***analysis-grade data***
1515
*NiPreps* were conceived as a generalization of *fMRIPrep* across new modalities, populations, cohorts, and species.
1616
*fMRIPrep* is widely adopted, as our telemetry with Sentry (and now, *in-house* with [migas](https://github.com/nipreps/migas-py)) shows:
1717

18-
| ![fmriprep usage](assets/20250204_weekly.png) |
18+
| ![fmriprep usage](assets/20250620_weekly.png) |
1919
|:--:|
2020
| *fMRIPrep* is executed an average of 11,800 times every week, of which, around 7,800 times it finishes successfully (66.2% success rate). The average number of executions started includes debug and *dry* runs where researchers do not intend actually process data. Therefore, the *effective* (that is, discarding test runs) success ratio of *fMRIPrep* is likely higher. |
2121

22-
| ![fmriprep versions](assets/20250204_versionstream.png) |
22+
| ![fmriprep versions](assets/20250620_versionstream.png) |
2323
|:--:|
2424
| Streamplot of *fMRIPrep*'s version adoption. |

scripts/update_telemetry_images.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2+
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
#
4+
# Copyright 2024 The NiPreps Developers <nipreps@gmail.com>
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# We support and encourage derived works from this project, please read
19+
# about our expectations at
20+
#
21+
# https://www.nipreps.org/community/licensing/
22+
#
23+
"""Update references to telemetry charts on the landing page."""
24+
25+
import re
26+
from pathlib import Path
27+
28+
29+
ASSETS_DIR = Path(__file__).parent.parent / "docs" / "assets"
30+
INDEX_FILE = Path(__file__).parent.parent / "docs" / "index.md"
31+
32+
WEEKLY_RE = re.compile(r"assets/\d{8}_weekly.png")
33+
VERSIONSTREAM_RE = re.compile(r"assets/\d{8}_versionstream.png")
34+
35+
36+
def _latest(pattern: str) -> str | None:
37+
files = sorted(ASSETS_DIR.glob(pattern))
38+
return files[-1].name if files else None
39+
40+
41+
def main(argv=None): # noqa: D401
42+
"""Update the links in the index page to the newest telemetry charts."""
43+
weekly_file = _latest("*_weekly.png")
44+
version_file = _latest("*_versionstream.png")
45+
46+
if not weekly_file or not version_file:
47+
return
48+
49+
text = INDEX_FILE.read_text()
50+
text = WEEKLY_RE.sub(f"assets/{weekly_file}", text)
51+
text = VERSIONSTREAM_RE.sub(f"assets/{version_file}", text)
52+
INDEX_FILE.write_text(text)
53+
54+
55+
if __name__ == "__main__":
56+
main()

0 commit comments

Comments
 (0)