Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
5d55fff
Add notes file (to be removed before merging)
rwb27 Jul 8, 2025
e50bd38
Improve docstrings in actions/__init__.py
rwb27 Jul 8, 2025
3bf9bee
Check docstrings on invocation_model
rwb27 Jul 8, 2025
edf83b4
Improved docstrings on client module
rwb27 Jul 8, 2025
8cbb4ff
Switch sphinx to rst mode again in docstrings
rwb27 Jul 9, 2025
a193f40
Docstring improvements in `DirectThingClient`
rwb27 Jul 9, 2025
d24920e
Improve docstrings and naming in client code
rwb27 Jul 9, 2025
05ae94f
Fix a couple of typing issues I introduced
rwb27 Jul 9, 2025
057ca01
Whitespace fixes
rwb27 Jul 9, 2025
64cad0c
Fix a D401 from ruff
rwb27 Jul 9, 2025
1deda39
Update lt_core_concepts to use newly-defined links.
rwb27 Jul 9, 2025
92d8a40
Improve docstrings in `descriptors` and add conceptual docs on actions
rwb27 Jul 9, 2025
81460f5
Fix ambiguous type hint
rwb27 Jul 9, 2025
a6824ad
Module level docstring for dependencies
rwb27 Jul 9, 2025
f5dee80
Docstring improvements in dependencies/action_manager
rwb27 Jul 9, 2025
f7f2761
Don't put yield types in docstrings
rwb27 Jul 9, 2025
cd73933
Improvements to blocking portal docstrings
rwb27 Jul 9, 2025
407e562
Started work on invocation dependencies.
rwb27 Jul 9, 2025
436d9ac
Link to conceptual docs and tidy exception.
rwb27 Jul 10, 2025
8530ea2
Finished documenting invocation deps.
rwb27 Jul 10, 2025
274a685
Finish docstringing the dependencies
rwb27 Jul 10, 2025
288aa66
Improve conceptual docs
rwb27 Jul 10, 2025
ecdc274
Note the change to how I recommend using DirectThingClient.
rwb27 Jul 10, 2025
e473dab
Docstring improvements to ActionDescriptor
rwb27 Jul 10, 2025
05192c2
Added a note about Thing-specificity.
rwb27 Jul 10, 2025
869cd68
Finished docstrings on descriptors.
rwb27 Jul 10, 2025
3967727
Add note on property
rwb27 Jul 10, 2025
14423fc
Document example things.
rwb27 Jul 10, 2025
a295d08
Notes
rwb27 Jul 10, 2025
e954bfb
Docstrings for blobs
rwb27 Jul 14, 2025
e571d9c
Added a few more details to blob docs
rwb27 Jul 14, 2025
b662fa7
Finish improving outputs
rwb27 Jul 14, 2025
11ea0c6
Top level docstring referencing docs.
rwb27 Jul 15, 2025
d843a72
Server docstrings
rwb27 Jul 15, 2025
1bf54ac
Fix incorrect type hint
rwb27 Jul 15, 2025
6aaccdd
Document Thing Description
rwb27 Jul 15, 2025
d03b106
Fix a test failing because of a more specific exception.
rwb27 Jul 15, 2025
fcfb6b4
Docstrings in utilities
rwb27 Jul 15, 2025
e55ae27
Documentation on Thing, and added a link to the TD model.
rwb27 Jul 15, 2025
85efab5
Last few docstrings
rwb27 Jul 15, 2025
859f441
Delete examples
rwb27 Jul 15, 2025
81e8b0c
Docstrings for TD model
rwb27 Jul 16, 2025
f5653ce
Lint RST in docstrings
rwb27 Jul 16, 2025
c88c7df
Swap to autoapi
rwb27 Jul 17, 2025
b445f09
Fixed the last few reference/rst issues
rwb27 Jul 17, 2025
d462d2b
Update readthedocs
rwb27 Jul 17, 2025
d226bdc
Get ruff and flake8 passing.
rwb27 Jul 17, 2025
cc5af86
Add flake8 to CI and readme
rwb27 Jul 17, 2025
e9ed606
Standardise on :return: and :raise X:
rwb27 Jul 17, 2025
4c6cc4a
fix typing import for python 3.10
rwb27 Jul 17, 2025
74da279
Remove v3.10 from test job
rwb27 Jul 17, 2025
7d16af6
Typing fixes
rwb27 Jul 17, 2025
6949815
lock dependencies for py3.10 and exclude old python from flake8
rwb27 Jul 17, 2025
060b963
Build docs on 3.12
rwb27 Jul 17, 2025
cd636f9
Add comments to docs/conf.py and test.yml
rwb27 Jul 17, 2025
72fa52e
Delete NOTES, update README, and add a final docstring
rwb27 Jul 17, 2025
2a4ef7e
Spotted a couple of typos/RST issues
rwb27 Jul 18, 2025
0f47e7f
Fix typos and delete examples folder in response to review.
rwb27 Jul 18, 2025
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
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ jobs:
- name: Format with Ruff
run: ruff format --check .

