Skip to content
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

Documentation and type checking #11

Merged
merged 43 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a296074
first attempt at docs
jat255 Sep 26, 2024
0725213
add ruff cache to gitignore
jat255 Sep 26, 2024
7bf1597
fix isort on conf.py
jat255 Sep 26, 2024
eee671c
conda GH actions test
jat255 Sep 26, 2024
766d3bb
put environment file in conda setup action
jat255 Sep 26, 2024
1a77b45
try adding CUDA to actions matrix
jat255 Sep 26, 2024
d3800c5
remove CUDA (can't use on standard GH action runners)
jat255 Sep 27, 2024
6e68baf
Test doc build in GH action
jat255 Sep 27, 2024
0d9e99d
upload built docs artifact
jat255 Sep 27, 2024
6c1836e
try check links
jat255 Sep 27, 2024
1971466
try installing CUDA so astra-toolbox can be installed using poetry
jat255 Sep 27, 2024
cf536ed
try setting up re-usable installation workflow
jat255 Sep 27, 2024
6693971
add poetry to reusable actions
jat255 Sep 27, 2024
6c68bf2
add dependencies and poetry pytest runs
jat255 Sep 27, 2024
78bd53a
fix ruff issues that only sometimes appeared?
jat255 Sep 27, 2024
211263c
test switching branch
jat255 Sep 27, 2024
e7e34b5
try committing docs to nist-pages using action
jat255 Sep 27, 2024
f171393
Get doc navigation working better
jat255 Sep 30, 2024
9c7ceca
add type hints to align module, add intersphinx, fix some docstrings,
jat255 Oct 1, 2024
1447499
add explicit groups for methods and classes
jat255 Oct 1, 2024
885bebc
Improve base.py docstrings
jat255 Oct 2, 2024
37a9226
Fix align.py type issues and datasets.py docstrings
jat255 Oct 2, 2024
7338ffb
Improve io, recon, simulation, and utils.py docstrings (add type hints)
jat255 Oct 3, 2024
772059b
fix remaining lint issues and get tests passing again
jat255 Oct 3, 2024
095c873
update README and add some context to API reference page
jat255 Oct 4, 2024
4b98242
fix various sphinx warnings to ensure a clean doc build
jat255 Oct 4, 2024
7d43259
Make recon.run take numpy array to be consistent with the rest of the…
jat255 Oct 4, 2024
b2b2cfc
Make CommonStack explicitly abstract so it cannot be instantiated dir…
jat255 Oct 4, 2024
bf6ce87
add typing_extensions for 3.10 support
jat255 Oct 4, 2024
2e8cd33
First attempt at rendering notebook in documentation
jat255 Oct 5, 2024
29254f1
update example notebook with CUDA outputs
jat255 Oct 5, 2024
a49654d
add some fancy badges and a section for developer installation
jat255 Oct 5, 2024
b873114
update pystackreg to 0.2.8 and numpy to 2.0
jat255 Oct 5, 2024
b0ed3ef
add missing cuda argument to stack_register
jat255 Oct 5, 2024
483f8e7
update README with updated test information
jat255 Oct 8, 2024
b460617
add coverage, pytest-cov, and pytest-mpl, and improve test running
jat255 Oct 8, 2024
15b01c8
update align.py to 100% (without CUDA)
jat255 Oct 8, 2024
d5585f7
Remove pytest-mpl since I couldn't get it to work reliably on CI/CD
jat255 Oct 11, 2024
a724218
bump version and add version check to test
jat255 Oct 11, 2024
7c2049c
pin sphinx due to https://github.com/jbms/sphinx-immaterial/issues/39…
jat255 Oct 11, 2024
33ce44f
retrigger checks
jat255 Oct 11, 2024
dd3f80d
try to limit doc deploy to master branch only on main repo
jat255 Oct 11, 2024
7c92be8
run test suite on PRs also
jat255 Oct 11, 2024
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
28 changes: 28 additions & 0 deletions .github/actions/install-with-conda/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Install ETSpy with conda
description: Uses conda package manager to install ETSpy and its dependencies
inputs:
conda-env-name:
default: etspy
type: string
python-version:
default: "3.12"
type: string
required: true

runs:
using: "composite"
steps:
- name: Setup conda environment
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: ${{ inputs.conda-env-name }}
environment-file: resources/etspy-dev.yml
auto-update-conda: true
python-version: ${{ inputs.python-version }}
auto-activate-base: false
- name: Conda list
run: conda list
shell: bash -el {0}
- name: Install etspy development
run: which pip && pip install -e ./
shell: bash -el {0}
34 changes: 34 additions & 0 deletions .github/actions/install-with-poetry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Install ETSpy with poetry
description: Uses poetry and CUDA action to install ETSpy and its dependencies
inputs:
python-version:
default: "3.12"
type: string
required: true
with-cuda:
default: false
type: boolean
poetry-options:
default: ""
type: string
required: false

runs:
using: "composite"
steps:
- name: Setup python interpreter
uses: actions/[email protected]
with:
python-version: ${{ inputs.python-version }}
- name: Setup poetry
uses: abatilo/[email protected]
- name: Install CUDA dependencies
if: ${{ inputs.with-cuda == 'true' }}
uses: Jimver/[email protected]
with:
method: network
sub-packages: '["cudart"]'
non-cuda-sub-packages: '["libcufft"]'
- name: Install ETSpy using poetry
run: poetry install ${{ inputs.poetry-options }}
shell: bash -el {0}
73 changes: 73 additions & 0 deletions .github/actions/push-doc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# adapted from https://github.com/hyperspy/.github/blob/main/.github/workflows/push_doc.yml
name: Push documentation
description: Uses git to push the documentation to a particular branch
inputs:
artifact_name:
description: 'The name of the github artifact containing the doc'
# if empty string, the current repository name is used
default: 'doc_html'
type: string
repository:
description: 'The repository, for example "usnistgov/etspy"'
# if empty string, the current repository name is used
default: ''
type: string
branch:
description: 'The branch to push to, for example "gh-pages"'
default: 'gh-pages'
type: string
output_path:
description: 'The path where the doc will be written'
default: '.'
type: string
secrets:
access_token:
description: 'The access token required to push a repository: "GITHUB_TOKEN" if same repository of personal access token for separate repository'
# See https://github.com/ad-m/github-push-action/tree/master?tab=readme-ov-file#inputs

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ inputs.repository }}
ref: ${{ inputs.branch }}
# Need to specify token here to enable pushing to other repository
token: ${{ env.ACCESS_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact_name }}
path: ${{ inputs.output_path }}
- name: list files
shell: bash -el {0}
run: |
ls
- name: Git status
shell: bash -el {0}
run: |
git status
git status -s
if [[ $(git status -s) ]]; then
HAS_CHANGES='true'
else
HAS_CHANGES='false'
fi
echo "HAS_CHANGES=${HAS_CHANGES}" >> $GITHUB_ENV
- name: Commit files
# Skip when there is nothing to commit
if: ${{ env.HAS_CHANGES == 'true' }}
shell: bash -el {0}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
git commit -m "Update docs build" -a

