Skip to content

Commit

Permalink
feat: add scripts to improve the release process 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislemke committed Dec 22, 2022
1 parent fd1575c commit 54a9dfe
Show file tree
Hide file tree
Showing 41 changed files with 615 additions and 234 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ name: BuildDocs
on:
push:
branches:
- main
- "main"

jobs:
deploy:
if: ${{ startsWith(github.event.head_commit.message, 'chore(main)') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- run: pip install poetry==1.3.1
- run: poetry install --without dev
- run: poetry install --with docs
- run: poetry run mkdocs gh-deploy --force --clean --verbose
6 changes: 3 additions & 3 deletions .github/workflows/code-cov.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CodeCov
on: [push, pull_request]
on: [pull_request]
jobs:
run:
runs-on: ubuntu-latest
Expand All @@ -13,8 +13,8 @@ jobs:
- name: Install dependencies and project
run: |
python -m pip install poetry==1.3.1
poetry install --without devs --without docs
poetry install --with test
- name: Run tests and collect coverage
run: poetry run pytest --cov sk_transformers --cov-report term-missing --cov-report xml
run: poetry run pytest --cov src/sk_transformers --cov-report term-missing --cov-report xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ name: "CodeQL"

on:
push:
branches: ["main", "develop"]
branches: ["develop"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["main", "develop"]
branches: ["develop"]
schedule:
- cron: "32 22 * * 2"
- cron: "27 21 * * 4"

jobs:
analyze:
Expand All @@ -33,6 +33,10 @@ jobs:
fail-fast: false
matrix:
language: ["python"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
Expand All @@ -50,7 +54,7 @@ jobs:
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/deploy-package.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: DeployPackage

on:
push:
branches:
- main
- "main"

jobs:
deploy:
if: ${{ startsWith(github.event.head_commit.message, 'chore(main)') }}
runs-on: ubuntu-latest
environment: deploy-package
steps:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Release
on:
push:
branches:
- main
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
with:
release-type: python
package-name: sk-transformers
prerelease: true
default-branch: main
pull-request-header: ":robot: I have created a release *beep* *boop*. This was predictable."
19 changes: 8 additions & 11 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Testing
on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop"]

on: [pull_request]

jobs:
build:
Expand All @@ -21,22 +18,22 @@ jobs:
- name: Install dependencies and project
run: |
python -m pip install poetry==1.3.1
poetry install
poetry install --with test
- name: Check with isort
run: |
poetry run isort --check-only ./sk_transformers ./tests
poetry run isort --check-only .
- name: Check with black
run: |
poetry run black --check ./sk_transformers ./tests
poetry run black --check ./src/sk_transformers ./tests
- name: Check with mypy
run: |
poetry run mypy --config-file=pyproject.toml .
- name: Check with bandit
run: |
poetry run bandit -r ./sk_transformers/*
poetry run bandit -r ./src/sk_transformers/*
- name: Lint with pylint
run: |
poetry run pylint --rcfile=pyproject.toml ./sk_transformers ./tests
poetry run pylint --rcfile=pyproject.toml ./src/sk_transformers ./tests
- name: Test with pytest
run: |
poetry run pytest --cov sk_transformers --cov-fail-under=99 --cov-report term-missing
poetry run pytest --cov src/sk_transformers --cov-fail-under=90 --cov-report term-missing
44 changes: 32 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.1.1
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args:
[
"build",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
"security",
]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
Expand All @@ -17,23 +37,28 @@ repos:
- id: fix-byte-order-marker
- id: forbid-new-submodules

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade

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

- repo: https://github.com/PyCQA/pylint
rev: v2.15.8
hooks:
- id: pylint
args: ["--rcfile=pyproject.toml"]

- repo: https://github.com/PyCQA/isort
rev: 5.11.1
rev: 5.11.4
hooks:
- id: isort
args: ["--profile=black"]

- repo: https://github.com/PyCQA/pylint
rev: v2.15.9
hooks:
- id: pylint
args: ["--rcfile=pyproject.toml"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
Expand All @@ -50,11 +75,6 @@ repos:
args:
- "-r"

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade

- repo: https://github.com/python-poetry/poetry
rev: 1.3.1
hooks:
Expand Down
6 changes: 6 additions & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
brew "poetry"
brew "pre-commit"
brew "black"
brew "mypy"
brew "pylint"
brew "isort"
42 changes: 17 additions & 25 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
BSD 3-Clause License
MIT License

Copyright (c) 2022, Christopher Lemke and contributors.
All rights reserved.
Copyright (c) 2022 Christopher Lemke

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 29 additions & 8 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,48 @@ pipeline.fit_transform(df).head()
1 Incredible Hulk Schikaneder
2 Tom and Jerry Futuregarden
```
For a non-dummy examples check out the [`MathExpressionTransformer`](number_transformer.md#sk-transformers.transformer.number_transformer.MathExpressionTransformer) or the [`ValueIndicatorTransformer`](generic_transformer.md#sk-transformers.transformer.generic_transformer.ValueIndicatorTransformer) for a simpler example.
For a non-dummy examples check out the [`MathExpressionTransformer`](API-reference/transformer/number_transformer.md#sk-transformers.transformer.number_transformer.MathExpressionTransformer) or the [`ValueIndicatorTransformer`](API-reference/transformer/generic_transformer.md#sk-transformers.transformer.generic_transformer.ValueIndicatorTransformer) for a simpler example.

## Poetry
We are using [Poetry](https://python-poetry.org/) to manage the dependencies, for deployment, and the virtual environment. If you have not used it before please check out the [documentation](https://python-poetry.org/docs/) to get started.
## Pre-commit hooks
We are using [pre-commit](https://pre-commit.com/) to ensure a consistent code style and to avoid common mistakes. Please install the [pre-commit](https://pre-commit.com/#installation) and install the hook with:

```bash
pre-commit install --hook-type commit-msg
```

## Homebrew
We are using [Homebrew](https://brew.sh/) to manage the dependencies for the development environment. Please install Homebrew and run:
```bash
brew bundle
```
to install the dependencies. If you don't want/can't use Homebrew, you can also install the dependencies manually.

## Conventional Commits
We are using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) to ensure a consistent commit message style. Please use the following commit message format:
```bash
<type>[optional scope]: <description>
```

E.g.:
```bash
feat: add a new fantastic plot
```

## How to contribute
The following steps will give a short guide on how to contribute to this project:

- Create a personal [fork](https://github.com/chrislemke/sk-transformers/fork) of the project on [GitHub](https://github.com/).
- Create a personal [fork](https://github.com/invia-flights/blitzly/fork) of the project on [GitHub](https://github.com/).
- Clone the fork on your local machine. Your remote repo on [GitHub](https://github.com/) is called `origin`.
- Add the original repository as a remote called `upstream`.
- If you created your fork a while ago be sure to pull upstream changes into your local repository.
- Create a new branch to work on! Start from from `develop` if it exists, else from `main`.
- Create a new branch to work on! Start from `develop` if it exists, else from `main`.
- Implement/fix your feature, comment your code, and add some examples.
- Follow the code style of the project, including indentation. [Black](https://github.com/psf/black), [isort](https://github.com/PyCQA/isort), [Pylint](https://github.com/PyCQA/pylint), and [mypy](https://github.com/python/mypy) can help you with it.
- Run the tests.
- Run all tests.
- Write or adapt tests as needed.
- Add or change the documentation as needed. Please follow the "[Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)".
- Squash your commits into a single commit with git's [interactive rebase](https://help.github.com/articles/interactive-rebase). Create a new branch if necessary.
- We are using pre-commit-hooks to ensure a consistent code style and to avoid common mistakes. Please install the [pre-commit](https://pre-commit.com/#installation) and install the hook with `pre-commit install`.
- Push your branch to your fork on [GitHub](https://github.com/), the remote `origin`.
- From your fork open a pull request in the correct branch. Target the project's `develop` branch if there is one, else go for `main`!
- From your fork open a pull request in the correct branch. Target the project's `develop` branch!
- Once the pull request is approved and merged you can pull the changes from `upstream` to your local repo and delete
your extra branch(es).
16 changes: 9 additions & 7 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![The Transformer](https://raw.githubusercontent.com/chrislemke/sk-transformers/master/docs/assets/images/image.png)
![The Transformer](https://raw.githubusercontent.com/chrislemke/sk-transformers/master/docs/assets/images/icon.png)

# sk-transformers
### A collection of various pandas & scikit-learn compatible transformers for all kinds of preprocessing and feature engineering steps 🛠
*** A collection of various pandas & scikit-learn compatible transformers for all kinds of preprocessing and feature engineering steps *** 🛠

[![testing](https://github.com/chrislemke/sk-transformers/actions/workflows/testing.yml/badge.svg?branch=main)](https://github.com/chrislemke/sk-transformers/actions/workflows/testing.yml)
[![codecov](https://codecov.io/github/chrislemke/sk-transformers/branch/main/graph/badge.svg?token=LJLXQXX6M8)](https://codecov.io/github/chrislemke/sk-transformers)
Expand All @@ -11,10 +11,11 @@
[![downloads](https://img.shields.io/pypi/dm/sk-transformers)](https://pypistats.org/packages/sk-transformers)
[![docs](https://img.shields.io/badge/docs-mkdoks%20material-blue)](https://chrislemke.github.io/sk-transformers/)
[![license](https://img.shields.io/github/license/chrislemke/sk-transformers)](https://github.com/chrislemke/sk-transformers/blob/main/LICENSE)
[![mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](https://github.com/python/mypy)
[![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://github.com/PyCQA/isort)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://github.com/PyCQA/isort)
[![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](https://github.com/python/mypy)
[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint)
## Introduction
Every tabular data is different. Every column needs to be treated differently. Pandas is already great! And [scikit-learn](https://scikit-learn.org/stable/index.html) has a nice [collection of dataset transformers](https://scikit-learn.org/stable/data_transforms.html). But the possibilities of data transformation are infinite. This project tries to provide a brought collection of data transformers that can be easily used together with [scikit-learn](https://scikit-learn.org/stable/index.html) - either in a [pipeline](https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html) or just on its own. See the [usage chapter](#usage) for some examples.

Expand Down Expand Up @@ -47,7 +48,7 @@ Let's assume you want to use some method from [NumPy's mathematical functions, t
use the [`MathExpressionTransformer`](https://chrislemke.github.io/sk-transformers/number_transformer-reference/#sk-transformers.transformer.number_transformer.MathExpressionTransformer).
```python
import pandas as pd
from sk_transformers import MathExpressionTransformer
from sk_transformers.number_transformer import MathExpressionTransformer

X = pd.DataFrame({"foo": [1, 2, 3], "bar": [4, 5, 6]})
transformer = MathExpressionTransformer([("foo", "np.sum", "bar", {"axis": 0})])
Expand All @@ -64,7 +65,8 @@ In the next example, we additionally add the [`MapTransformer`](https://chrislem
Together with [scikit-learn's pipelines](https://scikit-learn.org/stable/modules/compose.html#combining-estimators) it would look like this:
```python
import pandas as pd
from sk_transformers import MapTransformer, MathExpressionTransformer
from sk_transformers.number_transformer import MathExpressionTransformer
from sk_transformers.generic_transformer import MapTransformer
from sklearn.pipeline import Pipeline

X = pd.DataFrame({"foo": [1, 2, 3], "bar": [4, 5, 6]})
Expand Down
Binary file added docs/assets/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/assets/images/image.png
Binary file not shown.
Binary file removed docs/assets/images/logo.png
Binary file not shown.
Empty file added docs/javascripts/extras.js
Empty file.
16 changes: 16 additions & 0 deletions docs/javascripts/mathjax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};

document$.subscribe(() => {
MathJax.typesetPromise()
})
6 changes: 6 additions & 0 deletions docs/javascripts/tablesort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
document$.subscribe(function () {
var tables = document.querySelectorAll("article table:not([class])")
tables.forEach(function (table) {
new Tablesort(table)
})
})
Loading

0 comments on commit 54a9dfe

Please sign in to comment.