-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: full
scikit-learn
compatibility + general refactor (#241)
- Use `scikit-learn` ≥1.4 metadata routing for full API compatibility - Switch from `setup.py` to `pyproject.toml` - Switch to `poetry` for dependency management - Use `tox` for documentation building, unit tests and linting - Add pre-commit hooks - Add coverage checks via `coveralls` - Drop support for Python <3.11 - Support Python 3.11 and 3.12 - Add issue and pull request templates - Add license information to `.py` files - Update repository documentation - Use `cliff` for `CHANGELOG.md` generation - Update Sphinx documenation - Switch to `numpy` docstring format (via `napoleon`) - Move library code from `lib/` to `sequentia/` - Move unit tests from `lib/test` to `tests/` - Add `sequentia.enums` module for configuration values. - Add `sequentia.version` sub-package for versioning information. - Add `sequentia._internal` sub-package for internal logic. - Remove `sequentia.pipeline` module. - Make topologies internal - Remove `pydantic` validation classes for model inputs - Remove `pydantic` validation for `numpy` arrays - Use key-word only arguments more widely (e.g. for `lengths`) - Use `pydantic.validate_call` for validating constructors and other functions - Use type hinting - Use `ABCMeta` metaclass for base classes (e.g. `ClassifierMixin`/`RegressorMixin` and `BaseHMM`) - Use `abc` decorators for abstract methods - Avoid unnecessarily redefining methods on subclasses for only documentation purposes - Add `predict_log_proba` to classifiers - Move majority of validation logic to `sequentia._internal._validation` module - Prefix all HMM parameter setter functions with `set_state` - Rename `set_transitions` to set_state_transition_probs` - Rename `set_state_emissions` to `set_state_emission_probs` - Rename `set_state_covariances` to `set_state_covars` - Use static methods to define default HMM parameters - Handle KNN querying for single training sequences and single query sequences - Update `IndependentFunctionTransformer` to match `FunctionTransformer` from `scikit-learn` ≥1.4 API - Use `Helpers` fixture class for accessing helper methods in unit tests
- Loading branch information
Showing
167 changed files
with
8,205 additions
and
6,596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,62 @@ | ||
version: 2 | ||
version: "2.1" | ||
|
||
workflows: | ||
version: 2 | ||
test: | ||
jobs: | ||
- python_3.8 | ||
- python_3.9 | ||
- python_3.10 | ||
|
||
template: &template | ||
docker: | ||
- image: ubuntu:bionic | ||
steps: | ||
- checkout | ||
- run: | ||
name: Set up miniconda | ||
command: | | ||
apt update | ||
apt install -y wget | ||
cd $HOME | ||
wget "https://repo.anaconda.com/miniconda/Miniconda3-4.7.10-Linux-x86_64.sh" -O miniconda.sh | ||
printf '%s' "8a324adcc9eaf1c09e22a992bb6234d91a94146840ee6b11c114ecadafc68121 miniconda.sh" | sha256sum -c | ||
bash miniconda.sh -b -p $HOME/miniconda | ||
- run: | ||
name: Set up environment, dependencies and run tests | ||
command: | | ||
export PATH="$HOME/miniconda/bin:$PATH" | ||
conda create -n sequentia python=$PYTHON_VERSION -y | ||
source activate sequentia | ||
pip install ".[dev]" | ||
pytest lib/test --disable-pytest-warnings | ||
orbs: | ||
python: circleci/python@2.1.1 | ||
coveralls: coveralls/coveralls@2.2.1 | ||
|
||
jobs: | ||
python_3.8: | ||
<<: *template | ||
environment: | ||
PYTHON_VERSION: "3.8" | ||
python_3.9: | ||
<<: *template | ||
environment: | ||
PYTHON_VERSION: "3.9" | ||
python_3.10: | ||
<<: *template | ||
environment: | ||
PYTHON_VERSION: "3.10" | ||
linting: | ||
executor: | ||
name: python/default | ||
tag: "3.11" | ||
steps: | ||
- checkout | ||
- python/install-packages: | ||
pkg-manager: poetry | ||
args: --only base | ||
- run: | ||
name: Linting | ||
command: | | ||
poetry run tox -e lint | ||
tests: | ||
parameters: | ||
version: | ||
type: string | ||
executor: | ||
name: python/default | ||
tag: <<parameters.version>> | ||
steps: | ||
- checkout | ||
- python/install-packages: | ||
pkg-manager: poetry | ||
args: --only base | ||
# - run: | ||
# name: Docstring tests | ||
# command: | | ||
# poetry run tox -e tests.doctest | ||
- run: | ||
name: Unit tests | ||
command: | | ||
poetry run -- tox -e tests -- --cov | ||
- coveralls/upload: | ||
flag_name: <<parameters.version>> | ||
parallel: true | ||
coverage: | ||
executor: | ||
name: python/default | ||
steps: | ||
- coveralls/upload: | ||
carryforward: 3.11, 3.12 | ||
parallel_finished: true | ||
|
||
workflows: | ||
checks: | ||
jobs: | ||
- linting | ||
- tests: | ||
matrix: | ||
parameters: | ||
version: ["3.11", "3.12"] | ||
- coverage: | ||
requires: | ||
- tests |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @eonu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Report unexpected behaviour | ||
description: If you came across something unexpected, let us know here! | ||
labels: [bug, pending] | ||
|
||
body: | ||
- type: checkboxes | ||
id: exists | ||
attributes: | ||
label: Has this already been reported? | ||
description: If you haven't already, please look other existing issues to see if this bug has already been reported. | ||
options: | ||
- label: This is a new bug! | ||
required: true | ||
|
||
- type: textarea | ||
id: expected-behaviour | ||
attributes: | ||
label: Expected behaviour | ||
description: | | ||
Please describe the behaviour that you expected to see. | ||
If appropriate, provide any links to official Sequentia documentation that indicate this is the behaviour that is expected. | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: observed-behaviour | ||
attributes: | ||
label: Observed behaviour | ||
description: | | ||
Please describe the unexpected behaviour that you observed. | ||
Make sure to provide as much information as possible, so that we can investigate as thoroughly as we can. | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: example | ||
attributes: | ||
label: Code to reproduce | ||
description: > | ||
Please provide a snippet of code that shows how to reproduce the bug, | ||
making sure that it is [minimal and reproducible](https://stackoverflow.com/help/minimal-reproducible-example). | ||
placeholder: | | ||
import sequentia | ||
... | ||
render: Python | ||
|
||
- type: textarea | ||
id: version | ||
attributes: | ||
label: Version details | ||
description: | | ||
To help us get to the root of the problem as fast as possible, please run the following command to display version information about: | ||
- Python | ||
- Sequentia | ||
- Operating system | ||
```bash | ||
python -c "import sequentia; print(sequentia.version.version_info())" | ||
``` | ||
render: Text | ||
validations: | ||
required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
blank_issues_enabled: true | ||
contact_links: | ||
- name: Got a question? | ||
url: "https://github.com/eonu/sequentia/discussions/new?category=questions" | ||
about: Start a discussion on GitHub discussions where Sequentia developers and users can respond. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Request a new feature or improvement | ||
description: If you have a suggestion for something that might improve Sequentia, let us know here! | ||
labels: [feature, pending] | ||
|
||
body: | ||
- type: checkboxes | ||
id: exists | ||
attributes: | ||
label: Does this suggestion already exist? | ||
description: If you haven't already, please look through the documentation and other existing issues to see if this feature is already implemented. | ||
options: | ||
- label: This is a new feature! | ||
required: true | ||
|
||
- type: textarea | ||
id: feature-description | ||
attributes: | ||
label: Feature description | ||
description: Please describe the new feature or improvement that you would like. | ||
validations: | ||
required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Description | ||
|
||
<!-- If your pull request fixes an existing issue (e.g. #xxx), mention "Fixes #xxx" here. --> | ||
|
||
<!-- Please describe the purpose of the pull request. --> | ||
<!-- Provide thorough details about what you changed and why. --> | ||
|
||
## Checklist | ||
|
||
- [ ] I have added new tests (if necessary). | ||
- [ ] I have ensured that tests and coverage are passing on CI. | ||
- [ ] I have updated any relevant documentation (if necessary). | ||
- [ ] I have used a descriptive pull request title. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Create GitHub release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: "Get previous tag" | ||
id: latest-tag | ||
uses: "WyriHaximus/github-action-get-previous-tag@v1" | ||
- uses: ncipollo/release-action@v1 | ||
with: | ||
tag: ${{ steps.latest-tag.outputs.tag }} | ||
generateReleaseNotes: true | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Create PyPI release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v4 | ||
- name: Build and publish to PyPI | ||
uses: JRubics/poetry-publish@v1.17 | ||
with: | ||
python_version: "3.11.3" | ||
poetry_version: "==1.7.1" | ||
pypi_token: ${{ secrets.PYPI_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Create release PR | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: Version | ||
required: true | ||
|
||
jobs: | ||
create-pull-request: | ||
permissions: write-all | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: dev | ||
fetch-depth: 0 | ||
- name: Install Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11.3 | ||
- name: Install Poetry | ||
uses: abatilo/actions-poetry@v2 | ||
with: | ||
poetry-version: 1.7.1 | ||
- name: Install base dependencies | ||
run: poetry install --sync --only base | ||
- name: Bump version | ||
run: | | ||
poetry run -q invoke release.build -- -v ${{ github.event.inputs.version }} | ||
- name: Update changelog | ||
uses: orhun/git-cliff-action@v2 | ||
id: cliff-changelog | ||
with: | ||
config: cliff.toml | ||
args: --tag ${{ github.event.inputs.version }} | ||
env: | ||
OUTPUT: CHANGELOG.md | ||
- name: Get changelog entry | ||
uses: orhun/git-cliff-action@v2 | ||
id: cliff-entry | ||
with: | ||
config: cliff.toml | ||
args: --unreleased --strip header | ||
env: | ||
OUTPUT: ENTRY.md | ||
- name: Create pull request | ||
uses: peter-evans/create-pull-request@v5.0.2 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: "release: v${{ github.event.inputs.version }}" | ||
title: "release: v${{ github.event.inputs.version }}" | ||
body: "${{ steps.cliff-entry.outputs.content }}" | ||
branch: release/${{ github.event.inputs.version }} | ||
- uses: rickstaa/action-create-tag@v1 | ||
with: | ||
tag: v${{ github.event.inputs.version }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Enforce semantic PR title | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- edited | ||
- synchronize | ||
|
||
permissions: | ||
pull-requests: read | ||
|
||
jobs: | ||
main: | ||
name: validate | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: amannn/action-semantic-pull-request@v5 | ||
with: | ||
subjectPattern: ^(?![A-Z]).+$ | ||
subjectPatternError: | | ||
The subject "{subject}" found in the pull request title "{title}" | ||
didn't match the configured pattern. Please ensure that the subject | ||
doesn't start with an uppercase character. | ||
types: | | ||
build | ||
chore | ||
ci | ||
docs | ||
feat | ||
fix | ||
perf | ||
refactor | ||
release | ||
revert | ||
style | ||
tests | ||
scopes: | | ||
deps | ||
git | ||
pkg | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.