Skip to content

Commit 1070198

Browse files
add missing files for mkdocs, fix newline error for flake8
1 parent 853a028 commit 1070198

11 files changed

Lines changed: 757 additions & 6 deletions

File tree

.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

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)