Skip to content

Commit

Permalink
feat: update Dockerfile and compose.yml for new example structure and…
Browse files Browse the repository at this point in the history
… environment variables; remove old viz.py
  • Loading branch information
W. Meijer committed Nov 6, 2024
1 parent 3e2deee commit d381615
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM python:3.12


COPY --from=ghcr.io/astral-sh/uv:0.4.20 /uv /bin/uv
COPY --from=ghcr.io/astral-sh/uv:0.4.28 /uv /bin/uv

WORKDIR /workdir

COPY . .

RUN uv pip install --system ".[examples]"
RUN uv sync --extra examples
6 changes: 5 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ services:
meshnetworkx: # the experimental script.
init: true
build: .
command: ["uv", "run", "examples/main.py"]
command: ["uv", "run", "examples/two_device/main.py"]
depends_on:
- zenoh
environment:
ZENOH_ENDPOINTS: tcp/localhost:7447
ports:
- 8080:8080
File renamed without changes.
14 changes: 13 additions & 1 deletion src/meshnetworkx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import json
import os
import pickle
import time
from typing import Any
Expand All @@ -28,6 +29,16 @@ def _totopic(key: str):
return f"{PREFIX}/{key}"


def _get_endpoints() -> list[str]:
endpoints = os.getenv("ZENOH_ENDPOINTS", None)

if not endpoints:
return []

endpoints = endpoints.replace(" ", "").split(",")
return endpoints


class NodeView:
"""Provides a read only view for accessing node data in a dictionary-like manner."""

Expand Down Expand Up @@ -63,7 +74,8 @@ def __init__(self):

# tell zenoh to connect to local router,
# cause multicast scouting does not work in docker outside of linux host.
cfg.insert_json5("connect/endpoints", json.dumps(["tcp/localhost:7447"]))
# cfg.insert_json5("connect/endpoints", json.dumps(["tcp/localhost:7447"]))
cfg.insert_json5("connect/endpoints", json.dumps(_get_endpoints()))

self._z = zenoh.open(cfg)

Expand Down

0 comments on commit d381615

Please sign in to comment.