Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[flake8]
ignore = E203, F401, W503
max-line-length = 120
exclude = .venv,.venv314,__pycache__,.git,.pytest_cache,build,dist,*.egg-info
6 changes: 4 additions & 2 deletions .github/workflows/check-spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ name: Check Spelling

on:
push:
branches-ignore: [master, main]
branches-ignore:
- main
pull_request:
branches: [master, main]
branches:
- main

jobs:
build:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ name: Lint Code Base

on:
push:
branches-ignore: [main]
branches-ignore:
- main
pull_request:
branches: [main]
branches:
- main

jobs:
build:
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.12"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install --dev
uv venv
uv pip install -e ".[dev]"
- name: Test with pytest
run: |
pipenv run python -m pytest -vv
uv run python -m pytest -vv
36 changes: 1 addition & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,8 @@ Update the `TankController` code from C++ to Python and run on a Raspberry Pico.

To set up and run this project, the system must meet the following requirements:

- **Python**: The project requires Python to run. Python provides the runtime for the scripts and the GUI components.
- **pip**: Python's package installer is needed to install and manage dependencies.
- **pipenv**: Used for managing project dependencies and creating isolated virtual environments.
- **Tkinter**: Required for the GUI components of the application. Tkinter comes with Python (as `python3-tk`) and is used to build and display the UI.
- **uv**: The python project package manager must be installed. Learn more at [https://docs.astral.sh/uv/](https://docs.astral.sh/uv/).

## Windows Developer Instructions

Test Python version:
- `python -V`
This command prints the installed Python version.

Upgrade pip:
- `pip install --upgrade pip`
- `pip --version`
The first command upgrades pip to the latest version, and the second verifies the installed version.

Install pipenv (tool for dependencies and virtual environments):
- `pip install pipenv`
- `pipenv --version`
- `pipenv install`
This installs or updates all dependencies defined in the Pipfile and updates the Pipfile.lock.

Verify Tkinter installation:
- `python -m tkinter`
A small GUI window should appear if Tkinter is installed correctly.

## Run in Local Environment

Expand All @@ -48,17 +25,6 @@ To run in a local environment with mocked devices (with the UI State Machine int
./run_gui.sh
```

### Update Python Virtual Environment

Run `pipenv install` in the terminal to get the latest dependencies and update the lockfile.

### Virtual Environment

```sh
python3 -m venv .venv
source .venv/bin/activate
pip3 install --user pipenv
```

## Testing

Expand Down
71 changes: 0 additions & 71 deletions arduino/Pi-ArduinoStepStickDriver/Pi-ArduinoStepStickDriver.ino

This file was deleted.

1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to configure testing imports
"""

from titration import mock_config

# Set MOCK_ENABLED to true to avoid importing Raspberry Pi
Expand Down
17 changes: 17 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Ensure virtual environment is set up
uv venv --clear
uv pip install -e ".[dev]"

# Spell check
uv run codespell -f -w .

# Format Python
uv run black .
uv run isort .
uv run flake8 .

# Clean up
find . -name ".pytest_cache" -type d -exec /bin/rm -rf {} +
find . -name "__pycache__" -type d -exec /bin/rm -rf {} +
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to run the program
"""

import sys

from titration import mock_config
Expand Down
38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[build-system]
requires = ["setuptools>=45", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "TankControllerPython"
version = "0.1.0"
description = "Tank Controller Python Application"
requires-python = ">=3.12"
dependencies = [
"adafruit-circuitpython-ads1x15",
"adafruit-circuitpython-lis3dh",
"adafruit-circuitpython-max31865",
"gpiozero",
"pandas",
"click",
"adafruit-ads1x15",
"exceptiongroup",
"numpy",
"adafruit-blinka",
]

[tool.setuptools.packages.find]
include = ["titration*"]
exclude = ["test*"]

[project.optional-dependencies]
dev = [
"black",
"flake8",
"isort",
"pycodestyle",
"pytest",
"pylint",
"pytest-cov",
"pytest-mock",
"codespell",
]
9 changes: 7 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#!/bin/sh
pipenv sync
pipenv run python main.py

# Ensure virtual environment is set up
uv venv --clear
uv pip install -e ".[dev]"

# Run the GUI application
uv run python main.py
9 changes: 7 additions & 2 deletions run_gui.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#!/bin/sh
pipenv sync -d
pipenv run python main.py -gui

# Ensure virtual environment is set up
uv venv --clear
uv pip install -e ".[dev]"

# Run the GUI application
uv run python main.py -gui
9 changes: 7 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#!/bin/sh
pipenv sync -d
pipenv run pytest -vv

# Ensure virtual environment is set up
uv venv --clear
uv pip install -e ".[dev]"

# Run tests
uv run pytest -vv
1 change: 1 addition & 0 deletions test/devices/keypad_mock_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to test the mock keypad
"""

import digitalio

from titration.devices.library import Keypad, board
Expand Down
1 change: 1 addition & 0 deletions test/devices/ph_probe_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to test the pH probe
"""

import pytest

from titration.devices.library import ADS, PHProbe, board
Expand Down
1 change: 1 addition & 0 deletions test/devices/stir_control_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to test the StirControl class
"""

from unittest import mock
from unittest.mock import call

Expand Down
1 change: 1 addition & 0 deletions test/devices/syringe_pump_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to test the syringe pump
"""

import pytest

from titration.devices.library import SyringePump
Expand Down
1 change: 1 addition & 0 deletions test/titrator_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to test the Titrator class
"""

from unittest import mock

from titration.devices.library import Keypad
Expand Down
1 change: 1 addition & 0 deletions test/ui_state/calibration/calibrate_ph1_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to test the calibration CalibratePh class
"""

from unittest import mock
from unittest.mock import ANY

Expand Down
1 change: 1 addition & 0 deletions test/ui_state/calibration/calibrate_temp_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to test the CalibrateTemp class
"""

from unittest import mock
from unittest.mock import ANY

Expand Down
1 change: 1 addition & 0 deletions test/ui_state/calibration/setup_calibration_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to the SetupCalibration class
"""

from unittest import mock
from unittest.mock import ANY

Expand Down
1 change: 1 addition & 0 deletions test/ui_state/demo_mode/demo_mode_menu_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to test the DemoModeMenu class
"""

from unittest import mock
from unittest.mock import ANY

Expand Down
1 change: 1 addition & 0 deletions test/ui_state/demo_mode/read_values_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to test the ReadValues class
"""

from unittest import mock
from unittest.mock import ANY

Expand Down
1 change: 1 addition & 0 deletions test/ui_state/main_menu_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to test the MainMenu class
"""

from unittest import mock
from unittest.mock import ANY

Expand Down
1 change: 1 addition & 0 deletions test/ui_state/prime_pump/prime_pump_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to test the PrimePump class
"""

from unittest import mock
from unittest.mock import ANY

Expand Down
1 change: 1 addition & 0 deletions test/ui_state/titration/automatic_titration_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The file to test the AutomaticTitration class
"""

from unittest import mock
from unittest.mock import ANY

Expand Down
Loading