Skip to content

Commit 087c7d3

Browse files
authored
Reimplement Weave tracer and unify emitter interface (#411)
1 parent 2203070 commit 087c7d3

48 files changed

Lines changed: 3180 additions & 1120 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests-full.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ jobs:
4545
pytest-mark: 'agentops' # including agentops+litellm tests here
4646
runs-on: [self-hosted, 1ES.Pool=agl-runner-gpu]
4747
has-gpu: true
48+
# Similar for Weave.
49+
- id: weave
50+
display-name: Weave
51+
pytest-mark: 'weave'
52+
runs-on: ubuntu-latest # No GPU tests for Weave.
53+
has-gpu: false
4854
# Other tests that require GPU
4955
- id: gpu
5056
display-name: GPU required
@@ -54,7 +60,7 @@ jobs:
5460
# Other uncovered tests
5561
- id: others
5662
display-name: Others
57-
pytest-mark: 'not store and not agentops and not gpu and not llmproxy'
63+
pytest-mark: 'not store and not agentops and not weave and not gpu and not llmproxy'
5864
runs-on: ubuntu-latest
5965
has-gpu: false
6066
env:
@@ -83,24 +89,24 @@ jobs:
8389

8490
- name: Sync dependencies (latest, gpu)
8591
if: matrix.env.setup-script == 'latest' && matrix.mark.has-gpu
86-
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group langchain --group torch-gpu-stable
92+
run: uv sync --frozen --no-default-groups --extra apo --extra weave --extra mongo --group dev --group agents --group langchain --group torch-gpu-stable
8793
# Don't install vllm/pytorch on CPU counterparts
8894
- name: Sync dependencies (latest, cpu)
8995
if: matrix.env.setup-script == 'latest' && !matrix.mark.has-gpu
90-
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group langchain --group core-stable
96+
run: uv sync --frozen --no-default-groups --extra apo --extra weave --extra mongo --group dev --group agents --group langchain --group core-stable
9197
- name: Sync dependencies (stable, gpu)
9298
if: matrix.env.setup-script == 'stable' && matrix.mark.has-gpu
93-
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group langchain --group torch-gpu-${{ matrix.env.setup-script }}
99+
run: uv sync --frozen --no-default-groups --extra apo --extra weave --extra mongo --group dev --group agents --group langchain --group torch-gpu-${{ matrix.env.setup-script }}
94100
- name: Sync dependencies (stable, cpu)
95101
if: matrix.env.setup-script == 'stable' && !matrix.mark.has-gpu
96-
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group langchain --group core-stable
102+
run: uv sync --frozen --no-default-groups --extra apo --extra weave --extra mongo --group dev --group agents --group langchain --group core-stable
97103
# Don't install langchain for legacy dependency because it has conflicts with torch.
98104
- name: Sync dependencies (legacy, gpu)
99105
if: matrix.env.setup-script == 'legacy' && matrix.mark.has-gpu
100-
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group torch-gpu-legacy
106+
run: uv sync --frozen --no-default-groups --extra apo --extra weave --extra mongo --group dev --group agents --group torch-gpu-legacy
101107
- name: Sync dependencies (legacy, cpu)
102108
if: matrix.env.setup-script == 'legacy' && !matrix.mark.has-gpu
103-
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group core-legacy
109+
run: uv sync --frozen --no-default-groups --extra apo --extra weave --extra mongo --group dev --group agents --group core-legacy
104110

105111
- name: Freeze dependencies
106112
run: |
@@ -270,6 +276,14 @@ jobs:
270276
python write_traces.py agentops
271277
sleep 5
272278
279+
- name: Write Traces with Operations
280+
run: |
281+
set -euo pipefail
282+
source .venv/bin/activate
283+
cd examples/minimal
284+
python write_traces.py operation
285+
sleep 5
286+
273287
- name: Write Traces via Otel Tracer with Client
274288
run: |
275289
set -euo pipefail

.github/workflows/tests.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
run: |
4141
uv sync --frozen \
4242
--extra apo \
43+
--extra weave \
4344
--extra verl \
4445
--extra mongo \
4546
--group dev \
@@ -110,6 +111,10 @@ jobs:
110111
- name: Set source commit for docs
111112
run: |
112113
echo "SOURCE_COMMIT=${{ github.sha }}" >> $GITHUB_ENV
114+
- name: Verify OpenAPI specification is up-to-date
115+
run: |
116+
uv run --locked --no-sync python scripts/export_openapi.py
117+
git diff --exit-code docs/assets/store-openapi.json
113118
- name: Build documentation
114119
run: uv run --locked --no-sync mkdocs build --strict
115120
- name: Upload docs artifact
@@ -131,6 +136,10 @@ jobs:
131136
- id: agentops
132137
display-name: AgentOps
133138
pytest-mark: 'agentops'
139+
# Similar for Weave.
140+
- id: weave
141+
display-name: Weave
142+
pytest-mark: 'weave'
134143
# litellm proxy tests are slow
135144
- id: llmproxy
136145
display-name: LLM proxy
@@ -142,7 +151,7 @@ jobs:
142151
# unmarked tests: adapter, execution engine, etc.
143152
- id: others
144153
display-name: Others
145-
pytest-mark: 'not store and not agentops and not llmproxy and not utils'
154+
pytest-mark: 'not store and not agentops and not weave and not llmproxy and not utils'
146155
env:
147156
- python-version: '3.10'
148157
setup-script: 'legacy'
@@ -167,10 +176,10 @@ jobs:
167176
run: uv lock --upgrade
168177
if: matrix.env.setup-script == 'latest'
169178
- name: Sync dependencies (latest)
170-
run: uv sync --frozen --no-default-groups --extra apo --group dev --group agents --group langchain --group core-stable
179+
run: uv sync --frozen --no-default-groups --extra apo --extra weave --group dev --group agents --group langchain --group core-stable
171180
if: matrix.env.setup-script == 'latest'
172181
- name: Sync dependencies (stable & legacy)
173-
run: uv sync --frozen --no-default-groups --extra apo --group dev --group agents --group langchain --group core-${{ matrix.env.setup-script }}
182+
run: uv sync --frozen --no-default-groups --extra apo --extra weave --group dev --group agents --group langchain --group core-${{ matrix.env.setup-script }}
174183
if: matrix.env.setup-script != 'latest'
175184
- name: Freeze dependencies
176185
run: |

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Agentlightning specific files
22
verl_old
33
meta-llama/**
4-
debug/*.png
4+
**/debug/*.png
55
requirements-freeze*.txt
66
/playground
77

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ repos:
33
rev: v6.0.0
44
hooks:
55
- id: end-of-file-fixer
6+
exclude: (.*store-openapi\.json$)
67
- id: trailing-whitespace
78
- id: check-yaml
89
exclude: ^mkdocs\.yml$
910
- id: check-toml
1011
- id: check-added-large-files
1112
args: ["--maxkb=1024"]
12-
exclude: (^uv\.lock$)|(^docs/assets/.*\.svg$)
13+
exclude: (^uv\.lock$)|(^docs/assets/.*\.svg$)|(.*store-openapi\.json$)
1314
- id: check-shebang-scripts-are-executable
1415
- id: detect-private-key
1516
- repo: https://github.com/pycqa/isort

agentlightning/emitter/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Copyright (c) Microsoft. All rights reserved.
22

3+
"""Convenient helpers for creating spans / traces.
4+
5+
All emitters operate in two modes, switchable via the `propagate` parameter.
6+
The emitters first [`SpanCreationRequest`][agentlightning.SpanCreationRequest] object, then:
7+
8+
1. When `propagate` is True, this creation request will be propagated to the active tracer
9+
and a [`Span`][agentlightning.Span] instance will be created (possibly deferred).
10+
2. When `propagate` is False, the creation request will be returned directly. Useful for cases
11+
when you don't have a tracer but you want to create a creation request for later use.
12+
"""
13+
314
from .annotation import emit_annotation, operation
415
from .exception import emit_exception
516
from .message import emit_message, get_message_value

0 commit comments

Comments
 (0)