Skip to content

Commit

Permalink
Merge pull request #7 from ezmsg-org/dev
Browse files Browse the repository at this point in the history
Migrate to uv
  • Loading branch information
cboulay authored Sep 26, 2024
2 parents 5055ab1 + 30af46c commit 36b118f
Show file tree
Hide file tree
Showing 10 changed files with 398 additions and 189 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/python-publish-ezmsg-blackrock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Upload Python Package - ezmsg-blackrock

on:
release:
types: [published]
workflow_dispatch:

jobs:
build:
name: build and upload release to PyPI
runs-on: ubuntu-latest
environment: "release"
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v2

- name: Build Package
run: uv build

- name: Publish package distributions to PyPI
run: uv publish
41 changes: 41 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test package

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
build:
strategy:
matrix:
python-version: [3.9, "3.10", "3.11", "3.12"]
os:
- "ubuntu-latest"
- "windows-latest"
- "macos-latest"
runs-on: ${{matrix.os}}

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install the project
run: uv sync --all-extras --dev

- name: Lint
run:
uv tool run ruff check --output-format=github src

- name: Run tests
run: uv run pytest tests
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

src/ezmsg/blackrock/__version__.py
26 changes: 10 additions & 16 deletions examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ezmsg.blackrock.nsp import NSPSource, NSPSourceSettings
from ezmsg.util.debuglog import DebugLog

if __name__ == '__main__':
if __name__ == "__main__":
import argparse

parser = argparse.ArgumentParser(description="Consume data from NSP")
Expand All @@ -16,16 +16,16 @@
type=str,
default="192.168.137.128",
help="ipv4 address of device. pycbsdk will send control packets to this address. Subnet OK. "
"Use 127.0.0.1 for use with nPlayServer (non-bcast). "
"The default is 0.0.0.0 (IPADDR_ANY) on Mac and Linux. On Windows, known IPs will be searched.",
"Use 127.0.0.1 for use with nPlayServer (non-bcast). "
"The default is 0.0.0.0 (IPADDR_ANY) on Mac and Linux. On Windows, known IPs will be searched.",
)

parser.add_argument(
"--inst_port",
type=int,
default=51001,
help="Network port to send control packets."
"Use 51002 for Gemini and 51001 for Legacy NSP.",
"Use 51002 for Gemini and 51001 for Legacy NSP.",
)

parser.add_argument(
Expand All @@ -34,7 +34,7 @@
type=str,
default="",
help="ipv4 address of this machine's network adapter we will receive packets on. "
"Defaults to INADDR_ANY. If address is provided, assumes Cerebus Subnet.",
"Defaults to INADDR_ANY. If address is provided, assumes Cerebus Subnet.",
)

parser.add_argument(
Expand All @@ -50,7 +50,7 @@
"-b",
type=int,
help=f"UDP socket recv buffer size. "
f"Default: {(8 if sys.platform == 'win32' else 6) * 1024 * 1024}.",
f"Default: {(8 if sys.platform == 'win32' else 6) * 1024 * 1024}.",
)

parser.add_argument(
Expand All @@ -64,29 +64,23 @@
"--cont_smp_group",
type=int,
default=0,
help="Continuous data Sampling Group (1-6) to publish. Set to 0 to ignore continuous data."
help="Continuous data Sampling Group (1-6) to publish. Set to 0 to ignore continuous data.",
)

parser.add_argument(
"--cont_buffer_dur",
type=float,
default=0.5,
help="Duration of buffer for continuous data. Note: buffer may occupy ~15 MB / second."
help="Duration of buffer for continuous data. Note: buffer may occupy ~15 MB / second.",
)

parser.add_argument(
"--cont_override_config_all",
action="store_true",
help="Set this flag to set all analog channels to cont_smp_group (group 0 will disable continuous data)."
help="Set this flag to set all analog channels to cont_smp_group (group 0 will disable continuous data).",
)

source = NSPSource(NSPSourceSettings(**vars(parser.parse_args())))
log = DebugLog()

ez.run(
SOURCE=source,
LOG=log,
connections=(
(source.OUTPUT_SPIKE, log.INPUT),
)
)
ez.run(SOURCE=source, LOG=log, connections=((source.OUTPUT_SPIKE, log.INPUT),))
131 changes: 0 additions & 131 deletions poetry.lock

This file was deleted.

42 changes: 29 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
[tool.poetry]
[project]
name = "ezmsg-blackrock"
version = "0.1.1"
description = "Blackrock Cerebus ecosystem interface for ezmsg"
authors = ["Griffin Milsap <[email protected]>"]
authors = [
{ name = "Griffin Milsap", email = "[email protected]" },
{ name = "Chadwick Boulay", email = "[email protected]" },
]
readme = "README.md"
homepage = "https://github.com/griffinmilsap/ezmsg-blackrock"
packages = [
{ include = "ezmsg", from = "src" }
requires-python = ">=3.9"
dynamic = ["version"]
dependencies = [
"ezmsg>=3.5.0",
"pycbsdk>=0.1.3",
]

[project.optional-dependencies]
test = [
"pytest>=8.3.3",
]

[tool.poetry.dependencies]
python = "^3.9"
ezmsg = "^3.5.0"
pycbsdk = "^0.1.3"
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.hatch.version]
source = "vcs"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.hatch.build.hooks.vcs]
version-file = "src/ezmsg/blackrock/__version__.py"

[tool.hatch.build.targets.wheel]
packages = ["src/ezmsg"]

[tool.uv]
dev-dependencies = [
"ruff>=0.6.8",
]
5 changes: 1 addition & 4 deletions src/ezmsg/blackrock/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
import importlib.metadata


__version__ = importlib.metadata.version("ezmsg-blackrock")
from .__version__ import __version__ as __version__
Loading

0 comments on commit 36b118f

Please sign in to comment.