Skip to content

Commit

Permalink
Merge development branch into the master branch (#42)
Browse files Browse the repository at this point in the history
* Initialize repo packaging based on sci py cookie

* Update min python and remove pre-commit dep for now

* Remove copier answers

* Remove 3.12 for now

* Remove pypy3.9

* Allow formatting to always pass for now

* Ignore pre-commit for now

* fix: bring back missing .so file and remove from gitignore

* chore: remove old setup.py

* ci: update branch to development

Updated ci and cd yaml to trigger on development
branch

* ci: Add built dist test step for cd

* ci: publish need both steps to finish

* ci: fix python version

* ci: fix artifact name and action version

* ci: Remove cd for pull requests

* ci: fix auto versioning for pypi

* chore(deps): Add all optional deps

* Update README.md

* Update README.md

* Update docs and devcontainer

* Update .gitignore

* Update .gitignore

* Add build/html files

* chore(deps): Update smart_open to use braingeneers version

* chore(deps): Pin neuraltoolkit to v0.3.1

Pinned neuraltoolkit dependency to version 0.3.1 only.

@lsetiawan: From some investigation, the actual functions that are being used in the braingeneers package from neuraltoolkit hasn't changed in over a year. And the latest stable v0.3.1 was released in March 2023. So it is safe to use this specific version and minimize breakage.

* Update README.md

Update installation instructions

* Update .devcontainer/post_create.sh

Overwrite the directory in site-packages with a symbolic link to `".[all]"`

Co-authored-by: Don Setiawan <[email protected]>

* Update post_create.sh

Remove additional comments

Resolves https://github.com/braingeneers/braingeneerspy/pull/42/files/9eb851932e98a31d0cb171fd5414512d08caa057#r1355710644

* Update post_create.sh

Update the wording for the comment

Resolves #42 (comment)

* Update post_create.sh

Uninstall the pre-installed `braingeneerspy` package

Resolves comment #42 (comment)

* Update LICENSE

Updated LICENSE to BSD-3

Resolves comment #42 (comment)

* Update pyproject.toml

Updated to a BSD-3 Clause license

Resolves comment #42 (comment)

* Update README.md

Included packages in quotation marks
Replaced deprecated contribution instructions with `CONTRIBUTING.md`

Resolves comments
#42 (comment)
#42 (comment)

* Update README.md

Remove wheel instructions

Resolves comment #42 (comment)

* Update README.md

Updated Optional Dependencies installation
- Directly from PyPI

Resolves comment #42 (comment)

* ci: Rename .readthedocs.yml to .readthedocs.yaml

* Remove /docs/build files

Resolves comment #42 (comment)

* Update README.md

Remove quotation marks for Mac users comments

* Update README.md

Updated badges

Co-authored-by: Don Setiawan <[email protected]>

* Update .readthedocs.yaml

Update path to conf.py

Co-authored-by: Don Setiawan <[email protected]>

* Update src/braingeneers/_compat/typing.py

Co-authored-by: Lon Blauvelt <[email protected]>

* Update pyproject.toml

Remove commented `sortedcontainers` dependency

Co-authored-by: Lon Blauvelt <[email protected]>

* Update README.md

Remove `braingeneers-smart-open` statement
Resolves comment #42 (comment)

* Update README.md

Updated link for AWS Data Wrangler

* Update README.md

Add link to the `CONTRIBUTING.md` file
Resolves comment #42 (comment)

* Update ci.yml

Remove `PyLint`
Resolves comment #42 (comment)

* Delete .extgitignore

Resolves comment #42 (comment)

* Delete src/braingeneers/_compat directory

Remove the `_compat` module
Part 1 of resolving comment #42 (comment)

* Update test_package.py

Remove the `_compat` module tests
Part 2 of resolving comment #42 (comment)

* Update test_package.py

Remove the `_compat` module import
Part 3 of resolving comment #42 (comment)

* Update ci.yml

Updated the `ci.yml` to allow for Python 3.12 (experimental) support
Added `continue-on-error` functionality in case the experimental support fails since it is new
Resolves comment #42 (comment)
@lsetiawan could you review the changes that I made here?

* Update ci.yml

Commenting out `continue-on-error`

* Update ci.yml

Remove commented line

* Update ci.yml

Updated `python-version` to num

* Update ci.yml

* Update LICENSE

Updated the LICENSE to MIT

* Update README.md

Update to include the MIT license

* Update ci.yml

* Update ci.yml

* Update ci.yml

Add `continues-on-error`

* Update ci.yml

Removed commented `pre-commit` section

---------

Co-authored-by: Landung 'Don' Setiawan <[email protected]>
Co-authored-by: Lon Blauvelt <[email protected]>
  • Loading branch information
3 people authored Oct 26, 2023
1 parent 46bd43c commit bfaf45f
Show file tree
Hide file tree
Showing 59 changed files with 1,081 additions and 123 deletions.
15 changes: 15 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
{
"image":"ghcr.io/braingeneers/research:latest",

"customizations": {
"vscode": {
"extensions": [
"ms-toolsai.jupyter",
"ms-python.python",
"ms-vsliveshare.vsliveshare"
]
}
},
"postCreateCommand": "sh .devcontainer/post_create.sh"
}
7 changes: 7 additions & 0 deletions .devcontainer/post_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# For writing commands that will be executed after the container is created

# Uninstalls the braingeneerspy package (pre-installed in the research Docker image) from the environment
python3 -m pip uninstall braingeneerspy

# Installs a Python package located in the current directory in editable mode and includes all optional extras specified in the [all] section of braingeneers.
python3 -m pip install -e ".[all]"
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
101 changes: 101 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
See the [Scientific Python Developer Guide][spc-dev-intro] for a detailed
description of best practices for developing scientific packages.

[spc-dev-intro]: https://scientific-python-cookie.readthedocs.io/guide/intro

# Quick development

The fastest way to start with development is to use nox. If you don't have nox,
you can use `pipx run nox` to run it without installing, or `pipx install nox`.
If you don't have pipx (pip for applications), then you can install with with
`pip install pipx` (the only case were installing an application with regular
pip is reasonable). If you use macOS, then pipx and nox are both in brew, use
`brew install pipx nox`.

To use, run `nox`. This will lint and test using every installed version of
Python on your system, skipping ones that are not installed. You can also run
specific jobs:

```console
$ nox -s lint # Lint only
$ nox -s tests # Python tests
$ nox -s docs -- serve # Build and serve the docs
$ nox -s build # Make an SDist and wheel
```

Nox handles everything for you, including setting up an temporary virtual
environment for each run.

# Setting up a development environment manually

You can set up a development environment by running:

```bash
python3 -m venv .venv
source ./.venv/bin/activate
pip install -v -e .[dev]
```

If you have the
[Python Launcher for Unix](https://github.com/brettcannon/python-launcher), you
can instead do:

```bash
py -m venv .venv
py -m install -v -e .[dev]
```

# Post setup

You should prepare pre-commit, which will help you by checking that commits pass
required checks:

```bash
pip install pre-commit # or brew install pre-commit on macOS
pre-commit install # Will install a pre-commit hook into the git repo
```

You can also/alternatively run `pre-commit run` (changes only) or
`pre-commit run --all-files` to check even without installing the hook.

# Testing

Use pytest to run the unit checks:

```bash
pytest
```

# Coverage

Use pytest-cov to generate coverage reports:

```bash
pytest --cov=braingeneers
```

# Building docs

You can build the docs using:

```bash
nox -s docs
```

You can see a preview with:

```bash
nox -s docs -- serve
```

# Pre-commit

This project uses pre-commit for all style checking. While you can run it with
nox, this is such an important tool that it deserves to be installed on its own.
Install pre-commit and run:

```bash
pre-commit run -a
```

to check all files.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
32 changes: 32 additions & 0 deletions .github/matchers/pylint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"problemMatcher": [
{
"severity": "warning",
"pattern": [
{
"regexp": "^([^:]+):(\\d+):(\\d+): ([A-DF-Z]\\d+): \\033\\[[\\d;]+m([^\\033]+).*$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
],
"owner": "pylint-warning"
},
{
"severity": "error",
"pattern": [
{
"regexp": "^([^:]+):(\\d+):(\\d+): (E\\d+): \\033\\[[\\d;]+m([^\\033]+).*$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
],
"owner": "pylint-error"
}
]
}
101 changes: 101 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: CD

on:
workflow_dispatch:
push:
branches:
- master
- main
- development
release:
types:
- published

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FORCE_COLOR: 3

jobs:
dist:
name: Distribution build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Build sdist and wheel
run: pipx run build

- uses: actions/upload-artifact@v3
with:
path: dist

- name: Check products
run: pipx run twine check dist/*

test-built-dist:
needs: [dist]
name: Test built distribution
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/[email protected]
name: Install Python
with:
python-version: '3.10'
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: List contents of built dist
run: |
ls -ltrh
ls -ltrh dist
- name: Publish to Test PyPI
uses: pypa/[email protected]
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
skip-existing: true
- name: Check pypi packages
run: |
sleep 3
python -m pip install --upgrade pip
echo "=== Testing wheel file ==="
# Install wheel to get dependencies and check import
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre braingeneers
python -c "import braingeneers; print(braingeneers.__version__)"
echo "=== Done testing wheel file ==="
echo "=== Testing source tar file ==="
# Install tar gz and check import
python -m pip uninstall --yes braingeneers
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre --no-binary=:all: braingeneers
python -c "import braingeneers; print(braingeneers.__version__)"
echo "=== Done testing source tar file ==="
publish:
needs: [dist, test-built-dist]
name: Publish to PyPI
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist

- uses: pypa/[email protected]
if: startsWith(github.ref, 'refs/tags')
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI

on:
workflow_dispatch:
pull_request:
push:
branches:
- master
- main
- development

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FORCE_COLOR: 3

jobs:
checks:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
runs-on: [ubuntu-latest, macos-latest, windows-latest]
experimental: [false, false, true]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install package
run: python -m pip install .[test]

- name: Test package
run: >-
python -m pytest -ra --cov --cov-report=xml --cov-report=term
--durations=20
- name: Upload coverage report
uses: codecov/[email protected]
Loading

0 comments on commit bfaf45f

Please sign in to comment.