Skip to content

Commit

Permalink
Update to use pyproject.toml (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
tab-cmd authored Dec 10, 2024
1 parent 6cbbfbc commit b256aed
Show file tree
Hide file tree
Showing 25 changed files with 268 additions and 787 deletions.
36 changes: 0 additions & 36 deletions .bcipy/README.md

This file was deleted.

Binary file not shown.
23 changes: 0 additions & 23 deletions .coveragerc

This file was deleted.

17 changes: 11 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ jobs:
- name: update pip & install custom dependencies
run: |
python -m pip install --upgrade pip
- name: install manually downloaded pyWinhook wheel for Python 3.9
if: matrix.python-version == 3.9
run: |
pip install ./.bcipy/downloads/pyWinhook-1.6.2-cp39-cp39-win_amd64.whl
- name: install dependencies
run: |
make dev-install
Expand All @@ -96,6 +92,9 @@ jobs:
- name: lint
run: |
make lint
- name: build
run: |
make build
build-macos:

Expand Down Expand Up @@ -123,11 +122,17 @@ jobs:
if: always()
run: |
make coverage-report
make coverage-xml
- name: type-check
run: |
make type
- name: lint
run: |
make lint
- name: build
run: |
make build
- name: codacy
run: |
export CODACY_PROJECT_TOKEN=${{ secrets.CODACY_PROJECT_TOKEN }}
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r "cobertura.xml"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mypy-html.css
index.html
htmlcov/
html/
*.xml

# Virtualenv
venv/
Expand Down
26 changes: 20 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ install:
pip install -e .

dev-install:
pip install -r dev_requirements.txt
pip install psychopy==2024.2.1 --no-deps
pip install kenlm==0.1 --global-option="--max_order=12"
pip install -e ".[dev]"
make install

build:
pip install -e ".[release]"
python -m build --sdist --wheel

test-all:
make coverage-report
make type
Expand All @@ -19,18 +21,21 @@ integration-test:
pytest --mpl -k "slow"

coverage-report:
coverage run --branch --source=bcipy -m pytest --mpl -k "not slow"
coverage run --branch -m pytest --mpl -k "not slow"
coverage report

coverage-xml:
coverage xml -o "cobertura.xml"

coverage-html:
coverage run --branch --source=bcipy -m pytest --mpl -k "not slow"
coverage run --branch -m pytest --mpl -k "not slow"
coverage html

lint:
flake8 bcipy

lint-fix:
autopep8 --in-place --aggressive -r bcipy
autopep8 --in-place --aggressive --max-line-length 120 --ignore "E402,E226,E24,W50,W690" -r bcipy
flake8 bcipy

type:
Expand All @@ -43,6 +48,15 @@ clean:
find . -name "*.py[co]" -o -name __pycache__ -exec rm -rf {} +
find . -path "*/*.pyo" -delete
find . -path "*/*.pyc" -delete
find . -path "*/*/__pycache__" -delete
rm -rf .pytest_cache
rm -rf .mypy_cache
rm -rf .coverage
rm -rf htmlcov
rm -rf dist
rm -rf build
rm -rf bcipy.egg-info
rm -rf bcipy_cache

bci-gui:
python bcipy/gui/BCInterface.py
Expand Down
51 changes: 44 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@


[![BciPy](https://github.com/CAMBI-tech/BciPy/actions/workflows/main.yml/badge.svg)](https://github.com/CAMBI-tech/BciPy/actions/workflows/main.yml)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/96e31da4b0554dae9db7a1356556b0d5)](https://app.codacy.com/gh/CAMBI-tech/BciPy/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](https://github.com/CAMBI-tech/BciPy/fork)
[![Follow on Twitter](https://img.shields.io/twitter/follow/cambi_tech?label=Follow&style=social)](https://twitter.com/cambi_tech)


BciPy is a library for conducting Brain-Computer Interface experiments in Python. It functions as a standalone application for experimental data collection or you can take the tools you need and start coding your own system. See our official BciPy documentation including affiliations and more context information [here](https://bcipy.github.io/).

It will run on the latest windows (7, 10, 11), linux (ubuntu 22.04) and macos (Big Sur). Other versions may work as well, but are not guaranteed. To see supported versions and operating systems as of this release see here: [BciPy Builds](https://github.com/CAMBI-tech/BciPy/actions/workflows/main.yml).
It will run on the latest windows (10, 11), linux (ubuntu 22.04) and macos (Sonoma). Other versions may work as well, but are not guaranteed. To see supported versions and operating systems as of this release see here: [BciPy Builds](https://github.com/CAMBI-tech/BciPy/actions/workflows/main.yml).

*Please cite us when using!*

Expand All @@ -18,7 +19,7 @@ Memmott, T., Koçanaoğulları, A., Lawhead, M., Klee, D., Dudy, S., Fried-Oken,

## Dependencies
---------------
This project requires Python 3.8 or 3.9. Please see notes below for additional OS specific dependencies before installation can be completed and reference our documentation/FAQs for more information: https://bcipy.github.io/hardware-os-config/
This project requires Python 3.8, 3.9 or 3.10. Please see notes below for additional OS specific dependencies before installation. See our documentation/FAQs for more information [here](https://bcipy.github.io/hardware-os-config/).

### Linux

Expand All @@ -28,8 +29,6 @@ You will need to install the prerequisites defined in `scripts\shell\linux_requi

If you are using a Windows machine, you will need to install the [Microsoft Visual C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/).

*python 3.9 only!*
You will need to install pyWinhook manually. See [here](https://www.lfd.uci.edu/~gohlke/pythonlibs/#pywinhook) for the appropriate wheel file (`pyWinhook‑1.6.2‑cp39‑cp39‑win_amd64.whl`). Then run `pip install <path_to_wheel_file>`. We also include the 64-bit wheel file in the `.bcipy/downloads/` directory.

### Mac

Expand All @@ -48,9 +47,8 @@ In order to run BciPy on your computer, after following the dependencies above,
To install for use locally and use of the GUI:
1. Git clone https://github.com/BciPy/BciPy.git
2. Change directory in your terminal to the repo directory.
3. Install the kenlm language model package. `pip install kenlm==0.1 --global-option="--max_order=12"`.
4. Install PsychoPy with no dependencies. `pip install psychopy==2023.2.1 --no-deps`.
5. Install BciPy in development mode. `pip install -e .`
3. [Optional] Install the kenlm language model package. `pip install kenlm==0.1 --global-option="--max_order=12"`.
4. Install BciPy in development mode. `pip install -e .`


If wanting the latest version from PyPi and to build using modules:
Expand Down Expand Up @@ -356,6 +354,45 @@ Alternately, if Make is installed, you may run the follow command to run mypy:
make type
```

## Release
----------

The process to release a new version of BciPy is done through the below steps. An admin PyPi account is required to upload the package with a valid token. An admin GitHub account is also required to create tag the release. Reach out to the development team for more information.

### Install release dependencies and create a universal wheel

Configuration for the distribution is in `pyproject.toml`. To create a universal wheel, run:


```sh
pip install -e ".[release]"
python -m build --sdist --wheel
```

Alternately, if Make is installed, you may run the follow command to build the wheel:

```sh
make build
```

### Upload to PyPi

To upload the package to [PyPi](https://pypi.org/project/bcipy/), run:

```sh
twine upload dist/*
```

### Tag the release on GitHub

```sh
git tag v*add_version*
git push --tags'
```
### Create GitHub Release
Using the tag you just created, create a release on GitHub. Include the release notes from the CHANGELOG in the description. See https://github.com/CAMBI-tech/BciPy/releases for examples.
### Contributions Welcome!
--------------------------
Expand Down
25 changes: 4 additions & 21 deletions bcipy/core/session.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# mypy: disable-error-code="arg-type"
"""Helper functions for managing and parsing session.json data."""
import csv
import itertools
import json
import os
import sqlite3
import subprocess
from dataclasses import dataclass, fields
from typing import Any, Dict, List, Optional

Expand All @@ -16,12 +16,10 @@
BLACK = COLOR_INDEX[0]
WHITE = COLOR_INDEX[1]
YELLOW = COLOR_INDEX[5]
from bcipy.config import (BCIPY_ROOT, DEFAULT_ENCODING,
DEFAULT_PARAMETERS_FILENAME, EXPERIMENT_DATA_FILENAME,
from bcipy.config import (DEFAULT_ENCODING,
DEFAULT_PARAMETERS_FILENAME,
SESSION_DATA_FILENAME, SESSION_SUMMARY_FILENAME)
from bcipy.io.load import (load_experiment_fields, load_experiments,
load_json_parameters)
from bcipy.helpers.validate import validate_field_data_written
from bcipy.io.load import load_json_parameters
from bcipy.task.data import Session


Expand All @@ -45,21 +43,6 @@ def session_data(data_dir: str) -> Dict:
return data


def collect_experiment_field_data(experiment_name: str,
save_path: str,
file_name: str = EXPERIMENT_DATA_FILENAME) -> None:
experiment = load_experiments()[experiment_name]
experiment_fields = load_experiment_fields(experiment)

if experiment_fields:
cmd = (f'python {BCIPY_ROOT}/gui/experiments/ExperimentField.py -e'
f' "{experiment_name}" -p "{save_path}" -f "{file_name}"')
subprocess.check_call(cmd, shell=True)
# verify data was written before moving on
if not validate_field_data_written(save_path, file_name):
raise Exception('Field data not collected!')


@dataclass(frozen=True)
class EvidenceRecord:
"""Record summarizing Inquiry evidence."""
Expand Down
57 changes: 0 additions & 57 deletions bcipy/helpers/demo/demo_copy_phrase_wrapper.py

This file was deleted.

1 change: 1 addition & 0 deletions bcipy/helpers/offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def calculate_latency(raw_data: RawData,
if value < 1 and diode_enc:
diode_enc = False

trigger_diodes_timestamps = []
# Plot triggers.txt data if present; vertical line for each value.
if triggers:
trigger_diodes_timestamps = [
Expand Down
2 changes: 0 additions & 2 deletions bcipy/task/demo/control/demo_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ def _demo_decision_maker():

conjugator = EvidenceFusion(evidence_names, len_dist=len_alp)
decision_maker = DecisionMaker(
min_num_inq=1,
max_num_inq=10,
state='',
alphabet=alp)

Expand Down
12 changes: 0 additions & 12 deletions dev_requirements.txt

This file was deleted.

Loading

0 comments on commit b256aed

Please sign in to comment.