- name: Lint with Flake8 (for docstrings)
if: ${{ contains('3.12,3.13', matrix.python) }}
# Flake8 crashes on Python < 3.12, so we exclude those versions.
# Flake8 is primarily here to lint the docstrings, which
# does not need to happen under multiple versions.
run: flake8 src

- name: Test with pytest
run: pytest --cov=src --cov-report=lcov

Expand Down
5 changes: 3 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.12"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
Expand All @@ -24,4 +24,5 @@ sphinx:
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
- requirements: dev-requirements.txt
- path: .
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

# labthings-fastapi

A FastAPI based library to implement a [Web of Things] interface for laboratory hardware using Python. This is a ground-up rewrite of [python-labthings], replacing Flask 1 and Marshmallow with FastAPI and Pydantic. It is the underlying framework for v3 of the [OpenFlexure Microscope software].
A FastAPI based library to implement a [Web of Things] interface for laboratory hardware using Python. This is a ground-up rewrite of [python-labthings], based on FastAPI and Pydantic. It is the underlying framework for v3 of the [OpenFlexure Microscope software].

Documentation, including install instructions, is available on [readthedocs].

Features include:

Expand All @@ -18,7 +20,7 @@ Features include:
- Dependency injection is used to manage relationships between Things and dependency on the server
* Async HTTP handling
- Starlette (used by FastAPI) can handle requests asynchronously - potential for websockets/events (not used much yet)
- `Thing` code is still, for now, threaded. I intend to make it possible to write async things in the future, but don't intend it to become mandatory
- `Thing` code is still, for now, threaded. It may become possible to write async things in the future, but won't become mandatory
* Smaller codebase
- FastAPI more or less completely eliminates OpenAPI generation code from our codebase
- Thing Description generation is very much simplified by the new structure (multiple Things instead of one massive Thing with many extensions)
Expand All @@ -28,11 +30,11 @@ Features include:

## Installation

You can install this repository with `pip install labthings-fastapi`. It may at some point be renamed to `labthings` v2. For the latest development version, either clone it and run `pip install -e .[dev]` to work on it, or just `pip install https://gitlab.com/rwb27/labthings-fastapi.git`.
See [readthedocs] for installation instructions that are automatically tested. You can install this package with `pip install labthings-fastapi`. It may at some point be renamed to `labthings` v2. For the latest development version, either clone it and run `pip install -e .[dev]` to work on it, or just `pip install https://gitlab.com/rwb27/labthings-fastapi.git`.

## Developer notes

The code is linted with `ruff .`, type checked with `mypy src`, and tested with `pytest`. These all run in CI with GitHub Actions. The codebase is not even `v0.1` yet so it's still subject to summary rearrangement. We recommend a [pre-commit hook] to ensure `ruff` passes on every commit.
The code is linted with `ruff .`, type checked with `mypy src`, and tested with `pytest`. These all run in CI with GitHub Actions. The codebase is not even `v0.1` yet so it's still subject to summary rearrangement. 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`.

Dependencies are defined in `pyproject.toml` and can be compiled to `dev-requirements.txt` with:
```
Expand All @@ -44,9 +46,10 @@ All changes to the codebase should go via pull requests, and should only be merg

## Demo

See the [examples folder](./examples/) for a runnable demo.
See [readthedocs] for a runnable demo.

[Web of Things]: https://www.w3.org/WoT/
[python-labthings]: https://github.com/labthings/python-labthings/
[OpenFlexure Microscope software]: https://gitlab.com/openflexure/openflexure-microscope-server/
[pre-commit hook]: https://openflexure.org/contribute#use-git-hooks-for-ci-checks
[readthedocs]: https://labthings-fastapi.readthedocs.io/
Loading