Skip to content

Commit 537a170

Browse files
authored
Merge pull request #367 from labthings/installation-instructions-and-contributing-docs
Installation instructions and contributing docs
2 parents d0f1a84 + 8956110 commit 537a170

10 files changed

Lines changed: 178 additions & 34 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
python-version: ${{ matrix.python }}
104104

105105
- name: Install Dependencies
106-
run: pip install -e .[dev]
106+
run: pip install -r dev-requirements.txt
107107

108108
- name: Print installed packages
109109
run: pip freeze

CONTRIBUTING.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Contributing to labthings-fastapi
2+
3+
First off, thank you for considering contributing to `labthings-fastapi`! We welcome contributions from everyone, whether it's reporting a bug, suggesting a feature, improving documentation, or writing code.
4+
5+
This document outlines the processes for getting help, reporting issues, and contributing to the codebase.
6+
7+
## Seeking Support
8+
9+
If you have a question about how to use `labthings-fastapi`, or if you are running into trouble:
10+
11+
* **Check the Documentation:** Please review the official documentation on [readthedocs].
12+
* **GitHub Discussions / Issues:** If you cannot find the answer, feel free to open an issue on our [GitHub Issues page].
13+
* **OpenFlexure Community:** Because `labthings-fastapi` is the underlying framework for v3 of the [OpenFlexure Microscope software], you may also find support by engaging with the broader [OpenFlexure Forum].
14+
15+
## Reporting Issues or Bugs
16+
17+
If you find a bug or have a feature request, please report it by opening an issue on our [GitHub Issues page].
18+
19+
When reporting an issue, please include as much detail as possible:
20+
21+
* **Description:** A clear and concise description of what the bug is.
22+
* **Reproduction steps:** How can we reproduce the problem? (A minimal reproducible example is highly appreciated).
23+
* **Expected behaviour:** What did you expect to happen?
24+
* **Environment:** Include your OS, Python version, and `labthings-fastapi` version. Include full error tracebacks if applicable.
25+
26+
## Contributing Code or Documentation
27+
28+
We welcome pull requests for bug fixes, new features, and documentation improvements.
29+
30+
### 1. Local Development Setup
31+
32+
To work on the code, you will need to clone the repository and install the development dependencies.
33+
Please see the [installation notes](./README.md#installation-notes) for more detail about compatible Python versions and Windows installation.
34+
35+
```bash
36+
# Clone the repository
37+
git clone https://github.com/labthings/labthings-fastapi.git
38+
cd labthings-fastapi
39+
40+
# Install the package in editable mode with development dependencies
41+
pip install -r dev-requirements.txt
42+
```
43+
44+
### 2. Linting and Testing
45+
46+
We use several tools to maintain code quality. All of these run in CI with [GitHub Actions], but you should run them locally before submitting a Pull Request. Both `ruff` and `flake8` are configured from [`pyproject.toml`].
47+
48+
* **Linting:** We use [`ruff`] for fast linting and formatting. We highly recommend setting up a pre-commit hook to ensure [`ruff`] passes on every commit.
49+
```bash
50+
ruff format --check
51+
ruff check .
52+
```
53+
54+
* **Docstrings:** [`flake8`] is primarily used to enable stricter checks on docstrings.
55+
```bash
56+
flake8 src
57+
```
58+
59+
* **Spelling:** We use [`codespell`] to prevent common spelling mistakes in code and documentation.
60+
```bash
61+
codespell .
62+
```
63+
64+
* **Type Checking:** We use [`mypy`] for static type checking. It is configured in `pyproject.toml`.
65+
```bash
66+
mypy
67+
```
68+
69+
* **Testing:** We use [`pytest`] for our test suite and test coverage. Ensure all tests pass locally.
70+
```bash
71+
pytest --cov=src
72+
```
73+
74+
### 3. Managing Dependencies
75+
76+
Dependencies are defined in [`pyproject.toml`]. If you need to compile a `dev-requirements.txt` file (e.g., for reproducible CI/CD or local isolated environments), you can do so using [`uv`]:
77+
78+
```bash
79+
uv pip compile --extra dev pyproject.toml --output-file dev-requirements.txt
80+
```
81+
82+
*(If you're not using `uv`, regular `pip-compile` from `pip-tools` will achieve the same thing).*
83+
84+
### 4. Submitting a Pull Request (PR)
85+
86+
All changes to the codebase must go via pull requests. Unless you are a core maintainer with write access, please use the standard fork-and-branch workflow:
87+
88+
1. **Fork the repository** to your own GitHub account using the "Fork" button at the top of the repository page.
89+
2. **Clone your fork** locally and set up the upstream remote:
90+
```bash
91+
git clone https://github.com/YOUR-USERNAME/labthings-fastapi.git
92+
cd labthings-fastapi
93+
git remote add upstream https://github.com/labthings/labthings-fastapi.git
94+
```
95+
3. **Create a new branch** for your feature or bugfix:
96+
```bash
97+
git checkout -b feature-name
98+
```
99+
4. **Commit your changes** with clear, descriptive commit messages.
100+
5. **Push your branch** up to your fork:
101+
```bash
102+
git push origin feature-name
103+
```
104+
6. **Open a Pull Request** against the `main` branch of the `labthings/labthings-fastapi` repository.
105+
106+
**Pull Request Guidelines:**
107+
108+
* Code should only be merged once all the checks in the CI test job are passing.
109+
* **Unpinned Dependencies:** Note that we have a specific CI job called `test-with-unpinned-dependencies`. It is acceptable to merge code if only this specific job fails, provided the failure is due to upstream dependency issues. We prefer to deal with upstream dependency issues in a separate PR, particularly when the required fixes are distinct from the code in your current PR. The same applies to the `pip-audit` job.
110+
* Update documentation (`docs/` or docstrings) if your changes modify existing behavior or add new features.
111+
112+
[readthedocs]: https://labthings-fastapi.readthedocs.io/
113+
[GitHub Issues page]: https://github.com/labthings/labthings-fastapi/issues
114+
[OpenFlexure Forum]: https://openflexure.discourse.group/
115+
[OpenFlexure Microscope software]: https://gitlab.com/openflexure/openflexure-microscope-server/
116+
[GitHub Actions]: https://github.com/labthings/labthings-fastapi/actions
117+
[`ruff`]: https://docs.astral.sh/ruff/
118+
[`pyproject.toml`]: ./pyproject.toml
119+
[`flake8`]: https://flake8.pycqa.org/en/latest/
120+
[`mypy`]: https://mypy-lang.org/
121+
[`pytest`]: https://docs.pytest.org/en/stable/
122+
[`uv`]: https://docs.astral.sh/uv/

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@ Documentation, including install instructions, is available on [readthedocs].
1111

1212
See [readthedocs] for installation instructions that are automatically tested. You can install this package with `pip install labthings-fastapi`.
1313

14-
## Developer notes
1514

16-
For the latest development version, clone this repository and run `pip install -e .[dev]`.
15+
### Installation Notes
1716

18-
The code is linted with `ruff .`, type checked with `mypy`, and tested with `pytest`. These all run in CI with GitHub Actions. We recommend a [pre-commit hook] to ensure `ruff` passes on every commit. `flake8` is also run in CI, primarily to enable stricter checks on docstrings. It is run as `flake8 src`. `ruff` and `flake8` are both configured from `pyproject.toml`.
17+
`labthings-fastapi` supports **Python 3.10, 3.11, 3.12, and 3.13**. The upper limit is strictly capped at 3.13 due to current `pydantic-core` dependencies.
1918

20-
All changes to the codebase should go via pull requests, and should only be merged once all the checks in the `test` job are passing. It is preferable to merge code where the `test-with-unpinned-dependencies` job fails, and deal with the dependency issues in another PR, particularly where the required changes are distinct from the code in the PR.
19+
> **Note: Windows Installations on devices with ARM processors**
20+
>
21+
> Installing on Windows devices with ARM processors requires Visual Studio with the **"Desktop development with C++"** workload enabled. This is necessary because `pydantic` relies on Rust, which in turn requires C++ build tools to compile.
22+
>
23+
> *If you are using a centrally managed machine, you will need administrator privileges to install these system-level dependencies.*
2124
22-
Dependencies are defined in `pyproject.toml` and can be compiled to `dev-requirements.txt` with:
23-
```
24-
uv pip compile dev-requirements.in -o dev-requirements.txt
25-
```
26-
If you're not using `uv`, just regular `pip-compile` from `pip-tools` should do the same thing.
25+
For instructions on how to set up a development environment, run tests, and contribute to this project, please see [CONTRIBUTING.md].
2726

2827
## Demo
2928

@@ -34,3 +33,4 @@ See [readthedocs] for a runnable demo.
3433
[OpenFlexure Microscope software]: https://gitlab.com/openflexure/openflexure-microscope-server/
3534
[pre-commit hook]: https://openflexure.org/contribute#use-git-hooks-for-ci-checks
3635
[readthedocs]: https://labthings-fastapi.readthedocs.io/
36+
[CONTRIBUTING.md]: ./CONTRIBUTING.md

dev-requirements.txt

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ docstring-parser-fork==0.0.14
6464
# via pydoclint
6565
docutils==0.21.2
6666
# via
67+
# myst-parser
6768
# restructuredtext-lint
6869
# sphinx
6970
# sphinx-prompt
@@ -80,10 +81,6 @@ email-validator==2.3.0
8081
# via
8182
# fastapi
8283
# pydantic
83-
exceptiongroup==1.3.1
84-
# via
85-
# anyio
86-
# pytest
8784
fastapi==0.135.4
8885
# via labthings-fastapi
8986
fastapi-cli==0.0.27
@@ -143,6 +140,7 @@ itsdangerous==2.2.0
143140
jinja2==3.1.6
144141
# via
145142
# fastapi
143+
# myst-parser
146144
# sphinx
147145
# sphinx-autoapi
148146
# sphinx-jinja2-compat
@@ -154,14 +152,19 @@ jsonschema-specifications==2025.9.1
154152
# via jsonschema
155153
librt==0.11.0
156154
# via mypy
157-
markdown-it-py==4.2.0
158-
# via rich
155+
markdown-it-py==3.0.0
156+
# via
157+
# mdit-py-plugins
158+
# myst-parser
159+
# rich
159160
markupsafe==3.0.3
160161
# via
161162
# jinja2
162163
# sphinx-jinja2-compat
163164
mccabe==0.7.0
164165
# via flake8
166+
mdit-py-plugins==0.6.1
167+
# via myst-parser
165168
mdurl==0.1.2
166169
# via markdown-it-py
167170
msgpack==1.2.1
@@ -170,6 +173,8 @@ mypy==1.20.2
170173
# via labthings-fastapi
171174
mypy-extensions==1.1.0
172175
# via mypy
176+
myst-parser==4.0.1
177+
# via labthings-fastapi
173178
natsort==8.4.0
174179
# via domdf-python-tools
175180
numpy==2.2.6
@@ -233,6 +238,7 @@ python-multipart==0.0.32
233238
pyyaml==6.0.3
234239
# via
235240
# fastapi
241+
# myst-parser
236242
# sphinx-autoapi
237243
# uvicorn
238244
referencing==0.37.0
@@ -281,6 +287,7 @@ sphinx==8.1.3
281287
# via
282288
# autodocsumm
283289
# labthings-fastapi
290+
# myst-parser
284291
# sphinx-autoapi
285292
# sphinx-autodoc-typehints
286293
# sphinx-prompt
@@ -318,22 +325,14 @@ sphinxcontrib-serializinghtml==2.0.0
318325
# via sphinx
319326
sphobjinv==2.4
320327
# via labthings-fastapi
328+
standard-imghdr==3.10.14
329+
# via sphinx-jinja2-compat
321330
starlette==1.3.1
322331
# via fastapi
323332
tabulate==0.10.0
324333
# via sphinx-toolbox
325334
tinycss2==1.5.1
326335
# via dict2css
327-
tomli==2.4.1
328-
# via
329-
# coverage
330-
# fastapi-cli
331-
# flake8-pyproject
332-
# labthings-fastapi
333-
# mypy
334-
# pydoclint
335-
# pytest
336-
# sphinx
337336
typer==0.26.7
338337
# via
339338
# fastapi-cli
@@ -342,23 +341,17 @@ types-jsonschema==4.26.0.20260518
342341
# via labthings-fastapi
343342
typing-extensions==4.15.0
344343
# via
345-
# anyio
346-
# astroid
347344
# beautifulsoup4
348345
# domdf-python-tools
349-
# exceptiongroup
350346
# fastapi
351347
# labthings-fastapi
352348
# mypy
353349
# pydantic
354350
# pydantic-core
355351
# pydantic-extra-types
356-
# referencing
357352
# rich-toolkit
358353
# sphinx-toolbox
359-
# starlette
360354
# typing-inspection
361-
# uvicorn
362355
typing-inspection==0.4.2
363356
# via
364357
# fastapi

docs/source/_windows_arm_note.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. note::
2+
**Windows Installations on devices with ARM Processors**
3+
4+
Installing on Windows devices with ARM processors requires `Visual Studio`_ with the **"Desktop development with C++"** workload enabled. This is necessary because ``pydantic`` relies on Rust_, which in turn requires C++ build tools to compile.
5+
6+
*If you are using a centrally managed machine, you will need administrator privileges to install these system-level dependencies.*

docs/source/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@
2727
"autoapi.extension",
2828
"sphinx_rtd_theme",
2929
"sphinx_toolbox.decorators",
30+
"myst_parser",
3031
]
3132

33+
myst_heading_anchors = 3
34+
3235
templates_path = ["_templates"]
3336
exclude_patterns = []
3437

docs/source/contributing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
```{include} ../../CONTRIBUTING.md

docs/source/index.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Documentation for LabThings-FastAPI
55
:maxdepth: 2
66
:caption: Contents:
77

8+
contributing.md
89
quickstart/quickstart.rst
910
tutorial/index.rst
1011
structure.rst
@@ -50,6 +51,10 @@ Installation
5051

5152
``pip install labthings-fastapi``
5253

54+
``labthings-fastapi`` supports **Python 3.10, 3.11, 3.12, and 3.13**. The upper limit is strictly capped at 3.13 due to current ``pydantic-core`` dependencies.
55+
56+
.. include:: _windows_arm_note.rst
57+
5358
Indices and tables
5459
==================
5560

@@ -59,4 +64,6 @@ Indices and tables
5964

6065
.. _python-labthings: https://github.com/labthings/python-labthings/
6166
.. _FastAPI: https://fastapi.tiangolo.com/
62-
.. _pydantic: https://pydantic-docs.helpmanual.io/
67+
.. _pydantic: https://pydantic-docs.helpmanual.io/
68+
.. _Visual Studio: https://visualstudio.microsoft.com/
69+
.. _Rust: https://www.rust-lang.org/

docs/source/tutorial/installing_labthings.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,14 @@ then install labthings with:
2525

2626
It is also possible to install LabThings from source, by cloning the GitHub repository and running ``pip install -e .[dev]``, but this is only recommended if you intend to alter the LabThings-FastAPI library; it is best to use the published package unless you have a good reason not to.
2727

28-
.. _PyPI: https://pypi.org/project/labthings-fastapi/
28+
29+
Installation Notes
30+
++++++++++++++++++
31+
32+
``labthings-fastapi`` supports **Python 3.10, 3.11, 3.12, and 3.13**. The upper limit is strictly capped at 3.13 due to current ``pydantic-core`` dependencies.
33+
34+
.. include:: ../_windows_arm_note.rst
35+
36+
.. _PyPI: https://pypi.org/project/labthings-fastapi/
37+
.. _Visual Studio: https://visualstudio.microsoft.com/
38+
.. _Rust: https://www.rust-lang.org/

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ dev = [
4242
"sphinx-autoapi",
4343
"sphinx-toolbox",
4444
"sphobjinv",
45+
"myst-parser<5",
4546
"tomli; python_version < '3.11'",
4647
"codespell",
4748
]
@@ -70,6 +71,7 @@ addopts = [
7071
"--cov-report=xml:coverage.xml",
7172
"--cov-report=html:htmlcov",
7273
"--cov-report=lcov",
74+
"--cov=src"
7375
]
7476
markers = [
7577
"slow: marks tests as slow (deselect with '-m \"not slow\"')",

0 commit comments

Comments
 (0)