Skip to content

Commit 299dd76

Browse files
committed
Fix: Port examples to the new repo setup
1 parent 52b1eb9 commit 299dd76

9 files changed

Lines changed: 33 additions & 18 deletions

File tree

examples/feedback_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# /// script
22
# requires-python = ">=3.10"
3-
# dependencies = ["wildedge", "torch", "timm"]
3+
# dependencies = ["wildedge-sdk", "torch", "timm"]
44
#
55
# [tool.uv.sources]
6-
# wildedge = { path = "..", editable = true }
6+
# wildedge-sdk = { path = "..", editable = true }
77
# ///
88
"""
99
Feedback example — run with: uv run feedback_example.py

examples/gguf_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# /// script
22
# requires-python = ">=3.10"
3-
# dependencies = ["wildedge", "llama-cpp-python", "huggingface_hub"]
3+
# dependencies = ["wildedge-sdk", "llama-cpp-python", "huggingface_hub"]
44
#
55
# [tool.uv.sources]
6-
# wildedge = { path = "..", editable = true }
6+
# wildedge-sdk = { path = "..", editable = true }
77
# ///
88
"""GGUF / llama.cpp integration example — run with: uv run gguf_example.py"""
99

examples/gguf_gemma_manual_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# /// script
22
# requires-python = ">=3.10"
3-
# dependencies = ["wildedge", "llama-cpp-python", "huggingface_hub"]
3+
# dependencies = ["wildedge-sdk", "llama-cpp-python", "huggingface_hub"]
44
#
55
# [tool.uv.sources]
6-
# wildedge = { path = "..", editable = true }
6+
# wildedge-sdk = { path = "..", editable = true }
77
# ///
88
"""Gemma 2 GGUF — fully manual integration, no auto-instrumentation.
99

examples/keras_example.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# /// script
22
# requires-python = ">=3.10"
3-
# dependencies = ["wildedge", "keras"]
3+
# dependencies = ["wildedge-sdk", "keras", "tensorflow"]
44
#
55
# [tool.uv.sources]
6-
# wildedge = { path = "..", editable = true }
6+
# wildedge-sdk = { path = "..", editable = true }
77
# ///
88
"""
99
Keras integration example — run with: uv run keras_example.py
@@ -21,9 +21,10 @@
2121
# TensorFlow/Keras may not be available; skip gracefully
2222
try:
2323
from keras.applications import MobileNetV2
24-
from keras.preprocessing.image import preprocess_input
25-
except ImportError:
26-
print("Keras not installed. Install with: pip install keras tensorflow")
24+
from keras.applications.mobilenet_v2 import preprocess_input
25+
except ImportError as exc:
26+
print(f"Keras/TensorFlow import failed: {exc}")
27+
print("Install with: pip install keras tensorflow")
2728
exit(1)
2829

2930
client = wildedge.WildEdge(
@@ -32,7 +33,6 @@
3233

3334
# Load a pre-trained MobileNetV2 model using client to track construction and lifecycle
3435
model = client.load(lambda: MobileNetV2(weights="imagenet"))
35-
model.eval()
3636

3737
# Generate dummy image batch (batch_size=4, 224x224x3)
3838
batch = np.random.randn(4, 224, 224, 3).astype(np.float32) * 255

examples/onnx_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# /// script
22
# requires-python = ">=3.10"
3-
# dependencies = ["wildedge", "onnxruntime", "huggingface_hub", "numpy"]
3+
# dependencies = ["wildedge-sdk", "onnxruntime", "huggingface_hub", "numpy"]
44
#
55
# [tool.uv.sources]
6-
# wildedge = { path = "..", editable = true }
6+
# wildedge-sdk = { path = "..", editable = true }
77
# ///
88
"""ONNX Runtime integration example — run with: uv run onnx_example.py"""
99

examples/pytorch_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# /// script
22
# requires-python = ">=3.10"
3-
# dependencies = ["wildedge", "torch"]
3+
# dependencies = ["wildedge-sdk", "torch", "numpy"]
44
#
55
# [tool.uv.sources]
6-
# wildedge = { path = "..", editable = true }
6+
# wildedge-sdk = { path = "..", editable = true }
77
# ///
88
"""PyTorch integration example — run with: uv run pytorch_example.py"""
99

examples/timm_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# /// script
22
# requires-python = ">=3.10"
3-
# dependencies = ["wildedge", "torch", "timm"]
3+
# dependencies = ["wildedge-sdk", "torch", "timm"]
44
#
55
# [tool.uv.sources]
6-
# wildedge = { path = "..", editable = true }
6+
# wildedge-sdk = { path = "..", editable = true }
77
# ///
88
"""
99
timm integration example — run with: uv run timm_example.py

tests/test_device.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
"""Tests for device detection."""
22

3+
from pathlib import Path
34
from unittest.mock import patch
45

56
from wildedge.device import (
67
DeviceInfo,
78
LinuxPlatform,
89
MacOSPlatform,
910
detect_device,
11+
get_device_id_path,
1012
hmac_device_id,
1113
)
1214

@@ -87,3 +89,12 @@ def test_to_dict_returns_protocol_fields(self):
8789
assert d["device_type"] == "linux"
8890
assert d["app_version"] == "2.0.0"
8991
assert "sdk_version" in d
92+
93+
def test_get_device_id_path_uses_config_constants(self):
94+
class _FakePlatform:
95+
def config_base(self):
96+
return Path("/tmp/test-config")
97+
98+
with patch("wildedge.device.CURRENT_PLATFORM", _FakePlatform()):
99+
path = get_device_id_path()
100+
assert path == Path("/tmp/test-config/wildedge/device_id")

wildedge/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
ERROR_MSG_MAX_LEN = 200
2323

2424
# Device ID persistence
25+
DEVICE_ID_DIR = "wildedge"
26+
DEVICE_ID_FILE = "device_id"
27+
28+
# Runtime validation limits
2529
BATCH_SIZE_MIN = 1
2630
BATCH_SIZE_MAX = 100
2731
FLUSH_INTERVAL_MIN = 1

0 commit comments

Comments
 (0)