Skip to content

Commit cee22f6

Browse files
committed
Support for inference attachments - cleanup
1 parent 6c8d4dc commit cee22f6

4 files changed

Lines changed: 62 additions & 2 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Useful flags:
4444
| `--hubs` | Hub trackers to activate: `huggingface`, `torchhub` |
4545
| `--print-startup-report` | Print per-integration status at startup |
4646
| `--strict-integrations` | Fail if a requested integration can't be loaded |
47+
| `--attachments` | Enable opt-in raw input/output attachment upload |
4748
| `--no-propagate` | Don't pass WildEdge env vars to child processes |
4849

4950
## SDK
@@ -106,8 +107,9 @@ For unsupported frameworks, see [Manual tracking](https://github.com/wild-edge/w
106107
| `app_identity` | `<project_key>` | Namespace for offline persistence. Set per-app in multi-process workloads (or `WILDEDGE_APP_IDENTITY`) |
107108
| `enable_offline_persistence` | `true` | Persist unsent events to disk and replay on restart |
108109
| `sampling_interval_s` | `30.0` | Seconds between background hardware snapshots. Set to `0` or `None` to disable (or `WILDEDGE_SAMPLING_INTERVAL_S`) |
110+
| `attachments_enabled` | `false` | Opt-in upload of raw inference inputs/outputs (or `WILDEDGE_ATTACHMENTS_ENABLED`). See [Attachments](https://github.com/wild-edge/wildedge-python/blob/main/docs/configuration.md#attachments) |
109111

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

112114
## Projects using this SDK
113115

@@ -121,6 +123,10 @@ Using WildEdge in your project? Open a PR to add it to the list.
121123

122124
## Security & Privacy
123125

126+
By default the SDK transmits only anonymized telemetry, never raw model inputs
127+
or outputs. The one exception is opt-in [attachments](https://github.com/wild-edge/wildedge-python/blob/main/docs/configuration.md#attachments)
128+
(`attachments_enabled`), which upload raw bytes you explicitly pass in.
129+
124130
Report security and privacy issues to: support@wildedge.dev
125131

126132
## Links

docs/configuration.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,21 @@ Full reference for all `WildEdge` client parameters.
2222
| `max_event_age_sec` | `900` | - | Max age in seconds before an event is dropped |
2323
| `enable_dead_letter_persistence` | `false` | - | Persist dropped batches to disk for later inspection |
2424
| `debug` | `false` | `WILDEDGE_DEBUG` | Log SDK internals to console |
25+
26+
## Attachments
27+
28+
Opt-in upload of raw inference inputs/outputs (e.g. the source image or the
29+
generated text) alongside telemetry. Off by default; requires the attachment
30+
feature enabled on your project. Bytes are buffered locally and uploaded in the
31+
background via presigned URLs, so the event flush never waits on the upload.
32+
33+
| Parameter | Default | Env var | Description |
34+
|---|---|---|---|
35+
| `attachments_enabled` | `false` | `WILDEDGE_ATTACHMENTS_ENABLED` | Enable raw input/output upload |
36+
| `max_attachments_per_inference` | `10` | - | Cap on attachments buffered per inference event |
37+
| `max_attachment_size_bytes` | `10485760` | - | Per-attachment size limit (10 MB); larger ones are dropped |
38+
| `attachment_storage_strategy` | `"file"` | - | `"file"` (bytes on disk) or `"inline"` (small blobs embedded in the record) |
39+
| `attachment_filter` | `None` | - | `Callable[[list[Attachment]], list[Attachment]]` to redact/drop before buffering |
40+
| `attachment_dir` | per `app_identity` | - | Override the local buffer directory |
41+
42+
See [Track attachments](manual-tracking.md#track-attachments) for usage.

docs/manual-tracking.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,42 @@ handle.feedback(FeedbackType.THUMBS_DOWN)
216216

217217
`FeedbackType` values: `THUMBS_UP`, `THUMBS_DOWN`.
218218

219+
## Track attachments
220+
221+
Opt-in upload of the raw bytes behind an inference, such as the source image,
222+
audio clip, or generated text, so you can inspect or curate them later. This is
223+
off by default and requires the attachment feature enabled on your project.
224+
Enable it at init, then pass `attachments=` to `track_inference`:
225+
226+
```python
227+
import wildedge
228+
from wildedge import Attachment
229+
230+
client = wildedge.init(attachments_enabled=True)
231+
handle = client.register_model(model, model_id="doc-classifier-v1")
232+
233+
handle.track_inference(
234+
duration_ms=120,
235+
input_modality="image",
236+
output_modality="text",
237+
attachments=[
238+
Attachment(content_type="image/jpeg", role="input", data=image_bytes),
239+
Attachment(content_type="text/plain", role="output", data=answer.encode()),
240+
],
241+
)
242+
```
243+
244+
An `Attachment` carries either in-memory `data` or a file `path`, plus a
245+
`role` (`"input"` or `"output"`) and `content_type`. The SDK writes a reference
246+
into the inference event immediately and uploads the bytes in the background via
247+
a presigned URL. A failed or disabled upload never blocks telemetry.
248+
249+
Bytes are buffered to disk and survive restarts. Capture is gated by
250+
`max_attachments_per_inference`, `max_attachment_size_bytes`, and an optional
251+
`attachment_filter` hook. See [Configuration](configuration.md#attachments) and
252+
[`examples/attachments_example.py`](../examples/attachments_example.py) for the
253+
full reference.
254+
219255
## Track spans for agentic workflows
220256

221257
Use span events to track non-inference steps like planning, tool calls, retrieval, or memory updates.

examples/attachments_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Opt-in raw input/output capture. When `attachments_enabled=True` (and the
1212
project has the paid feature turned on), the SDK buffers the raw bytes locally,
1313
writes a reference into the inference event, and uploads the bytes independently
14-
via a presigned URL the batch flush never waits on the upload.
14+
via a presigned URL, so the batch flush never waits on the upload.
1515
1616
Attachments are off by default and must be explicitly enabled. Set WILDEDGE_DSN
1717
to see real uploads; otherwise the client runs in no-op mode.

0 commit comments

Comments
 (0)