Skip to content

Commit

Permalink
Merge pull request #1 from JakobEliasWagner/wip-inital-setup
Browse files Browse the repository at this point in the history
Wip inital setup
  • Loading branch information
JakobEliasWagner authored Nov 3, 2023
2 parents 6fffc5a + 83b6196 commit 1eb9b6b
Show file tree
Hide file tree
Showing 17 changed files with 285 additions and 33 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: CI

on: [ push ]

jobs:
hooks:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
architecture: 'x64'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
architecture: 'x64'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest and build coverage reports
run: |
pytest test --cov=src --cov-report=html:codecov --cov-report=json
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: covdata
path: |
coverage.json
- name: package coverage report
run: |
zip -r coverage_report.zip codecov
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: covdata-html
path: coverage_report.zip


coverage-reports:
name: coverage
needs: test
if: ${{ github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
name: Checkout
- name: Download coverage data
uses: actions/download-artifact@v3
with:
name: covdata
- name: Download coverage report
uses: actions/download-artifact@v3
with:
name: covdata-html
- name: Unpack coverage report and move into sphinx
run: |
unzip coverage_report.zip
mv codecov doc/source/_static/codecov
- name: build website for detailed coverage
run: |
pip install sphinx
sphinx-build -M html doc/source doc/build
- name: deploy website
uses: peaceiris/actions-gh-pages@v3
with:
publish_branch: deployed-pages
github_token: ${{ secrets.DEPLOY_TOKEN }}
publish_dir: doc/build/html/
force_orphan: true
- name: Create json for badge
run: |
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
- name: Make badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: 715271f51dd7b16c37fcf84c79dcb31a
filename: covbadge.json
label: Coverage
message: ${{ env.total }}%
minColorRange: 50
maxColorRange: 95
valColorRange: ${{ env.total }}
48 changes: 16 additions & 32 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ share/python-wheels/
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

Expand Down Expand Up @@ -82,31 +80,7 @@ target/
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
Expand Down Expand Up @@ -152,9 +126,19 @@ dmypy.json
# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

.idea
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-case-conflict
- id: check-merge-conflict
- id: no-commit-to-branch
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [ cython ]
- id: isort
name: isort (pyi)
types: [ pyi ]
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
# Neural-Operators
# Neural-Operators
*Master's Thesis by Jakob Wagner*

[![Python 3.8](https://img.shields.io/badge/Python-3.11-blue)](https://www.python.org/downloads/release/python-3110/)
[![Code Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/JakobEliasWagner/715271f51dd7b16c37fcf84c79dcb31a/raw/e1ecebc4ebfaac81fe3225be6d84ebe1069231c2/covbadge.json)](https://jakobeliaswagner.github.io/Neural-Operators/_static/codecov/index.html)
[![Documentation](https://img.shields.io/badge/Documentation-FF7043)](https://jakobeliaswagner.github.io/Neural-Operators/index.html)
[![Linkedin](https://img.shields.io/badge/-LinkedIn-blue?style=flat&logo=linkedin)](https://www.linkedin.com/in/jakob-wagner-65b9871a9/)

## Setup
I recommend setting up a python venv.

Install the required packages and libraries
```shell
pip install -r requirements.txt
```

## Hooks
Install the pre-commit package manager:
```shell
pip install pre-commit
```
Install the git hook scripts
```shell
pre-commit install
```
now `pre-commit` will run automatically on `git commit `.

## Tests
Run tests
```shell
pytest test/
```
12 changes: 12 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions doc/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
Empty file added doc/source/_static/.gitkeep
Empty file.
19 changes: 19 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import sys

sys.path.insert(0, os.path.abspath(os.path.join("..", "..", "src")))

# -- Project information -----------------------------------------------------
project = "Neural Operators"
copyright = "2023, Jakob Wagner"
author = "Jakob Wagner"

# -- General configuration ---------------------------------------------------
extensions = ["sphinx.ext.autodoc"]

templates_path = ["_templates"]
exclude_patterns = []

# -- Options for HTML output -------------------------------------------------
html_theme = "alabaster"
html_static_path = ["_static"]
4 changes: 4 additions & 0 deletions doc/source/coverage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Code Coverage
=============

For an in detail report on the code coverage `click here <_static/codecov/index.html>`_.
6 changes: 6 additions & 0 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Neural Operators
============================================
.. toctree::
:maxdepth: 2

coverage
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[tool.black]
line-length = 79

[tool.isort]
profile = "black"
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 79
skip_glob = [".github/*", ".idea/*", ".pytest_cache/*", "data/*", "docs/*", "models/*", "venv/*"]
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pre-commit
pytest
pytest-cov
Empty file added src/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions src/dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def tmp_dummy_function(x: int, y: int) -> int:
return x + y
Empty file added test/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions test/test_dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from src.dummy import tmp_dummy_function


def test_dummy_function():
assert tmp_dummy_function(1, 2) == 3
6 changes: 6 additions & 0 deletions test/test_pytest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def test_assert_true():
"""
Make sure pytest is running correctly
:return:
"""
assert True

0 comments on commit 1eb9b6b

Please sign in to comment.