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/compat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
--version-set "${{ matrix.version-set }}" \
--python-version "${{ matrix.python-version }}"
- name: Cache downloaded test models
if: matrix.integration == 'gguf' || matrix.integration == 'faster_whisper'
if: matrix.integration == 'llama_cpp' || matrix.integration == 'faster_whisper'
uses: actions/cache@v4
with:
path: |
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ under Unreleased and move into a version section at release time.

### Changed

- The llama.cpp Python integration is now named `llama_cpp` in Python, CLI,
and environment configuration. `gguf` remains a compatibility alias; `all`
selects the integration once under its new name. Model format metadata
remains `gguf`.

- Automatic integrations no longer attach raw payloads, including GGUF prompts,
chat messages and replies. `attachments_enabled=True` enables uploads only for
attachments explicitly passed to `track_inference(attachments=[...])`.
Expand Down
49 changes: 15 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
[![PyPI](https://img.shields.io/pypi/v/wildedge-sdk)](https://pypi.org/project/wildedge-sdk/)
[![Coverage](https://codecov.io/gh/wild-edge/wildedge-python/branch/main/graph/badge.svg)](https://codecov.io/gh/wild-edge/wildedge-python)

ML inference monitoring for Python: on-device and remote models. Tracks latency, tokens, errors, and model metadata with no code changes, plus traces for agent pipelines.
Monitor local and remote ML inference from Python. Track latency, token usage,
errors, model metadata, and local hardware context across llama.cpp, MLX,
Transformers, OpenAI, and more.

**[Get a DSN](https://app.wildedge.dev)** · [Website](https://wildedge.dev) · [Docs](https://docs.wildedge.dev) · [Blog](https://blog.wildedge.dev)
Instrument supported libraries with one command, or add tracking in your code.
Prompts and outputs aren't uploaded unless you explicitly attach them.

**[Get started](#install)** · [Docs](https://docs.wildedge.dev) · [Website](https://wildedge.dev)

## Install

Expand All @@ -26,32 +31,19 @@ To send events, sign up at [app.wildedge.dev](https://app.wildedge.dev), create

## CLI

Drop `wildedge run` in front of your existing command. WildEdge instruments the runtime before your code starts. No SDK calls required in user code.
Monitor an existing application by adding `wildedge run` to its start command:

```bash
WILDEDGE_DSN="https://<secret>@ingest.wildedge.dev/<key>" \
wildedge run --integrations timm -- python app.py
```

Validate your environment before deploying. `--send-test-event` proves the
whole pipeline end to end by sending one span event and reporting the ingest
response (exit codes: 0 pass, 1 config failure, 2 connectivity failure):

```bash
wildedge doctor --integrations all --send-test-event
wildedge run --integrations llama_cpp -- python app.py
```

Useful flags:
The `llama_cpp` integration instruments llama.cpp through `llama-cpp-python`.
Replace it with your [integration](#supported-integrations).
No SDK calls are required in your application code.

| Flag | Description |
|---|---|
| `--integrations` | Comma-separated list of integrations to activate (or `all`) |
| `--hubs` | Hub trackers to activate: `huggingface`, `torchhub` |
| `--print-startup-report` | Print per-integration status at startup |
| `--strict-integrations` | Exit (code 121) if a requested integration can't be instrumented |
| `--strict` | Exit (120 config, 122 internal) instead of running untracked when bootstrap fails |
| `--attachments` | Enable opt-in raw input/output attachment upload |
| `--no-propagate` | Don't pass WildEdge env vars to child processes |
See the [deployment guide](docs/deployment.md) for startup options,
environment validation, and production configuration.

## SDK

Expand Down Expand Up @@ -91,7 +83,7 @@ for client lifecycle and the full contract.
| `mlx_whisper` / `faster_whisper` | [whisper_example.py](https://github.com/wild-edge/wildedge-python/blob/main/examples/whisper_example.py) |
| `mlx` | [mlx_example.py](https://github.com/wild-edge/wildedge-python/blob/main/examples/mlx_example.py) |
| `timm` | [timm_example.py](https://github.com/wild-edge/wildedge-python/blob/main/examples/timm_example.py) |
| `gguf` | [gguf_example.py](https://github.com/wild-edge/wildedge-python/blob/main/examples/gguf_example.py) |
| llama.cpp (`llama_cpp`, via `llama-cpp-python`) | [gguf_example.py](https://github.com/wild-edge/wildedge-python/blob/main/examples/gguf_example.py) |
| `onnx` | [onnx_example.py](https://github.com/wild-edge/wildedge-python/blob/main/examples/onnx_example.py) |
| `ultralytics` | - |
| `tensorflow` | [tensorflow_example.py](https://github.com/wild-edge/wildedge-python/blob/main/examples/tensorflow_example.py) |
Expand Down Expand Up @@ -148,17 +140,6 @@ For unsupported frameworks, see [Manual tracking](https://github.com/wild-edge/w

For advanced options (batching, queue tuning, dead-letter storage, attachments), see [Configuration](https://github.com/wild-edge/wildedge-python/blob/main/docs/configuration.md).

## Projects using this SDK

| Name | Link |
|---|---|
| outfitstudio.app | https://outfitstudio.app/ |
| agntr | [github.com/pmaciolek/agntr](https://github.com/pmaciolek/agntr) |
| demo-app | [github.com/wild-edge/demo-app](https://github.com/wild-edge/demo-app) |
| *(your project here)* | - |

Using WildEdge in your project? Open a PR to add it to the list.

## Security & Privacy

By default the SDK transmits only anonymized telemetry, never raw model inputs
Expand Down
8 changes: 4 additions & 4 deletions docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ generated from `scripts/compat_matrix.py`, which also defines the CI jobs.
`tests/compat/test_<integration>_compat.py` loads a real model with the real
library and checks the events the SDK records: a `model_load` event, then an
`inference` event for the same model with the expected fields (token counts
for LLMs, input modality for vision models). Apart from one download for gguf, nothing
for LLMs, input modality for vision models). Apart from one download for llama_cpp, nothing
touches the network:

- openai and anthropic get canned responses through the SDK's own HTTP
client (`MockTransport`).
- onnx loads a tiny model committed in `tests/compat/fixtures`. gguf
- onnx loads a tiny model committed in `tests/compat/fixtures`. llama_cpp
downloads a 1.2 MB model on first use, checked against a pinned sha256.
- torch, timm, tensorflow, transformers, ultralytics and mlx build models from
a config, with random weights.
Expand Down Expand Up @@ -57,8 +57,8 @@ To run the full matrix locally: `python scripts/run_compat_local.py`.
| `tensorflow` | `min` | `tensorflow==2.16.1`, `keras==3.3.3`, `numpy==1.26.4` | 3.10, 3.11, 3.12 |
| `tensorflow` | `current` | `tensorflow==2.21.0`, `keras==3.15.1`, `numpy==2.2.6` | 3.10, 3.11, 3.12 |
| `tensorflow` | `current` (`py3.10` override) | `tensorflow==2.21.0`, `keras==3.12.4`, `numpy==2.2.6` | 3.10 |
| `gguf` | `min` | `llama-cpp-python==0.2.90`, `numpy==1.26.4` | 3.10, 3.11, 3.12, 3.13 |
| `gguf` | `current` | `llama-cpp-python==0.3.36`, `numpy==2.2.6` | 3.10, 3.11, 3.12, 3.13 |
| `llama_cpp` | `min` | `llama-cpp-python==0.2.90`, `numpy==1.26.4` | 3.10, 3.11, 3.12, 3.13 |
| `llama_cpp` | `current` | `llama-cpp-python==0.3.36`, `numpy==2.2.6` | 3.10, 3.11, 3.12, 3.13 |
| `openai` | `min` | `openai==1.30.0` | 3.10, 3.11, 3.12, 3.13 |
| `openai` | `current` | `openai==3.35.1` | 3.10, 3.11, 3.12, 3.13 |
| `transformers` | `min` | `transformers==4.40.0`, `torch==2.4.1`, `numpy==1.26.4` | 3.10, 3.11, 3.12, 3.13 |
Expand Down
16 changes: 16 additions & 0 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ Under `wildedge run`, a missing DSN warns on stderr and your program runs
untracked. Telemetry failing must not take production down; that is the
default policy.

## CLI options

| Flag | Description |
|---|---|
| `--integrations` | Comma-separated runtime integrations, such as `llama_cpp`, `onnx`, or `openai`; default: `all` |
| `--hubs` | Download tracking via `huggingface` or `torchhub` |
| `--print-startup-report` | Print activation status for each integration |
| `--strict-integrations` | Exit with 121 if a requested integration cannot be instrumented |
| `--strict` | Exit on bootstrap failure; see the exit codes below |
| `--attachments` | Enable upload of explicitly supplied attachments |
| `--no-propagate` | Scrub run-scoped environment variables after initialization |

Use `llama_cpp` for the `llama-cpp-python` runtime. The older name `gguf` is
accepted as a compatibility alias in Python, CLI, and environment settings.
The recorded model format remains `gguf`.

## Strict mode

`wildedge run --strict` inverts the failure policy for deployments where
Expand Down
6 changes: 3 additions & 3 deletions examples/django_gemma/demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cd "${SCRIPT_DIR}"

uv sync

uv run wildedge doctor --integrations gguf --hubs huggingface
uv run wildedge doctor --integrations llama_cpp --hubs huggingface

# wildedge run replaces this process (os.execle) so sitecustomize.py
# auto-installs the runtime before Django loads, patching Llama.__init__
Expand All @@ -26,13 +26,13 @@ uv run wildedge doctor --integrations gguf --hubs huggingface
if [[ "$(uname)" == "Darwin" ]]; then
uv run wildedge run \
--print-startup-report \
--integrations gguf \
--integrations llama_cpp \
--hubs huggingface \
-- waitress-serve --port=8100 gemmaapp.wsgi:application
else
uv run wildedge run \
--print-startup-report \
--integrations gguf \
--integrations llama_cpp \
--hubs huggingface \
-- gunicorn gemmaapp.wsgi:application --config gunicorn.conf.py
fi
Expand Down
2 changes: 1 addition & 1 deletion examples/django_gemma/gemmaapp/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Gemma inference view.

The Llama constructor is patched automatically by `wildedge run --integrations gguf`
The Llama constructor is patched automatically by `wildedge run --integrations llama_cpp`
via sitecustomize.py; load/unload/inference events are tracked without any
wildedge imports here.

Expand Down
4 changes: 2 additions & 2 deletions examples/gguf_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# ///
"""GGUF / llama.cpp integration example. Run with: uv run gguf_example.py

The gguf integration tracks every llama-cpp-python entry point, once per
The llama_cpp integration tracks every llama-cpp-python entry point, once per
call: create_chat_completion (streamed or not), create_completion and
llm(...). Each inference event carries token counts, tokens per second,
the stop reason and the sampling settings; chat calls also record
Expand All @@ -21,7 +21,7 @@

wildedge.init(
app_version="1.0.0", # uses WILDEDGE_DSN if set; otherwise no-op
integrations="gguf",
integrations="llama_cpp",
hubs=["huggingface"],
)

Expand Down
4 changes: 2 additions & 2 deletions scripts/compat_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"min": ["tensorflow==2.16.1", "keras==3.3.3", "numpy==1.26.4"],
"current": ["tensorflow==2.21.0", "keras==3.15.1", "numpy==2.2.6"],
},
"gguf": {
"llama_cpp": {
"min": ["llama-cpp-python==0.2.90", "numpy==1.26.4"],
"current": ["llama-cpp-python==0.3.36", "numpy==2.2.6"],
},
Expand Down Expand Up @@ -70,7 +70,7 @@
"torch": ["3.10", "3.11", "3.12", "3.13", "3.14"],
"timm": ["3.10", "3.11", "3.12", "3.13", "3.14"],
"tensorflow": ["3.10", "3.11", "3.12"],
"gguf": ["3.10", "3.11", "3.12", "3.13"],
"llama_cpp": ["3.10", "3.11", "3.12", "3.13"],
"openai": ["3.10", "3.11", "3.12", "3.13"],
"transformers": ["3.10", "3.11", "3.12", "3.13"],
"ultralytics": ["3.10", "3.11", "3.12", "3.13"],
Expand Down
4 changes: 2 additions & 2 deletions tests/compat/fixtures/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
Larger models are downloaded on first use and checked against a sha256 (see
`downloaded_fixture` in `../conftest.py`). They are cached in
`tests/compat/.cache`, or in `$WILDEDGE_COMPAT_CACHE` when set, which CI
keeps between runs. The gguf test declares its model's URL and checksum at
the top of `test_gguf_compat.py`.
keeps between runs. The llama_cpp test declares its model's URL and checksum at
the top of `test_llama_cpp_compat.py`.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@pytest.fixture
def llm(compat_client):
model = downloaded_fixture("stories260K-f32.gguf", MODEL_URL, MODEL_SHA256)
compat_client.instrument("gguf")
compat_client.instrument("llama_cpp")
return llama_cpp.Llama(model_path=str(model), n_ctx=128, seed=1, verbose=False)


Expand Down
10 changes: 10 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from wildedge.integrations.registry import IntegrationSpec
from wildedge.platforms.device_info import DeviceInfo
from wildedge.runtime import bootstrap
from wildedge.settings import parse_integration_list
from wildedge.transmitter import IngestResponse, TransmitError


Expand Down Expand Up @@ -578,3 +579,12 @@ def test_doctor_json_includes_environment_and_statuses(monkeypatch, capsys):
assert data["environment"]["autoload_on_pythonpath"] is False
assert data["config_status"] == "PASS"
assert data["connectivity_status"] == "SKIP"


@pytest.mark.parametrize("names", ["gguf", "llama_cpp", "gguf,llama_cpp"])
def test_llama_cpp_names_resolve_once_in_cli_and_environment(names):
assert cli.integration_list(names) == ["llama_cpp"]
assert parse_integration_list(names, []) == ["llama_cpp"]
assert cli.INTEGRATIONS_BY_NAME["gguf"] is cli.INTEGRATIONS_BY_NAME["llama_cpp"]
assert "llama_cpp" in cli.integration_list("all")
assert "gguf" not in cli.integration_list("all")
23 changes: 22 additions & 1 deletion tests/test_integration_patching.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def test_instrument_hubs_activates_requested_trackers(stub_client):
activated = []
with (
patch.object(stub_client, "_activate_hub", side_effect=activated.append),
patch.dict(stub_client.PATCH_INSTALLERS, {"gguf": lambda ref: None}),
patch.dict(stub_client.PATCH_INSTALLERS, {"llama_cpp": lambda ref: None}),
):
stub_client.instrument("gguf", hubs=["huggingface"])

Expand All @@ -244,3 +244,24 @@ def test_instrument_none_activates_hub(stub_client):
with patch.object(stub_client, "_activate_hub", side_effect=activated.append):
stub_client.instrument(None, hubs=["huggingface"])
assert activated == ["huggingface"]


@pytest.mark.parametrize("names", [("gguf", "llama_cpp"), ("llama_cpp", "gguf")])
def test_llama_cpp_aliases_share_patch_and_client_route(
stub_client, monkeypatch, names
):
class FakeLlama:
def __init__(self, *args, **kwargs):
pass

runtime = types.SimpleNamespace(Llama=FakeLlama)
monkeypatch.setattr(gguf_mod, "_llama_cpp", runtime)
monkeypatch.setattr(gguf_mod, "_llama_patched", False)
stub_client.instrument(names[0])
first = runtime.Llama.__init__
stub_client.instrument(names[1])
assert runtime.Llama.__init__ is first
with patch.object(stub_client, "_on_model_auto_loaded") as loaded:
model = runtime.Llama("model.gguf")
loaded.assert_called_once()
assert loaded.call_args.args[0] is model
16 changes: 13 additions & 3 deletions wildedge/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
from wildedge.client import parse_dsn
from wildedge.events.span import SpanEvent
from wildedge.hubs.registry import HUBS_BY_NAME, supported_hubs
from wildedge.integrations.registry import INTEGRATIONS_BY_NAME, supported_integrations
from wildedge.integrations.registry import (
INTEGRATIONS_BY_NAME,
canonical_integration,
supported_integrations,
)
from wildedge.paths import default_dead_letter_dir, default_pending_queue_dir
from wildedge.platforms import detect_device, get_device_id_path
from wildedge.settings import read_client_env, resolve_app_identity
Expand All @@ -44,7 +48,7 @@ def build_parser() -> argparse.ArgumentParser:
run.add_argument(
"--integrations",
default="all",
help="Comma-separated framework integrations to enable (gguf, onnx, timm, …). Default: all.",
help="Comma-separated framework integrations to enable (llama_cpp, onnx, timm, …). Default: all.",
)
run.add_argument(
"--hubs",
Expand Down Expand Up @@ -291,7 +295,13 @@ def run_command(parsed: argparse.Namespace) -> int:
def integration_list(value: str | None) -> list[str]:
if not value or value == "all":
return sorted(supported_integrations())
return [item.strip() for item in value.split(",") if item.strip()]
return list(
dict.fromkeys(
canonical_integration(item.strip())
for item in value.split(",")
if item.strip()
)
)


def hub_list(value: str | None) -> list[str]:
Expand Down
6 changes: 4 additions & 2 deletions wildedge/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from wildedge.integrations.base import BaseExtractor
from wildedge.integrations.registry import (
INTEGRATION_SPECS,
canonical_integration,
find_extractor,
noop_integrations,
supported_integrations,
Expand Down Expand Up @@ -739,7 +740,7 @@ def instrument(
Pass ``hubs=`` alongside a framework name to activate download provenance
tracking for the hub(s) your code downloads from::

client.instrument("gguf", hubs=["huggingface"])
client.instrument("llama_cpp", hubs=["huggingface"])
client.instrument("onnx", hubs=["huggingface"])
client.instrument("timm", hubs=["huggingface", "torchhub"])

Expand All @@ -753,7 +754,7 @@ def instrument(

Supported framework integrations
---------------------------------
``"gguf"``
``"llama_cpp"`` (``"gguf"`` remains a compatibility alias)
Patches ``llama_cpp.Llama.__init__``. Requires ``llama-cpp-python``.
``"onnx"``
Replaces ``ort.InferenceSession`` with a timed subclass.
Expand Down Expand Up @@ -816,6 +817,7 @@ def instrument(
self._activate_hub(hub_name)
return

integration = canonical_integration(integration)
if integration in self.SUPPORTED_HUBS:
raise ValueError(
f"{integration!r} is a hub, not a framework integration. "
Expand Down
2 changes: 1 addition & 1 deletion wildedge/integrations/gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
LLAMA_AUTO_LOAD_PATCH_NAME = "gguf_auto_load"


debug_gguf_failure = functools.partial(debug_failure, "gguf")
debug_gguf_failure = functools.partial(debug_failure, "llama_cpp")


def n_gpu_layers(obj: object) -> int:
Expand Down
Loading
Loading