Skip to content

Commit fe8ae1d

Browse files
Merge pull request Botts-Innovative-Research#32 from Botts-Innovative-Research/part3-compliance-update
Part3 compliance update
2 parents 3f07ec4 + 981e5a4 commit fe8ae1d

51 files changed

Lines changed: 5023 additions & 497 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs_pages.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ on: [ push, pull_request, workflow_dispatch ]
33
permissions:
44
contents: write
55

6+
concurrency:
7+
group: docs-${{ github.ref }}
8+
cancel-in-progress: true
9+
610
jobs:
711
build-docs:
812
runs-on: ubuntu-latest
@@ -19,9 +23,9 @@ jobs:
1923
- name: Install dependencies
2024
run: uv sync --all-extras
2125

22-
- name: Sphinx build
26+
- name: Build MkDocs site
2327
run: |
24-
uv run sphinx-build -b html docs/source docs/build/html
28+
uv run mkdocs build --strict
2529
2630
- name: Deploy documentation
2731
uses: peaceiris/actions-gh-pages@v4

README.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,54 @@ recommendations for data, retrieving data in real time, archival streams, and ba
55

66
API Documentation available [here](https://botts-innovative-research.github.io/OSHConnect-Python/)
77

8-
Links:
8+
Links:
99
* [Architecture Doc](https://docs.google.com/document/d/1pIaeQw0ocU6ApNgqTVRZuSwjJAbhCcmweMq6RiVYEic/edit?usp=sharing)
10-
* [UML Diagram](https://drive.google.com/file/d/1FVrnYiuAR8ykqfOUa1NuoMyZ1abXzMPw/view?usp=drive_link)
10+
* [UML Diagram](https://drive.google.com/file/d/1FVrnYiuAR8ykqfOUa1NuoMyZ1abXzMPw/view?usp=drive_link)
11+
12+
## Generating the Docs
13+
14+
The documentation is built with [MkDocs](https://www.mkdocs.org/) using the
15+
Material theme, [mkdocstrings](https://mkdocstrings.github.io/) for
16+
auto-generated API reference from the source, and
17+
[mermaid](https://mermaid.js.org/) for architecture diagrams. Markdown sources
18+
live under `docs/markdown/`.
19+
20+
Install dev dependencies (including MkDocs and plugins):
21+
22+
```bash
23+
uv sync
24+
```
25+
26+
Build the HTML docs:
27+
28+
```bash
29+
uv run mkdocs build
30+
```
31+
32+
The output will be in `docs/build/html/`. Open `docs/build/html/index.html` in
33+
a browser to view locally.
34+
35+
For a live-reloading preview while editing:
36+
37+
```bash
38+
uv run mkdocs serve
39+
```
40+
41+
Then visit http://127.0.0.1:8000.
42+
43+
To match what CI publishes (warnings become errors — useful when you've
44+
touched docstrings):
45+
46+
```bash
47+
uv run mkdocs build --strict
48+
```
49+
50+
CI builds the site on every push and deploys `main` to GitHub Pages via
51+
`.github/workflows/docs_pages.yaml`.
52+
53+
The legacy Sphinx setup under `docs/source/` is kept temporarily for
54+
reference and builds to a separate output directory:
55+
56+
```bash
57+
uv run sphinx-build -b html docs/source docs/build/sphinx
58+
```

docker-compose.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# =============================================================================
2+
# OSHConnect-Python — Local PyPI Server
3+
#
4+
# A lightweight pypiserver for publishing dev builds of oshconnect so that
5+
# downstream projects (OCSASim, etc.) can `pip install` normally instead of
6+
# pointing at raw wheel paths.
7+
#
8+
# Usage:
9+
# docker compose up -d # start the local PyPI
10+
# ./scripts/publish-local.sh # build wheel + upload to local PyPI
11+
# docker compose down -v # tear down + remove packages volume
12+
#
13+
# Consumer side (e.g. OCSASim):
14+
# pip install --index-url http://localhost:8090/simple/ oshconnect
15+
# uv pip install --index-url http://localhost:8090/simple/ oshconnect
16+
# =============================================================================
17+
18+
services:
19+
pypi:
20+
image: pypiserver/pypiserver:latest
21+
container_name: local-pypi
22+
command: run -a . -P . -o
23+
ports:
24+
- "8090:8080"
25+
volumes:
26+
- pypi-packages:/data/packages
27+
healthcheck:
28+
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://localhost:8080/"]
29+
interval: 5s
30+
timeout: 3s
31+
start_period: 5s
32+
retries: 3
33+
34+
volumes:
35+
pypi-packages:

docs/markdown/api.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# API Reference
2+
3+
All public symbols are re-exported from the top-level package and can be
4+
imported directly:
5+
6+
```python
7+
from oshconnect import OSHConnect, Node, Datastream, TimePeriod, ObservationFormat
8+
```
9+
10+
Lower-level CS API utilities are available from the `oshconnect.csapi4py`
11+
sub-package:
12+
13+
```python
14+
from oshconnect.csapi4py import APIResourceTypes, MQTTCommClient, ConnectedSystemsRequestBuilder
15+
```
16+
17+
---
18+
19+
## Core Application
20+
21+
::: oshconnect.oshconnectapi
22+
23+
---
24+
25+
## Streamable Resources
26+
27+
The primary objects for interacting with systems, datastreams, and control
28+
streams on an OSH node. Includes `Node`, `System`, `Datastream`,
29+
`ControlStream`, and supporting enums.
30+
31+
::: oshconnect.streamableresource
32+
33+
---
34+
35+
## Resource Data Models
36+
37+
Pydantic models that represent CS API resources returned from or sent to an
38+
OSH server.
39+
40+
::: oshconnect.resource_datamodels
41+
42+
---
43+
44+
## SWE Schema Components
45+
46+
Builder classes for constructing datastream and command schemas using SWE
47+
Common data types.
48+
49+
::: oshconnect.swe_components
50+
51+
::: oshconnect.schema_datamodels
52+
53+
---
54+
55+
## Event System
56+
57+
Pub/sub event bus for in-process notifications. Implement `IEventListener`
58+
to receive events.
59+
60+
::: oshconnect.eventbus
61+
62+
::: oshconnect.events.core
63+
64+
::: oshconnect.events.builder
65+
66+
---
67+
68+
## Time Management
69+
70+
::: oshconnect.timemanagement
71+
72+
---
73+
74+
## CS API Integration (`csapi4py`)
75+
76+
### Constants and Enums
77+
78+
::: oshconnect.csapi4py.constants
79+
80+
### Request Builder
81+
82+
::: oshconnect.csapi4py.con_sys_api
83+
84+
### API Helper
85+
86+
::: oshconnect.csapi4py.default_api_helpers
87+
88+
### MQTT Client
89+
90+
::: oshconnect.csapi4py.mqtt

docs/markdown/architecture.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Architecture
2+
3+
OSHConnect is structured around a small number of long-lived objects that mirror
4+
the resource hierarchy of the OGC API – Connected Systems specification.
5+
6+
## Object hierarchy
7+
8+
```mermaid
9+
graph TD
10+
OSHConnect[OSHConnect<br/><i>application entry point</i>]
11+
Node[Node<br/><i>connection to one OSH server</i>]
12+
APIHelper[APIHelper<br/><i>CS API HTTP requests</i>]
13+
Session[SessionManager<br/><i>OSHClientSession instances</i>]
14+
MQTT[MQTTCommClient<br/><i>paho-mqtt wrapper</i>]
15+
System[System<br/><i>sensor system</i>]
16+
Datastream[Datastream<br/><i>output channel — observations</i>]
17+
ControlStream[ControlStream<br/><i>input channel — commands &amp; status</i>]
18+
19+
OSHConnect --> Node
20+
Node --> APIHelper
21+
Node --> Session
22+
Node --> MQTT
23+
Node --> System
24+
System --> Datastream
25+
System --> ControlStream
26+
```
27+
28+
## Key abstractions
29+
30+
- **`OSHConnect`** (`oshconnectapi.py`) — top-level class. Owns nodes and
31+
provides `discover_systems()`, `discover_datastreams()`,
32+
`save_config()` / `load_config()`, and `create_and_insert_system()`.
33+
- **`Node`** (`streamableresource.py`) — wraps a server connection. Drives
34+
discovery via `APIHelper` and owns the `MQTTCommClient`. All HTTP resource
35+
creation goes through here.
36+
- **`StreamableResource`** (`streamableresource.py`) — abstract base for
37+
`System`, `Datastream`, and `ControlStream`. Manages MQTT
38+
subscriptions/publications, WebSocket connections, and the inbound /
39+
outbound message deques. Connection modes: `PUSH`, `PULL`, `BIDIRECTIONAL`.
40+
- **`Datastream` / `ControlStream`** (`streamableresource.py`) — concrete
41+
streamable resources. Datastreams publish observations; ControlStreams
42+
publish commands and receive status updates. Both follow CS API Part 3
43+
topic conventions (`:data`, `:status`, `:commands`).
44+
- **`resource_datamodels.py`** — Pydantic models for the CS API resource types
45+
(`SystemResource`, `DatastreamResource`, `ControlStreamResource`,
46+
`ObservationResource`). These map directly to API request and response
47+
bodies.
48+
- **`swe_components.py`** — Pydantic models for SWE Common schema components
49+
(`DataRecordSchema`, `QuantitySchema`, `VectorSchema`, etc.). Used to define
50+
observation and command schemas when creating new datastreams.
51+
- **`csapi4py/`** — sub-package that handles the CS API specifics: URL
52+
construction (`endpoints.py`), request building (`con_sys_api.py`), enums
53+
(`constants.py`), and MQTT topic conventions (`mqtt.py`).
54+
- **`EventHandler`** (`eventbus.py`) — singleton pub/sub bus. Listeners
55+
subscribe to event types (e.g. `NEW_OBSERVATION`) and topic strings; events
56+
are dispatched asynchronously through an internal queue.
57+
- **`timemanagement.py`**`TimeInstant` (epoch / ISO-8601), `TimePeriod`,
58+
`TemporalModes` (`REAL_TIME`, `ARCHIVE`, `BATCH`), and `TimeUtils`
59+
conversions.
60+
61+
## Typical data flow
62+
63+
```mermaid
64+
sequenceDiagram
65+
autonumber
66+
participant App as OSHConnect
67+
participant N as Node
68+
participant H as APIHelper
69+
participant S as Server
70+
participant DS as Datastream
71+
72+
App->>N: add_node()
73+
App->>N: discover_systems()
74+
N->>H: retrieve_resource(SYSTEM)
75+
H->>S: HTTP GET /systems
76+
S-->>H: JSON
77+
H-->>N: System objects
78+
App->>DS: discover_datastreams()
79+
DS->>DS: initialize() — open MQTT/WebSocket
80+
DS->>DS: start() — begin streaming
81+
S-->>DS: observations → _inbound_deque
82+
Note over App,DS: To insert: resource.insert_self() →<br/>APIHelper.create_resource() → POST →<br/>server returns Location header with new ID
83+
```
84+
85+
## Dependencies
86+
87+
- **pydantic** — all resource and schema models. Bumping the minimum requires
88+
confirming pre-built wheels exist for all supported Python versions
89+
(3.12 – 3.14).
90+
- **shapely** — geometry handling for spatial resources.
91+
- **paho-mqtt** — MQTT streaming for CS API Part 3.
92+
- **websockets** / **aiohttp** — WebSocket and async HTTP streaming.
93+
- **requests** — synchronous HTTP for discovery and resource creation.

docs/markdown/index.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# OSHConnect-Python
2+
3+
OSHConnect-Python is the Python member of the OSHConnect family of application
4+
libraries. It provides a simple, straightforward way to interact with
5+
OpenSensorHub (or any other OGC API – Connected Systems server).
6+
7+
It supports Parts 1, 2, and 3 (Pub/Sub) of the OGC Connected Systems API,
8+
including:
9+
10+
- System, Datastream, and ControlStream discovery and management
11+
- Real-time MQTT streaming using CS API Part 3 `:data` topic conventions
12+
- Resource event topic subscriptions (CloudEvents lifecycle notifications)
13+
- Batch retrieval and archival stream playback
14+
- Configuration persistence (JSON save/load)
15+
- SWE Common schema builders for defining datastream and command schemas
16+
17+
All major classes and utilities are importable directly from `oshconnect`.
18+
Lower-level CS API utilities are available from `oshconnect.csapi4py`.
19+
20+
## Where to next
21+
22+
- [Architecture](architecture.md) — object hierarchy, data flow, and key abstractions
23+
- [Tutorial](tutorial.md) — common workflows for connecting, discovering, streaming, and inserting resources
24+
- [API Reference](api.md) — auto-generated reference for every public symbol

0 commit comments

Comments
 (0)