- name: Push changes
if: ${{ env.HAS_CHANGES == 'true' }}
uses: ad-m/[email protected]
with:
github_token: ${{ env.ACCESS_TOKEN }}
repository: ${{ inputs.repository }}
branch: ${{ inputs.branch }}
84 changes: 84 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Documentation

on: [push, pull_request]

env:
DOC_SOURCE_PATH: docs
DOC_BUILD_PATH: docs/_build/html
DOC_ARTIFACT_NAME: doc_html
PAGES_BRANCH: nist-pages

jobs:
build-documentation:
name: Build docs
runs-on: ubuntu-latest
steps:
- name: Checkout latest commit
uses: actions/checkout@v4
- name: Set up CUDA and poetry
uses: ./.github/actions/install-with-poetry
with:
with-cuda: true
poetry-options: "--with=dev"
python-version: "3.11" # use 3.11 due to flaky pystackreg install on 3.12
- name: Check links
run: |
cd ${{ env.DOC_SOURCE_PATH }}
poetry run make linkcheck
- name: Build docs
run: |
cd ${{ env.DOC_SOURCE_PATH }}
poetry run make html
- name: Upload built docs artifact
uses: actions/upload-artifact@v4
with:
path: ${{ env.DOC_BUILD_PATH }}
name: ${{ env.DOC_ARTIFACT_NAME }}

