Skip to content

Commit

Permalink
Merge pull request #3 from scientificcomputing/finsberg/updates
Browse files Browse the repository at this point in the history
Restructure repo and add workflow for reproducing results
  • Loading branch information
finsberg authored Nov 7, 2023
2 parents eb9eaff + 2327f4f commit 363f6c0
Show file tree
Hide file tree
Showing 25 changed files with 935 additions and 380 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
data/*
code/results/*
code/figures/*
_build


### Python ###
Expand Down
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

49 changes: 42 additions & 7 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Github Pages
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

Expand All @@ -16,22 +19,54 @@ jobs:
PUBLISH_DIR: ./_build/html

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Cache
id: cache
uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/_build
key: cache_v1
restore-keys: |
cache_v1
- name: Install dependencies
run: python3 -m pip install -r requirements-docs.txt


- name: Build docs
run: jupyter book build .
- name: Upload documentation as artifact
uses: actions/upload-artifact@v3

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
name: documentation
path: ${{ env.PUBLISH_DIR }}
if-no-files-found: error

# Single deploy job since we're just deploying
deploy:
if: github.ref == 'refs/heads/main'
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Pages
uses: actions/configure-pages@v3


- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
54 changes: 0 additions & 54 deletions .github/workflows/deploy.yml

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Pre-commit

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]


jobs:
check-code:
runs-on: ubuntu-22.04
steps:
# This action sets the current path to the root of your github repo
- uses: actions/checkout@v4

- name: Install pre-commit
run: python3 -m pip install pre-commit

- name: Run hooks
run: pre-commit run --all
59 changes: 59 additions & 0 deletions .github/workflows/reproduce_results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Simple workflow for deploying static content to GitHub Pages
name: Reproduce results

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
workflow_call:


jobs:
run:
runs-on: ubuntu-22.04
env:
# Directory that will be published on github pages
DATAPATH: ./artifacts/data/data.json
FIGDIR: ./artifacts/figures
RESULTDIR: ./artifacts/results

steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Cache
id: cache
uses: actions/cache@v3
with:
path: |
~/.cache/pip
key: cache_v1
restore-keys: |
cache_v1
- name: Install dependencies
run: python3 -m pip install -r requirements.txt

- name: Run pre-processing
run: python3 code/pre_processing.py --datapath=${{ env.DATAPATH }}

- name: Run simulation
run: python3 code/run_all.py --resultdir=${{ env.RESULTDIR }}

- name: Postprocess
run: python3 code/postprocess.py --resultdir=${{ env.RESULTDIR }} --datapath=${{ env.DATAPATH }} --figdir=${{ env.FIGDIR }}

- name: Upload artifact
if: always()
uses: actions/upload-artifact@v3
with:
path: ./artifacts
if-no-files-found: error
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
_build
code/results
data/data.txt
data/data.json
code/figures
.DS_Store
# Created by https://www.toptal.com/developers/gitignore/api/python,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=python,visualstudiocode

Expand Down
33 changes: 16 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-docstring-first
- id: debug-statements
- id: requirements-txt-fixer
- id: check-added-large-files
- id: check-toml

- repo: https://github.com/asottile/reorder_python_imports
rev: v3.8.3
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: reorder-python-imports
- id: add-trailing-comma

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.10.1
hooks:
- id: black

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.1.4'
hooks:
- id: flake8
- id: ruff

- repo: https://github.com/asottile/add-trailing-comma
rev: v2.3.0
hooks:
- id: add-trailing-comma

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
rev: v1.6.1
hooks:
- id: mypy

- repo: https://github.com/asottile/pyupgrade
rev: v3.1.0
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v7.3.2
hooks:
- id: pyupgrade
args: [--py38-plus]
- id: cspell
files: docs/(.+).md|README.md
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

This repository contains supplementary code for the paper
> Finsberg, H., Dokken, J. 2022.
> Title of paper, Journal of blabla, volume, page, url
> Title of paper, Journal of ..., volume, page, url

## Abstract
Provide the abstract of the paper

## Getting started

We provide a pre-build Docker image which can be used to run the the code in this repository. First thing you need to do is in ensure that you have [docker installed](https://docs.docker.com/get-docker/).
We provide a pre-build Docker image which can be used to run the the code in this repository. First thing you need to do is to ensure that you have [docker installed](https://docs.docker.com/get-docker/).

To start an interactive docker container you can execute the following command

Expand Down
16 changes: 14 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# Learn more at https://jupyterbook.org/customize/config.html

title: Example paper
author: Henrik Finsberg
author: Henrik Finsberg and Jørgen Dokken
logo: "docs/logo.png"
copyright: "2022"
copyright: "2023"
only_build_toc_files: true

# Force re-execution of notebooks on each build.
# See https://jupyterbook.org/content/execute.html
Expand All @@ -30,13 +31,24 @@ parse:
- dollarmath
- linkify


sphinx:
config:
bibtex_bibfiles: ["docs/refs.bib"]
nb_execution_show_tb: True
html_theme_options:
navigation_with_keys: false
html_last_updated_fmt: "%b %d, %Y"
nb_custom_formats: # https://jupyterbook.org/en/stable/file-types/jupytext.html#file-types-custom
.py:
- jupytext.reads
- fmt: py

extra_extensions:
- 'sphinx.ext.autodoc'
- 'sphinx.ext.napoleon'
- 'sphinx.ext.viewcode'
- "sphinxcontrib.bibtex"


exclude_patterns: [".pytest_cache/*", ".github/*"]
2 changes: 1 addition & 1 deletion _toc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
format: jb-book
root: index
root: README

chapters:
- file: docs/abstract
Expand Down
Loading

0 comments on commit 363f6c0

Please sign in to comment.