Skip to content

Commit

Permalink
chore: init commit py-vibracore
Browse files Browse the repository at this point in the history
  • Loading branch information
RDWimmers committed Nov 8, 2023
1 parent d831a05 commit eafe41c
Show file tree
Hide file tree
Showing 35 changed files with 5,292 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
omit = */tests/*
source = src/pyvibracore
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
# just stop shouting as black decides line lengths.
max-line-length = 180
# E203, W504: due to black fmt
ignore = E203,W503
exclude = ["test*"]
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
33 changes: 33 additions & 0 deletions .github/workflows/deploy_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: deploy docs

on:
push:
branches:
- main

jobs:
deploy_docs:
name: Deploy docs
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: Install python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install .
- name: Build docs
run: sphinx-build -b html docs public

- name: Publish docs
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
43 changes: 43 additions & 0 deletions .github/workflows/release_pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

on:
push:
tags: ['*']

jobs:
deploy:
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/py-vibracore

# Mandatory permission for trusted publishing to PyPi
permissions:
id-token: write

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install dependencies
run: |
pip install setuptools build
- name: Build a binary wheel and a source tarball
run: python3 -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
106 changes: 106 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Test

on:
push:
paths-ignore:
- "docs/**"
- "**.md"
pull_request:
paths-ignore:
- "docs/**"
- "**.md"
workflow_call:

jobs:
test:
name: Unit test
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- '3.9'
- '3.10'
- '3.11'
steps:
- uses: actions/checkout@v3

- name: Install python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
# shellcheck disable=SC2102
pip install -e .[test]
- name: Test
run: coverage run -m pytest

- name: Post coverage results
uses: coverallsapp/github-action@v2
with:
flag-name: run-${{ matrix.python-version }}
parallel: true

finish:
needs: test
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true

lint:
name: Formatting check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed test_files within `super-linter`
fetch-depth: 0

- name: Lint
uses: github/super-linter@v5
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main

VALIDATE_JSCPD: false
VALIDATE_CSS: false
VALIDATE_BASH: false
VALIDATE_YAML: false
VALIDATE_PYTHON_PYLINT: false
VALIDATE_NATURAL_LANGUAGE: false
VALIDATE_MARKDOWN: false

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

LINTER_RULES_PATH: /
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
PYTHON_ISORT_CONFIG_FILE: pyproject.toml
PYTHON_MYPY_CONFIG_FILE: pyproject.toml
PYTHON_FLAKE8_CONFIG_FILE: .flake8

test_docs:
name: Test docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install .
- name: Build docs
run: sphinx-build -b html docs public
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,104 @@
# py-vibracore
Public python SDK for the CEMS VibraCore web-API

[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)


This repository is created by [CEMS BV](https://cemsbv.nl/) and is a public python wrapper around the CEMS [VibraCore web-API](https://nuclei.cemsbv.io/#/vibracore/api).

# Installation

To install a package in this repository run:

`$ pip install py-vibracore`


## ENV VARS

To use `py-vibracore` add the follow ENV vars to your environment. Or provide them when asked.

```
* NUCLEI_TOKEN
- Your NUCLEI user token
```

You can obtain your `NUCLEI_TOKEN` on [NUCLEI](https://nuclei.cemsbv.io/#/).
Go to `personal-access-tokens` and create a new user token.

# Contribution

## Environment

We recommend developing in Python3.9 with a clean virtual environment (using `virtualenv` or `conda`), installing the requirements from the requirements.txt file:

Example using `virtualenv` and `pip` to install the dependencies in a new environment .env on Linux:

```bash
python -m venv .env
source .env/bin/activate
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install -e .
```

## Documentation

Build the docs:

```bash
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install .

sphinx-build -b html docs public
```

## Format

We format our code with black and isort.

```bash
black --config "pyproject.toml" src/pyvibracore tests notebooks
isort --settings-path "pyproject.toml" src/pyvibracore tests notebooks
```

## Lint

To maintain code quality we use the GitHub super-linter.

To run the linters locally, run the `run_super_linters.sh` bash script from the root directory.

## UnitTest

Test the software with the use of coverage:

```bash
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install -e .
coverage run -m pytest
```

## Requirements

Requirements are autogenerated by the `pip-compile` command with python 3.9

Install pip-tools with:

```bash
pip install pip-tools
```

Generate requirements.txt file with:

```bash
pip-compile --extra=test --extra=lint --extra=docs --extra=notebook --output-file=requirements.txt pyproject.toml
```

Update the requirements within the defined ranges with:

```bash
pip-compile --upgrade --extra=test --extra=lint --extra=docs --extra=notebook --output-file=requirements.txt pyproject.toml
```
16 changes: 16 additions & 0 deletions docs/_static/css/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


.red {
color: red;
}

.blue {
color: blue;
}

.green {
color: green;
}
.body {
max-width: 1200px !important;
}
62 changes: 62 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

import os
import sys
from typing import List

sys.path.insert(0, os.path.abspath("../src"))
os.environ["DOC_PATH"] = os.path.dirname(__file__)

import pyvibracore # noqa: E402

project = "py-vibracore"
copyright = "2023, CEMS BV"
author = "Robin Wimmers"

# The full version, including alpha/beta/rc tags
release = pyvibracore.__version__

# 'sphinx.ext.napoleon' Used for numpy docstring support
extensions = [
"IPython.sphinxext.ipython_console_highlighting",
"IPython.sphinxext.ipython_directive",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
"sphinx.ext.autodoc",
"sphinx.ext.mathjax",
"sphinx_autodoc_typehints",
"matplotlib.sphinxext.plot_directive",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns: List = []

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

html_css_files = ["css/index.css"]
Loading

0 comments on commit eafe41c

Please sign in to comment.