Skip to content

Python Package, Code Refactoring and Documentation #46

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

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 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
133 changes: 133 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: release

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+a[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+b[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"

env:
PACKAGE_NAME: "chordspy"
OWNER: "Upside Down Labs"

jobs:
details:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.release.outputs.new_version }}
suffix: ${{ steps.release.outputs.suffix }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: actions/checkout@v4

- name: Extract tag and Details
id: release
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
TAG_NAME=${GITHUB_REF#refs/tags/}
NEW_VERSION=$(echo $TAG_NAME | awk -F'-' '{print $1}')
SUFFIX=$(echo $TAG_NAME | grep -oP '[a-z]+[0-9]+' || echo "")
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT"
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
else
echo "No tag found"
exit 1
fi

check_pypi:
needs: details
runs-on: ubuntu-latest
steps:
- name: Fetch PyPI version
run: |
response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}")
latest_version=$(echo $response | jq -r '.info.version // "0.0.0"')
echo "latest_version=$latest_version" >> $GITHUB_ENV

- name: Compare versions
run: |
if [ "$(printf '%s\n' "$latest_version" "${{ needs.details.outputs.new_version }}" | sort -rV | head -n1)" != "${{ needs.details.outputs.new_version }}" ]; then
echo "Version ${{ needs.details.outputs.new_version }} is not newer than PyPI version $latest_version"
exit 1
fi

setup_and_build:
needs: [details, check_pypi]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10" # Changed from 3.13 to stable version

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Configure Poetry
run: |
poetry config virtualenvs.in-project true
poetry config virtualenvs.create true

- name: Set version
run: poetry version ${{ needs.details.outputs.new_version }}

- name: Install dependencies
run: poetry install --sync --no-interaction --no-root

- name: Build package
run: poetry build

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*

pypi_publish:
needs: setup_and_build
runs-on: ubuntu-latest
environment:
name: release
permissions:
id-token: write # Essential for trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true # For better debugging

github_release:
needs: [details, setup_and_build, pypi_publish]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.details.outputs.tag_name }}
files: |
dist/*
generate_release_notes: true
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include requirements.txt
include README.md
recursive-include chordspy/templates *
recursive-include chordspy/static *
recursive-include chordspy/config *
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
# Chords - Python

Chords- Python is a bag of tools designed to interface with Micro-controller development boards running [Chords Arduino Firmware](https://github.com/upsidedownlabs/Chords-Arduino-Firmware).Use Upside Down Labs bio-potential amplifiers to read data, visualize it, record data in CSV Files, and stream it via Lab Streaming Layer.
Chords- Python is an open-source bag of tools designed to interface with Micro-controller development boards running [Chords Arduino Firmware](https://github.com/upsidedownlabs/Chords-Arduino-Firmware). Use Upside Down Labs bio-potential amplifiers to read data, visualize it, record data in CSV Files, and stream it via Lab Streaming Layer.

> [!NOTE]
> **Firmware Required:**
> - For Arduino: [Chords Arduino Firmware](https://github.com/upsidedownlabs/Chords-Arduino-Firmware)
> **Firmware Required for Arduino:** [Chords Arduino Firmware](https://github.com/upsidedownlabs/Chords-Arduino-Firmware)

## Features
- **Multiple Protocols**: Supports `Wi-Fi`, `Bluetooth`, and `Serial` communication.
- **LSL Data Streaming**:Once the LSL stream starts, any PC on the same Wi-Fi network can access the data using tools like BrainVision LSL Viewer.
- **LSL Data Streaming**: Once the LSL stream starts, any PC on the same Wi-Fi network can access the data using tools like BrainVision LSL Viewer.
- **CSV Logging**: Save raw data with Counter
- **GUI**: Live plotting for all channels.
- **Applications**: EEG/ECG/EMG/EOG-based games and utilities (e.g., Tug of War, Keystroke Emulator).

## Installation
1. **Python**: Ensure Latest version of Python is installed.
2. **Virtual Environment**:
```bash
python -m venv venv
source venv/bin/activate # Linux/macOS
.\venv\Scripts\activate # Windows
```
3. **Dependencies**:
```bash
pip install -r requirements.txt
```

> [!IMPORTANT]
> On Windows, if scripts are blocked, run:
> ```powershell
> Set-ExecutionPolicy Unrestricted -Scope Process
> ```
- **Applications**: EEG/ECG/EMG/EOG-based games and utilities (e.g., Tug of War, Keystroke Emulator).


## Installation

- Make sure you have the latest version of Python installed.

- Open command prompt and run:
```bash
python -m venv venv
```

```bash
venv\Scripts\activate # For Windows
source venv/bin/activate # For MacOS/Linux
```

```bash
pip install chordspy
```

## Usage
Run the script and access the web interface:
Run the command and access the web interface:
```bash
python app.py
chordspy
```

**Web Interface Preview**:
![Web Interface Screenshot](./media/Interface.png)
![Web Interface Screenshot](./chordspy/media/Interface.png)

![Web Interface Screenshot](./media/Webinterface.png)
![Web Interface Screenshot](./chordspy/media/Webinterface.png)

### Key Options:

Expand Down
Loading