Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Update testing (use Black, Ruff, precommit hook) #140

Merged
merged 18 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .github/workflows/check_linting.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: PEP8 Compliance, Spellcheck, & Docstring
name: Style, Spellcheck, & Docstring

on: pull_request

jobs:
linting:
style:
name: Style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: pip install -r requirements_testing.txt
- name: Run flake8
run: flake8 pylossless docs --exclude pylossless/__init__.py
- name: Run Codespell
run: codespell pylossless docs --skip docs/source/generated
- name: Check Numpy Format Docstring
run: pydocstyle pylossless

- uses: actions/checkout@v3
with:
python-version: "3.11"
- uses: psf/black@stable
- uses: pre-commit/[email protected]
- name: Install dependencies
run: pip install -r requirements_testing.txt
# Run Ruff
- name: Run Ruff
run: ruff pylossless
# Run Codespell
- name: Run Codespell
run: codespell pylossless docs
63 changes: 63 additions & 0 deletions .github/workflows/main_pylossless-qc-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions

name: Build and deploy Python app to Azure Web App - pylossless-qc-demo

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python version
uses: actions/setup-python@v1
with:
python-version: '3.7'

- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install dependencies
run: pip install -r requirements.txt

# Optional: Add step to run tests here (PyTest, Django test suites, etc.)

- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v2
with:
name: python-app
path: |
.
!venv/
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: python-app
path: .

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: 'pylossless-qc-demo'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_B1F7B3988A884792AC90F3E962E01A2B }}
48 changes: 27 additions & 21 deletions .github/workflows/test_pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
name: Test pipeline

on: pull_request
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Pylossless & Deps
run: pip install -e .
- name: Install testing dependencies
run: pip install -r requirements_testing.txt
- name: Install QC depedencies
run: pip install -r requirements_qc.txt
- name: install openneuro
run: pip install openneuro-py
- name: Test Pipeline
run: |
coverage run -m pytest
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
- uses: actions/checkout@v3
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Pylossless & Deps
run: pip install -e .
- name: Install testing dependencies
run: pip install -r requirements_testing.txt
- name: Install QC depedencies
run: pip install -r requirements_qc.txt
- name: install openneuro
run: pip install openneuro-py
- name: Test Pipeline
run: |
coverage run -m pytest
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
args: [--quiet]

# Ruff linter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.286
hooks:
- id: ruff
name: ruff
files: ^pylossless/

# Codespell
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: codespell
additional_dependencies:
- tomli
files: ^pylossless/|^docs/
types_or: [python, bib, rst, inc]
1 change: 1 addition & 0 deletions docs/examples/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
# Then, we import the function we need.
# For use in jupyter notebooks, We just need to import a single function.
from pylossless.dash.app import get_app

app = get_app(kind="jupyter")
app.run_server(mode="inline")
62 changes: 31 additions & 31 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'pyLossless'
project = "pyLossless"
copyright = "2023, Huberty, Scott; O'Reilly, Christian; Desjardins, James"
author = "Huberty, Scott; O'reilly, Christian"
release = '0.1'
release = "0.1"


# Point Sphinx.ext.autodoc to the our python modules (two parent directories
# from this dir)
sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath("../.."))

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand All @@ -29,13 +29,15 @@
# gallery for: building tutorial .rst files from python files
# sphinxemoji So we can use emoji's in docs.
# sphinx design to support certain directives, like ::grid etc.
extensions = ['sphinx.ext.intersphinx',
'sphinx.ext.autodoc',
'numpydoc',
'sphinx.ext.todo',
'sphinx_gallery.gen_gallery',
'sphinxemoji.sphinxemoji',
"sphinx_design"]
extensions = [
"sphinx.ext.intersphinx",
"sphinx.ext.autodoc",
"numpydoc",
"sphinx.ext.todo",
"sphinx_gallery.gen_gallery",
"sphinxemoji.sphinxemoji",
"sphinx_design",
]

# Allows us to use the ..todo:: directive
todo_include_todos = True
Expand All @@ -44,45 +46,43 @@
# Source directory of python file tutorials and the target
# directory for the converted rST files
sphinx_gallery_conf = {
'examples_dirs': '../examples', # path to your example scripts
'gallery_dirs': './generated/auto_tutorials', # path to save tutorials
"examples_dirs": "../examples", # path to your example scripts
"gallery_dirs": "./generated/auto_tutorials", # path to save tutorials
}

templates_path = ['_templates']
templates_path = ["_templates"]
exclude_patterns = []

