Skip to content

Commit

Permalink
Merge pull request #140 from IMMM-SFA/dev
Browse files Browse the repository at this point in the history
new release
  • Loading branch information
thurber authored Dec 26, 2024
2 parents 3cb8456 + fd197b2 commit 2c3cd05
Show file tree
Hide file tree
Showing 121 changed files with 4,128 additions and 2,508 deletions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/contribution_proposal.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Contribution Proposal
description:
description:
Want to contribute to our eBook? Fill the following proposal form and we will review your contribution idea shortly.
labels: ["needs triage"]

Expand All @@ -26,7 +26,7 @@ body:
description: Please provide your email address
validations:
required: true

- type: textarea
id: issue-institution
attributes:
Expand All @@ -38,11 +38,11 @@ body:
- type: textarea
id: issue-source
attributes:
label: Referral
label: Referral
description: How did you hear about the eBook?
validations:
required: true

- type: dropdown
id: issue-category
attributes:
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE/contribution_checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Please ensure that you are able to check all of the following boxes before submi
- [ ] My contribution proposal has been approved
- [ ] I have performed a self-review of my own code
- [ ] All elements of my contribution are fully open-source and can be distributed with an [Open Source Initiative approved license](https://opensource.org/licenses/) with an understanding that they may be used in community demonstrations and other activities. Author citations will be present in the notebook for any contributed work to ensure the author(s) receive full credit for their contribution.
- [ ] Any data or code reused in your submission are correctly cited giving credit to the original authors.
- [ ] Any data or code reused in your submission are correctly cited giving credit to the original authors.
- [ ] The notebook provided is written in English and able to be a stand-alone product that needs no further explanation past what is written in the notebook to make use of it.
- [ ] The provided work is not merely a regurgitation of an existing tutorial or demonstration but represents a novel contribution.
- [ ] All contributions and communication thereof must abide by our [code of conduct](https://uc-ebook.org/docs/html/code_of_conduct.html).
Expand Down
77 changes: 50 additions & 27 deletions .github/workflows/01_test.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,66 @@
name: Build
name: Test

on:
push:
branches: [ main, dev ]
branches:
- main
- dev
pull_request:
branches:
- main
- dev

schedule:
- cron: '0 8 * * 1' # Runs every monday at 12am Pacific time

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
strategy:
matrix:
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
os: [ ubuntu-latest ]
fail-fast: false

env:
OS: ${{ matrix.os }}
PYTHON: '3.9'
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

steps:
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}

- name: Set up Python
uses: actions/setup-python@master
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install pytest-mock
run: |
pip install pytest-mock
- name: Test and generate coverage report
run: |
- name: Test and generate coverage report
run: |
pip install pytest
pip install pytest-cov
pytest --cov=./ --cov-report=xml
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v1
# with:
# file: ./coverage.xml
# fail_ci_if_error: true
- uses: codecov/codecov-action@v4
with:
files: ./coverage.xml # optional
name: codecov-umbrella # optional
token: ${{ secrets.CODECOV_TOKEN }} # required

- name: Notify on failure
if: failure() # This step will only run if any previous step fails
run: |
echo "Build or tests failed. Please check the logs."
- name: Test and generate coverage report
run: |
pip install pytest
pip install pytest-cov
pip install pytest-mock # Ensure pytest-mock is installed before testing
pytest --cov=./ --cov-report=xml # Run tests and generate a coverage report
4 changes: 2 additions & 2 deletions .github/workflows/02_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
working-directory: 'docs/'
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install ".[docs]"
- name: Build html and pdf ebook
working-directory: 'docs/'
run: |
Expand Down Expand Up @@ -91,4 +91,4 @@ jobs:
branch: gh-pages
directory: landing/build
force: true
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
13 changes: 6 additions & 7 deletions .github/workflows/03_dev_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/setup-python@master
with:
python-version: '3.9'
- name: Install latex dependencies
run: sudo apt-get update -y && sudo apt-get install -y texlive latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended ghostscript
- name: Update pip and install python dependencies
working-directory: 'docs/'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install ".[docs]"
- name: Build html and pdf ebook
working-directory: 'docs/'
env:
Expand Down Expand Up @@ -48,12 +47,12 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
AWS_REGION: ${{ secrets.AWS_REGION_DEV }}
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile_dev
Expand Down Expand Up @@ -86,4 +85,4 @@ jobs:
branch: gh-pages
directory: deploy
force: true
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
125 changes: 125 additions & 0 deletions .github/workflows/04_publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# This GitHub Action will only push to PyPI if the branch is tagged and then merged to main.
# Tag the branch with:
# $ git push REMOTE-NAME TAG-NAME

name: Publish Python to PyPI

on:
push:
branches:
- main

jobs:
build:
name: Build distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python distribution to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/msdbook
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
Sign the Python distribution with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
publish-to-testpypi:
name: Publish to TestPyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/msdbook

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# msdbook
msdbook/data/

# system
.DS_Store

Expand Down Expand Up @@ -109,7 +112,7 @@ celerybeat.pid

# Environments
.env
.venv
.venv*
env/
venv/
ENV/
Expand Down
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# pre-commit hooks require a user to have installed `pre-commit`:
# $ brew install pre-commit
# Then install the hooks within the repo:
# $ cd /PATH/TO/REPO
# $ pre-commit install

repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.5.5
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix]
exclude: .rst
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
args: [--line-length=100]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-ast
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
13 changes: 5 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
FROM jupyter/minimal-notebook:2022-05-03
FROM ghcr.io/msd-live/jupyter/python-notebook:latest

USER root

RUN git clone https://github.com/IMMM-SFA/msd_uncertainty_ebook.git msd_uncertainty_ebook
RUN git clone --depth=1 --branch=main https://github.com/IMMM-SFA/msd_uncertainty_ebook.git msd_uncertainty_ebook
RUN cd msd_uncertainty_ebook && pip install .

# Now create a symlinked data folder inside the msdbook package that links to /home/demo/data folder
RUN mkdir -p /bucket/data
RUN rm -rf /opt/conda/lib/python3.9/site-packages/msdbook/data
RUN ln -s /bucket/data /opt/conda/lib/python3.9/site-packages/msdbook/data


# Install msdbook data
RUN mkdir -p /opt/conda/lib/python3.11/site-packages/msdbook/data
RUN python -c 'from msdbook.install_supplement import install_package_data; install_package_data()'
11 changes: 4 additions & 7 deletions Dockerfile_dev
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
FROM jupyter/minimal-notebook:2022-05-03
FROM ghcr.io/msd-live/jupyter/python-notebook:latest

USER root

RUN git clone --depth=1 --branch=dev https://github.com/IMMM-SFA/msd_uncertainty_ebook.git msd_uncertainty_ebook
RUN cd msd_uncertainty_ebook && pip install .

# Now create a symlinked data folder inside the msdbook package that links to /home/demo/data folder
RUN mkdir -p /bucket/data
RUN rm -rf /opt/conda/lib/python3.9/site-packages/msdbook/data
RUN ln -s /bucket/data /opt/conda/lib/python3.9/site-packages/msdbook/data


# Install msdbook data
RUN mkdir -p /opt/conda/lib/python3.11/site-packages/msdbook/data
RUN python -c 'from msdbook.install_supplement import install_package_data; install_package_data()'
Loading

0 comments on commit 2c3cd05

Please sign in to comment.