added python project config and reordered folder structure

This commit is contained in:
Sebastian Wendel 2022-11-11 17:31:21 +01:00
parent cd77777085
commit 5cc786bab1
No known key found for this signature in database
GPG key ID: 1422B7DF78144640
80 changed files with 708 additions and 446 deletions

43
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,43 @@
---
name: test
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true
env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
jobs:
run:
name: |
Python ${{ matrix.python-version }} on
${{ startsWith(matrix.os, 'macos-') &&
'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
run: pip install --upgrade hatch
- name: Run tests
run: hatch run cov

144
pyproject.toml Normal file
View file

@ -0,0 +1,144 @@
[build-system]
requires = ["hatchling", "hatch-vcs", "hatch-containers"]
build-backend = "hatchling.build"
[project]
readme = "README.md"
name = "PlanktoScope"
description = "An open and affordable imaging platform for citizen oceanography"
license = { text = "GPL-3.0-or-later" }
requires-python = ">=3.7"
authors = [{ name = "Romain Bazile", email = "planktoscope@gmail.com" }]
keywords = []
classifiers = [
"Development Status :: 5 - Production/Stable",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Image Processing",
"Topic :: Scientific/Engineering :: Image Recognition",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
]
dependencies = [
"Adafruit-Blinka~=6.15.0",
"adafruit-circuitpython-motor~=3.3.1",
"adafruit-circuitpython-motorkit~=1.6.3",
"Adafruit-PlatformDetect~=3.17.2",
"Adafruit-SSD1306~=1.6.2",
"loguru~=0.5.3",
"matplotlib~=3.5.0",
"morphocut~=0.1.2",
"numpy~=1.21.4",
"opencv-contrib-python~=4.5.3.56",
"paho-mqtt~=1.6.1",
"picamera~=1.13",
"picamerax~=21.9.8",
"RPi.GPIO~=0.7.1a4",
"scikit-image~=0.18.3",
"scipy~=1.7.2",
"smbus2~=0.4.1",
]
dynamic = ["version"]
[project.urls]
Homepage = "https://www.planktoscope.org/"
Documentation = "http://PlanktoScope.github.io/PlanktoScope"
Issues = "https://github.com/PlanktoScope/PlanktoScope/issues"
Source = "https://github.com/PlanktoScope/PlanktoScope"
[project.scripts]
planktoscope = "pkg.planktoscope:main"
[tool.hatch.version]
source = "vcs"
[tool.hatch.build]
sources = ["./software/planktoscope-backend/src"]
[tool.hatch.build.hooks.vcs]
version-file = "./software/planktoscope-backend/src/planktoscope_backend/__about__.py"
[tool.hatch.build.targets.sdist]
include = ["main.py", "./planktoscope/*.py", "./planktoscope/**/*.py"]
[tool.hatch.build.targets.wheel]
[tool.hatch.envs.default]
[tool.hatch.envs.dev]
python = "310"
dependencies = [
"black",
"coverage[toml]",
"isort",
"pydocstyle",
"pycodestyle",
"pylint",
"pytest",
"typing",
"pytest-cov",
"pytest-mock",
"pytest-randomly",
"pytest-rerunfailures",
"pytest-xdist",
]
[tool.hatch.envs.test]
dependencies = [
"coverage[toml]",
"pytest",
"pytest-cov",
"pytest-mock",
"pyspelling",
]
[tool.hatch.envs.test.scripts]
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=scripts/planktoscope --cov=tests {args}"
no-cov = "cov --no-cov {args}"
[[tool.hatch.envs.test.matrix]]
python = ["37", "38", "39", "310", "311"]
[tool.hatch.envs.lint]
dependencies = ["flake8", "black", "isort"]
[tool.hatch.envs.lint.scripts]
check = [
"flake8 .",
"black --check --diff software/planktoscope-backend",
"isort --check-only --diff software/planktoscope-backend",
]
fmt = [
"isort software/planktoscope-backend",
"black software/planktoscope-backend",
"check",
]
[tool.hatch.envs.docs]
dependencies = [
"mkdocs",
"mkdocs-charts-plugin",
"mkdocs-glightbox",
"mkdocs-macros-plugin",
"mkdocs-markdownextradata-plugin",
"mkdocs-material-extensions",
"mkdocs-material",
"mkdocs-minify-plugin",
"mkdocs-redirects",
"mkdocs-table-reader-plugin",
"pygments",
"pymdown-extensions",
"linkchecker",
]
[tool.hatch.envs.docs.scripts]
build = "mkdocs build --clean --strict"
serve = "mkdocs serve --dev-addr localhost:8000"
validate = ["linkchecker --config .linkcheckerrc site"]
check = ["build --no-directory-urls", "validate"]

View file

@ -17,4 +17,4 @@
"nb_frame": 100,
"sleep_before": 0.5,
"imaging_pump_volume": 0.01
}
}