# -- Intersphinx configuration -----------------------------------------------

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'numpy': ('https://numpy.org/doc/stable/', None),
'pandas': ('https://pandas.pydata.org/docs/', None),
'xarray': ('https://docs.xarray.dev/en/stable/', None),
'mne': ('https://mne.tools/dev', None),
'mne_icalabel': ('https://mne.tools/mne-icalabel/dev', None)
"python": ("https://docs.python.org/3", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"pandas": ("https://pandas.pydata.org/docs/", None),
"xarray": ("https://docs.xarray.dev/en/stable/", None),
"mne": ("https://mne.tools/dev", None),
"mne_icalabel": ("https://mne.tools/mne-icalabel/dev", None),
}

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'pydata_sphinx_theme'
html_static_path = ['_static']
html_theme = "pydata_sphinx_theme"
html_static_path = ["_static"]
html_theme_options = {
"logo": {
"image_light": "logo-lightmode_color.png",
"image_dark": "logo_white.png",
}
"logo": {
"image_light": "logo-lightmode_color.png",
"image_dark": "logo_white.png",
}
}

# user made CSS to customize look
html_css_files = [
'css/custom.css',
"css/custom.css",
]

# Custom sidebar templates, maps document names to template names.
html_sidebars = {
"index": ["search-field.html", "sidebar-nav-bs", 'globaltoc.html']
}
html_sidebars = {"index": ["search-field.html", "sidebar-nav-bs", "globaltoc.html"]}

# NumPyDoc configuration -----------------------------------------------------

Expand All @@ -96,7 +96,7 @@
numpydoc_xref_param_type = True
numpydoc_validate = True
# Only generate documentation for public members
autodoc_default_flags = ['members', 'undoc-members', 'inherited-members']
autodoc_default_flags = ["members", "undoc-members", "inherited-members"]
numpydoc_class_members_toctree = False

numpydoc_xref_aliases = {
Expand Down Expand Up @@ -126,5 +126,5 @@
"in",
"dtype",
"object",
"LosslessPipeline"
"LosslessPipeline",
}
2 changes: 1 addition & 1 deletion docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Viewing the docs locally

The built documentation is placed in ``docs/build``. You should not
change any files in this directory. If you want to view the documentation
locally, simply click on the ``docs/build/html/index.rst`` file from your
locally, simply click on the ``docs/build/html/index.html`` file from your
file browser or open it with the command line:

If you are in the ``docs`` directory:
Expand Down
43 changes: 38 additions & 5 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,26 @@
Installation
============

****************************************
Install via :code:`pip` or :code:`conda`
****************************************
To stay up to date with the latest version of pyLossless, we recommend that you install
the package from the github repository. This will allow you to easily update to the
latest version of pyLossless as we continue to develop it.

.. hint::
To use pyLossless you need to have the ``git`` command line tool installed.
If you are not sure, see this
`tutorial
<https://git-scm.com/book/en/v2/Getting-Started-Installing-Git>`__
<https://mne.tools/stable/install/contributing.html>`__


Once you have git installed and configured, and before creating your local copy
of the codebase, go to the `PyLossless GitHub <https://github.com/lina-usc/pylossless>`_
page and create a
`fork <https://docs.github.com/en/get-started/quickstart/fork-a-repo>`_ into your GitHub
user account.

****************************************
Install via :code:`pip` or :code:`conda`
****************************************

Pylossless requires Python version |min_python_version| or higher. If you
need to install Python, please see `MNE-Pythons guide to installing Python
Expand Down Expand Up @@ -63,4 +74,26 @@ or via :code:`conda`:
$ conda develop ./pylossless
That's it! You are now ready to use pyLossless.
That's it! You are now ready to use pyLossless.

Additional Requirements for Development
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If you plan on contributing to the development of pyLossless, you will need to install
some additional dependencies so that you can run tests and build the documentation
locally. The code below will install the additional dependencies as well as the
pre-commit hooks that we use to ensure that all code is formatted correctly. Make sure
that you have activated your ``pylossless`` environment and are inside the pylossless
git repository directory, before running the code below:

.. code-block:: console
$ pip install -r requirements_testing.txt
$ pip install -r docs/requirements_doc.txt
$ pre-commit run -a
PyLossless uses `black <https://github.com/psf/black>`_ style formatting. If you are
using Visual Studio Code, you can also install the black extension to automatically
format your code. See the instructions at this
`link
<https://dev.to/adamlombard/how-to-use-the-black-python-code-formatter-in-vscode-3lo0>`_
Loading
Loading