deploy-docs:
name: Deploy documentation
runs-on: ubuntu-latest
needs: build-documentation
if: ${{ (github.repository_owner == 'usnistgov' && github.ref_name == 'master') || github.repository_owner != 'usnistgov' }}
permissions:
contents: write
steps:
- name: Checkout latest commit
uses: actions/checkout@v4
- name: Commit to ${{ env.PAGES_BRANCH }}
uses: ./.github/actions/push-doc
with:
artifact_name: ${{ env.DOC_ARTIFACT_NAME }}
branch: ${{ env.PAGES_BRANCH }}
env:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Push_dev:
# needs: Build
# # Push only on the "RELEASE_next_minor" and update the "dev" documentation
# if: ${{ github.repository_owner == 'hyperspy' && github.ref_name == 'RELEASE_next_minor' }}
# permissions:
# # needs write permission to push the docs to gh-pages
# contents: write
# # Use the "reusable workflow" from the hyperspy organisation
# uses: hyperspy/.github/.github/workflows/push_doc.yml@main
# with:
# repository: 'hyperspy/hyperspy-doc'
# output_path: 'dev'
# secrets:
# access_token: ${{ secrets.PAT_DOCUMENTATION }}

# Push_tag:
# needs: Build
# # Push only on tag and update the "current" documentation
# if: ${{ github.repository_owner == 'hyperspy' && startsWith(github.ref, 'refs/tags/') }}
# permissions:
# # needs write permission to push the docs to gh-pages
# contents: write
# # Use the "reusable workflow" from the hyperspy organisation
# uses: hyperspy/.github/.github/workflows/push_doc.yml@main
# with:
# repository: 'hyperspy/hyperspy-doc'
# output_path: 'current'
# secrets:
# access_token: ${{ secrets.PAT_DOCUMENTATION }}
74 changes: 58 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,66 @@
name: CI
on: push
on: [push, pull_request]

jobs:
format-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install ruff isort
- run: isort . --check
- run: ruff check
- name: Set up poetry
uses: ./.github/actions/install-with-poetry
with:
with-cuda: false
poetry-options: "--only=dev"
- run: poetry run isort . --check
- run: poetry run ruff check

pytest:
runs-on: ubuntu-latest
container:
image: aaherzing/etspy:latest
conda-pytest:
name: "conda pytest: (${{ matrix.python-version }}, ${{ matrix.os }})"
runs-on: ${{ matrix.os }}
needs: [ format-checks ]
defaults:
run:
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout latest commit
uses: actions/checkout@v4
- name: Install with conda
uses: ./.github/actions/install-with-conda
with:
python-version: ${{ matrix.python-version }}
- name: Run docstring example tests
run: pytest --doctest-modules --ignore=etspy/tests etspy/
- name: Run full test suite
id: full_conda_tests
if: always()
run: pytest etspy/tests/

poetry-pytest:
name: "poetry pytest: (${{ matrix.python-version }}, ${{ matrix.os }})"
runs-on: ${{ matrix.os }}
needs: [ format-checks ]
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Install ETSpy
run: pip install -e ./
- name: Run docstring example tests
run: pytest --doctest-modules --ignore=etspy/tests etspy/
- name: Run full test suite
if: always()
run: pytest etspy/tests/
- name: Checkout latest commit
uses: actions/checkout@v4
- name: Install with poetry
uses: ./.github/actions/install-with-poetry
with:
python-version: ${{ matrix.python-version }}
with-cuda: true
poetry-options: "--with=dev"
- name: Run docstring example tests
run: poetry run pytest --doctest-modules --ignore=etspy/tests etspy/
- name: Run full test suite
id: full_poetry_tests
if: always()
run: poetry run pytest etspy/tests/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ coverage.xml
*.cover
.hypothesis/
.pytest_cache/
.ruff_cache/

# Translations
*.mo
Expand All @@ -68,6 +69,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/api/

# PyBuilder
target/
Expand Down
Loading
Loading