View file

@ -0,0 +1 @@
SPDX-License-Identifier: GPL-3.0-or-later

View file

@ -0,0 +1,14 @@
{
"stepper_reverse": false,
"microsteps": 32,
"focus_steps_per_mm": 40,
"pump_steps_per_ml": 507,
"focus_max_speed": 0.5,
"pump_max_speed": 30,
"stepper_type": "adafruit",
"wb_red_gain": 2,
"wb_blue_gain": 1.41,
"analog_gain": 1.0,
"digital_gain": 1.0,
"acq_fnumber_objective": 16
}

View file

@ -0,0 +1 @@
SPDX-License-Identifier: GPL-3.0-or-later

View file

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2022-present Sebastian Wendel <s.wendel@sourceindex.de>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,21 @@
# planktoscope-backend
[![PyPI - Version](https://img.shields.io/pypi/v/planktoscope-backend.svg)](https://pypi.org/project/planktoscope-backend)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/planktoscope-backend.svg)](https://pypi.org/project/planktoscope-backend)
-----
**Table of Contents**
- [Installation](#installation)
- [License](#license)
## Installation
```console
pip install planktoscope-backend
```
## License
`planktoscope-backend` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.

View file

@ -1,3 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
RPi.GPIO~=0.7.1a4
Adafruit-Blinka~=6.15.0
adafruit-circuitpython-motorkit~=1.6.3
@ -14,4 +16,4 @@ morphocut~=0.1.2
opencv-contrib-python~=4.5.3.56
scipy~=1.7.2
smbus2~=0.4.1
scikit-image~=0.18.3
scikit-image~=0.18.3

View file

@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: 2022-present Sebastian Wendel <s.wendel@sourceindex.de>
#
# SPDX-License-Identifier: MIT
__version__ = '0.0.1'

View file

@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2022-present Sebastian Wendel <s.wendel@sourceindex.de>
#
# SPDX-License-Identifier: MIT

View file

@ -0,0 +1,5 @@
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = '0.1.dev643+g3c581f6.d19800101'
__version_tuple__ = version_tuple = (0, 1, 'dev643', 'g3c581f6.d19800101')

View file

@ -81,7 +81,7 @@ if __name__ == "__main__":
# Create script PID file, so it's easy to kill the main process without ravaging all python script in the OS
with open('/tmp/pscope_pid', 'w') as f:
f.write(str(os.getpid()))
# check if gpu_mem configuration is at least 256Meg, otherwise the camera will not run properly
with open("/boot/config.txt", "r") as config_file:
for i, line in enumerate(config_file):
@ -197,5 +197,5 @@ if __name__ == "__main__":
# Cleanup pid file
os.remove('/tmp/pscope_pid')
logger.info("Bye")

View file

@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2022-present Sebastian Wendel <s.wendel@sourceindex.de>
#
# SPDX-License-Identifier: MIT

View file

@ -17,4 +17,4 @@
"credentialsFile": "flows/main_cred.json"
}
}
}
}

View file

@ -1,4 +1,7 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-or-later
log="echo -e"
CURRENT_BRANCH=$(git --git-dir=/home/pi/PlanktoScope/.git rev-parse --abbrev-ref HEAD)

View file

@ -1,4 +1,7 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-or-later
log="echo -e"
CURRENT_BRANCH=$(git --git-dir=/home/pi/PlanktoScope/.git rev-parse --abbrev-ref HEAD)

View file

@ -1,4 +1,7 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-or-later
# Stolen from https://github.com/raamsri/automount-usb/blob/master/usb-mount.sh
# This work is licensed under the Unlicense

File diff suppressed because one or more lines are too long

View file

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 4 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 692 KiB

After

Width:  |  Height:  |  Size: 692 KiB

View file

Before

Width:  |  Height:  |  Size: 141 KiB

After

Width:  |  Height:  |  Size: 141 KiB

View file

Before

Width:  |  Height:  |  Size: 829 KiB

After

Width:  |  Height:  |  Size: 829 KiB

View file

@ -54,7 +54,7 @@ dtparam=spi=on
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
# Additional overlays and parameters are documented /boot/overlays/README
# Additional overlays and parameters are documented /boot/overlays/images/readme
# Enable audio (loads snd_bcm2835)
dtparam=audio=on

View file

@ -1,4 +1,7 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-or-later
sudo killall -15 python3
sudo killall -15 raspimjpeg
sleep 10