Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
76e776c
docs: get started on using astromodels in gammapy docs
PreisTo May 22, 2026
658e718
docs: warning on experimental unit setting
PreisTo May 26, 2026
54a810e
test: add test framework for fitting with gammapy
PreisTo May 26, 2026
ec6bf74
refactor: isort
PreisTo May 26, 2026
34a6c36
Merge branch 'dev' into 5-feat-update-astromodels-via-gammapy-skymodel
PreisTo May 28, 2026
deae5bc
add: public update method
PreisTo May 28, 2026
06d0396
docs: fix kernel name
PreisTo May 28, 2026
1997bbb
docs: add gammapy-datasets
PreisTo May 28, 2026
7630972
chore: clean up rtd config
PreisTo May 29, 2026
fe094b0
ci: add building jupytext job
PreisTo May 29, 2026
c4caa30
add: public update method
PreisTo May 28, 2026
002e3a3
add: public update method for converter
PreisTo May 29, 2026
b611c73
ci: fix the sha also for PRs
PreisTo May 29, 2026
5ff1c32
ci: why cant it be just bash ...
PreisTo May 29, 2026
e05d3d1
docs: try downloading notebooks
PreisTo May 29, 2026
46c7e65
ci: syntax fix getting branch name
PreisTo May 29, 2026
1aec26b
ci: try again
PreisTo May 29, 2026
2267c8d
ci: use v3 api instead
PreisTo May 29, 2026
d9f035e
docs: use ultranest for notebook building
PreisTo May 29, 2026
aaeac6c
ci: fix versioning triggering
PreisTo May 29, 2026
25aa9f8
ci: syntax fix
PreisTo May 29, 2026
38093c2
docs: rtd download switch to python instead of jq for parsing
PreisTo May 29, 2026
b246733
Merge pull request #8 from threeML/7-feat-fix-readthedocs-build
PreisTo May 29, 2026
5d4d2db
Merge branch 'dev' into 5-feat-update-astromodels-via-gammapy-skymodel
PreisTo May 29, 2026
0827c64
docs: add astromodels in gammapy notebook to toctree
PreisTo May 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 42 additions & 126 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,152 +1,68 @@
name: Docs
on: [release]
on:
push:
branches:
- main
- dev
tags:
- "v*"
pull_request:
branches:
- main
- dev
release:

permissions:
contents: write # 'write' access to repository contents
pull-requests: write # 'write' access to pull requests

jobs:
notebooks:
build-notebooks:
name: "Build the notebooks for the docs"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set SHA
run: |
SHA="${{ github.event.pull_request.head.sha || github.sha }}"
echo "SHA=$SHA" >> "$GITHUB_ENV"
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.11
- uses: conda-incubator/setup-miniconda@v4
with:
auto-activate-base: true
activate-environment: ""
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge, threeml, defaults

python-version: 3.13
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install numpy==2.1
pip install matplotlib==3.8.4
pip install black
pip install ipython jupyter cython astropy
conda install jupytext jupyterthemes emcee pymultinest ultranest nbconvert ipykernel astropy regions threeML astromodels gammapy
pip install .
pip install black ultranest
pip install -e .
pip install -r docs/requirements.txt

