Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ jobs:
- name: Run ruff
run: uv run ruff check
- name: Run mypy
run: uv run mypy .
run: uv run mypy . --exclude examples
- name: Test
run: uv run pytest
8 changes: 6 additions & 2 deletions README_dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
uv sync
```

## Examples

To run the example code with a locally edited version of wlsonar, use: `uv run --with-editable . examples/trim_recording.py`.

## Linting

The package is linted with `ruff` and `mypy`:

```bash
uv run ruff check
uv run ruff format --diff
uv run mypy .
uv run mypy . --exclude examples
```

## Testing
Expand Down Expand Up @@ -44,4 +48,4 @@ uv run protoc \
--python_out=src/wlsonar/range_image_protocol/_proto/ \
--mypy_out=src/wlsonar/range_image_protocol/_proto/ \
src/wlsonar/range_image_protocol/_proto/WaterLinkedSonarIntegrationProtocol.proto
```
```
4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ The following examples are provided:
- [convert_recording.py](./convert_recording.py)
- [trim_recording.py](./trim_recording.py)

The examples require the dev dependencies listed in pyproject.toml. If you have [`uv`](https://docs.astral.sh/uv/) installed, you can run the examples with for example `uv run python trim_recording.py`.
The examples declare inline script dependencies. If you have [`uv`](https://docs.astral.sh/uv/) installed, you can `uv run` the examples directly: `uv run examples/trim_recording.py`.

There is a short test recording included as test data: [ship_short.sonar](/tests/data/ship_short.sonar).
There is a short test recording included as test data: [ship_short.sonar](/tests/data/ship_short.sonar).
10 changes: 10 additions & 0 deletions examples/convert_recording.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "pillow>=12.1.0,<13",
# "wlsonar>=0.3.1,<0.5",
# ]
# ///
"""Example use of wlsonar module to convert .sonar recordings to .xyz and .png files."""

import argparse
import os
from importlib.metadata import version

from PIL import Image

Expand Down Expand Up @@ -29,6 +37,8 @@ def make_filename(header: rip.Header, extension: str) -> str:


if __name__ == "__main__":
print(f"wlsonar version: {version('wlsonar')}")

parser = argparse.ArgumentParser(
description=(
"Example use of wlsonar module: Convert the first -n packets to .xyz and "
Expand Down
9 changes: 9 additions & 0 deletions examples/record_udp_to_file.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "wlsonar>=0.3.1,<0.5",
# ]
# ///
"""Example use of wlsonar module: Record UDP packets from Sonar 3D-15 to a .sonar file."""

import argparse
import time
from collections import defaultdict
from importlib.metadata import version
from typing import DefaultDict, Set

import wlsonar.range_image_protocol as rip
Expand All @@ -20,6 +27,8 @@ def human_readable_size(size: int) -> str:


if __name__ == "__main__":
print(f"wlsonar version: {version('wlsonar')}")

parser = argparse.ArgumentParser(
description=(
"Example use of wlsonar module: Record UDP multicast packets from Sonar 3D-15 to a "
Expand Down
9 changes: 9 additions & 0 deletions examples/trim_recording.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "wlsonar>=0.3.1,<0.5",
# ]
# ///
"""Example use of wlsonar module to trim a .sonar recording by timestamps."""

import argparse
import datetime
from importlib.metadata import version
from typing import Optional

import wlsonar.range_image_protocol as rip
Expand All @@ -27,6 +34,8 @@ def parse_time(timestr: str) -> datetime.time:


if __name__ == "__main__":
print(f"wlsonar version: {version('wlsonar')}")

parser = argparse.ArgumentParser(
description=(
"Example use of wlsonar module: Trim the a .sonar recording to include only packets"
Expand Down
19 changes: 9 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[project]
name = "wlsonar"
version = "0.3.1"
version = "0.4.0"
description = "Python client and Range Image Protocol utilities for Water Linked Sonar 3D-15."
readme = "README.md"
authors = [
{ name = "Water Linked" }
]
requires-python = ">=3.10"
dependencies = [
"protobuf>=6.33.2",
"python-snappy>=0.7.3",
"requests>=2.32.5",
"protobuf>=6.33.2,<7",
"python-snappy>=0.7.3,<0.8",
"requests>=2.32.5,<3",
]

[project.urls]
Expand All @@ -27,12 +27,11 @@ disallow_untyped_defs = true

[dependency-groups]
dev = [
"mypy>=1.19.1",
"mypy-protobuf>=4.0.0",
"pdbpp>=0.11.7",
"pillow>=12.1.0",
"pytest>=9.0.2",
"ruff>=0.14.10",
"mypy>=1.19.1,<2",
"mypy-protobuf>=4.0.0,<5",
"pdbpp>=0.11.7,<0.12",
"pytest>=9.0.2,<10",
"ruff>=0.14.10,<0.15",
]

[[tool.mypy.overrides]]
Expand Down
118 changes: 9 additions & 109 deletions uv.lock

Large diffs are not rendered by default.