Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,41 @@ on:
workflow_call: {}

jobs:
CheckGeneratedProtobuf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.9.15"
python-version: "3.10"
- name: Install protoc 33.2
run: |
curl --fail --location \
--output "$RUNNER_TEMP/protoc.zip" \
https://github.com/protocolbuffers/protobuf/releases/download/v33.2/protoc-33.2-linux-x86_64.zip
unzip "$RUNNER_TEMP/protoc.zip" -d "$RUNNER_TEMP/protoc"
echo "$RUNNER_TEMP/protoc/bin" >> "$GITHUB_PATH"
- name: Install dependencies
run: uv sync --locked --dev
- name: Generate protobuf bindings
run: |
uv run protoc \
--proto_path=src/wlsonar/range_image_protocol/_proto/ \
--python_out=src/wlsonar/range_image_protocol/_proto/ \
--mypy_out=src/wlsonar/range_image_protocol/_proto/ \
src/wlsonar/range_image_protocol/_proto/WaterLinkedSonarIntegrationProtocol.proto
- name: Check generated protobuf bindings are up to date
run: |
echo "Checking that protobuf generation did not cause a diff."
echo "If this fails, regenerate the bindings before committing."
git diff --exit-code -- src/wlsonar/range_image_protocol/_proto/

Check:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
14 changes: 13 additions & 1 deletion README_dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,19 @@ Versioning is handled with `uv`. Setting a new version with `uv version <new ver

## Protobuf

The Sonar 3D-15 uses a .proto file to define message formats. This package includes generated Python for these messages. When changing the .proto file, run the following to generate new Python code:
The Sonar 3D-15 uses a .proto file to define message formats. wlsonar includes generated Python for these messages using protoc.

The version of protoc used to generate code should match the Python protobuf package requirement in pyproject.toml.
At the time of writing the Python protobuf dependency is `>=6.33.2,<7`, meaning the protoc compiler should be 33.2.

Install 33.2 here: https://github.com/protocolbuffers/protobuf/releases/tag/v33.2

There is a pipeline check to assert that the generated code matches the expected protoc version.

> [!IMPORTANT]
> If the Python library in pyproject.toml is updated, this section should be updated also.

When changing the .proto file, run the following to generate new Python code:

```bash
uv run protoc \
Expand Down
2 changes: 1 addition & 1 deletion examples/convert_recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# requires-python = ">=3.10"
# dependencies = [
# "pillow>=12.1.0,<13",
# "wlsonar>=0.5.4,<0.6",
# "wlsonar>=0.5.5,<0.6",
# ]
# ///
"""Example use of wlsonar module to convert .sonar recordings to .xyz and .png files."""
Expand Down
2 changes: 1 addition & 1 deletion examples/imu.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "wlsonar>=0.5.4,<0.6",
# "wlsonar>=0.5.5,<0.6",
# ]
# ///
"""Example use of wlsonar module: Receive IMU data and print it."""
Expand Down
2 changes: 1 addition & 1 deletion examples/record_udp_to_file.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "wlsonar>=0.5.4,<0.6",
# "wlsonar>=0.5.5,<0.6",
# ]
# ///
"""Example use of wlsonar module: Record UDP packets from Sonar 3D-15 to a .sonar file."""
Expand Down
2 changes: 1 addition & 1 deletion examples/trim_recording.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "wlsonar>=0.5.4,<0.6",
# "wlsonar>=0.5.5,<0.6",
# ]
# ///
"""Example use of wlsonar module to trim a .sonar recording by timestamps."""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "wlsonar"
version = "0.5.4"
version = "0.5.5"
description = "Python client and Range Image Protocol utilities for Water Linked Sonar 3D-15."
readme = "README.md"
authors = [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/test_e2e_real_sonar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import datetime
from importlib.metadata import version
from typing import Literal, cast

import pytest
Expand Down Expand Up @@ -32,6 +33,8 @@ def test_e2e_Sonar3D_client_against_real_sonar(request: pytest.FixtureRequest) -
Example use:
uv run pytest -s -m e2e --sonar-ip 10.1.2.156
"""
print(f"wlsonar version: {version('wlsonar')}")

sonar_ip = request.config.getoption("--sonar-ip")
assert sonar_ip is not None and isinstance(sonar_ip, str), (
"This test requires --sonar-ip to be set."
Expand Down
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.