- name: Execute the notebooks
shell: bash -l {0}
run: |
pip install .
export GAMMAPY_DATA=$HOME/data
export GAMMAPY_DATA="/home/runner/work/gammapy_data"
mkdir -p $GAMMAPY_DATA
git clone https://github.com/gammapy/gammapy-data.git $GAMMAPY_DATA
jupytext --to ipynb --pipe black --execute docs/md/*.md
jupytext --to ipynb --pipe black --execute docs/md_docs/*.md
mkdir -p docs/notebooks
mv docs/md/*.ipynb docs/notebooks

mv docs/md_docs/*.ipynb docs/notebooks
echo "Next - uploading artifacts for sha ${SHA}"
- uses: actions/upload-artifact@v6
with:
name: notebooks-for-${{ github.sha }}
name: notebooks-for-${{ env.SHA }}
path: docs/notebooks

api_doc:
name: "Create the API stubs"
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

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

- name: Build the API doc
run: |

brew install c-blosc
brew install hdf5

pip3 install --upgrade pip
pip3 install cython
pip3 install numpy==2.1
pip3 install --upgrade scipy numba astropy
pip3 install matplotlib==3.8.4
pip3 install .

brew install sphinx-doc pandoc

pip3 install wheel
pip3 install mock recommonmark
pip3 install sphinx_rtd_theme
pip3 install -U sphinx nbsphinx sphinx-gallery



sphinx-apidoc -f -o docs/api/ gammapy_plugin

- uses: actions/upload-artifact@v6
with:
name: api-stubs-for-${{ github.sha }}
path: docs/api

build_docs:
name: "Build the Documentation"
runs-on: macos-latest
needs: [notebooks, api_doc]
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

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

- name: Install package
- name: Trigger RTD
shell: bash -l {0}
run: |
curl -X POST \
"https://app.readthedocs.org/api/v3/projects/gammapy-plugin/versions/${PR_NUMBER}/builds/" \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"branch\": \"${BRANCH}\"
}"

brew install c-blosc
brew install hdf5
pip3 install numpy scipy numba astropy matplotlib==3.8.4
brew install sphinx-doc pandoc

pip3 install wheel
pip3 install mock recommonmark
pip3 install sphinx_rtd_theme
pip3 install -U sphinx nbsphinx sphinx-gallery
pip3 install threeML
pip3 install --upgrade git+https://github.com/threeml/astromodels.git
pip3 install --upgrade git+https://github.com/threeml/threeML.git
pip3 install --upgrade gammapy --use-pep517


pip3 install -e .

rm -rf docs/md/*
env:
ISDEV: ${{contains(github.rev,'dev') || contains(github.base_ref, 'dev')}}

- uses: actions/download-artifact@master
with:
name: notebooks-for-${{ github.sha }}
path: docs/notebooks

- uses: actions/download-artifact@master
with:
name: api-stubs-for-${{ github.sha }}
path: docs/notebooks/api

- name: Build and Commit
uses: sphinx-notes/pages@master
with:
documentation_path: docs
sphinx_version: 5.1.1
requirements_path: docs/requirements.txt

- name: Push changes
if: github.event_name == 'push'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
TOKEN: ${{ secrets.RTD_API }}
BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }}
PR_NUMBER: ${{ github.event.number || 'latest' }}
14 changes: 1 addition & 13 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-24.04
tools:
python: "3.12"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"
jobs:
pre_build:
- sphinx-apidoc . -o docs/api
- jupytext --to ipynb --pipe black --execute docs/md_docs/*.md
- mv docs/md_docs/*.ipynb docs/notebooks
- bash docs/download_notebooks.sh

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py
fail_on_warning: false

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

python:
install:
- requirements: docs/requirements.txt
Expand Down
63 changes: 63 additions & 0 deletions docs/download_notebooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
set -euo pipefail

OWNER="threeML"
REPO="gammapy-plugin"
SHA="${READTHEDOCS_GIT_COMMIT_HASH}"
TOKEN="${GITHUB_TOKEN}"

API="https://api.github.com/repos/$OWNER/$REPO"

echo "Searching artifacts for SHA: $SHA"

ARTIFACT_ID=$(
python3 - <<PY
import os, json, urllib.request

owner = "$OWNER"
repo = "$REPO"
sha = "$SHA"
token = "$TOKEN"

url = f"https://api.github.com/repos/{owner}/{repo}/actions/artifacts?per_page=100"

req = urllib.request.Request(url)
req.add_header("Accept", "application/vnd.github+json")
req.add_header("Authorization", f"Bearer {token}")

with urllib.request.urlopen(req) as r:
data = json.load(r)

for a in data.get("artifacts", []):
if a.get("expired"):
continue
name = a.get("name", "")
if sha in name:
print(a["id"])
break
PY
)

if [[ -z "$ARTIFACT_ID" ]]; then
echo "No artifact found for SHA: $SHA"
exit 1
fi

echo "Artifact ID: $ARTIFACT_ID"

echo "Downloading artifact..."

curl -fL \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/vnd.github+json" \
"$API/actions/artifacts/$ARTIFACT_ID/zip" \
-o artifact.zip

echo "Downloaded artifact.zip"

mkdir -p docs/notebooks
unzip -o artifact.zip -d docs/notebooks

rm artifact.zip

echo "Done unzipping"
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ To get started check out the `get-started`_ section.

intro
notebooks/converter.ipynb
notebooks/am_in_gp.ipynb

api/API.rst

.. nblinkgallery::

notebooks/crab_spectrum.ipynb
notebooks/converter.ipynb
notebooks/am_in_gp.ipynb

Loading