Skip to content

Commit 68a32dd

Browse files
Keep deprecated lp/r3 deserializer shims for backward compatibility.
Re-export the moved tracing decoders from their old adapter paths with a DeprecationWarning so existing imports keep working after the tracing refactor. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 38fe102 commit 68a32dd

3 files changed

Lines changed: 120 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Deprecated compatibility shim for ``eval_protocol.tracing.logprobs``.
2+
3+
Import from ``eval_protocol.tracing.logprobs`` (or ``decode_payloads`` from
4+
``eval_protocol.tracing``) instead. This module re-exports the LP/v1 helpers
5+
that lived here before the tracing package refactor.
6+
"""
7+
8+
from __future__ import annotations
9+
10+
import warnings
11+
12+
warnings.warn(
13+
"eval_protocol.adapters.lp_deserializer is deprecated; "
14+
"import from eval_protocol.tracing.logprobs instead.",
15+
DeprecationWarning,
16+
stacklevel=2,
17+
)
18+
19+
from eval_protocol.tracing.logprobs import ( # noqa: E402
20+
ENTRY_FORMAT,
21+
ENTRY_SIZE,
22+
HEADER_FORMAT,
23+
HEADER_SIZE,
24+
HEADER_VERSION,
25+
MAGIC,
26+
MISSING_TOKEN_ID,
27+
decompress_and_parse_lp,
28+
parse_logprobs,
29+
)
30+
31+
__all__ = [
32+
"ENTRY_FORMAT",
33+
"ENTRY_SIZE",
34+
"HEADER_FORMAT",
35+
"HEADER_SIZE",
36+
"HEADER_VERSION",
37+
"MAGIC",
38+
"MISSING_TOKEN_ID",
39+
"decompress_and_parse_lp",
40+
"parse_logprobs",
41+
]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Deprecated compatibility shim for ``eval_protocol.tracing.router_replay``.
2+
3+
Import from ``eval_protocol.tracing.router_replay`` (or ``decode_payloads`` from
4+
``eval_protocol.tracing``) instead. This module re-exports the R3/v1 helpers
5+
that lived here before the tracing package refactor.
6+
"""
7+
8+
from __future__ import annotations
9+
10+
import warnings
11+
12+
warnings.warn(
13+
"eval_protocol.adapters.r3_deserializer is deprecated; "
14+
"import from eval_protocol.tracing.router_replay instead.",
15+
DeprecationWarning,
16+
stacklevel=2,
17+
)
18+
19+
from eval_protocol.tracing.router_replay import ( # noqa: E402
20+
BITS_PER_BYTE,
21+
HEADER_FORMAT,
22+
HEADER_SIZE,
23+
MAGIC,
24+
_RoutingDtype,
25+
_SelectorMode,
26+
_parse_header,
27+
_read_bitmap_positions,
28+
decompress_and_parse_r3,
29+
)
30+
31+
__all__ = [
32+
"BITS_PER_BYTE",
33+
"HEADER_FORMAT",
34+
"HEADER_SIZE",
35+
"MAGIC",
36+
"_RoutingDtype",
37+
"_SelectorMode",
38+
"_parse_header",
39+
"_read_bitmap_positions",
40+
"decompress_and_parse_r3",
41+
]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Backward-compat shims for moved adapter deserializers."""
2+
3+
from __future__ import annotations
4+
5+
import warnings
6+
7+
import pytest
8+
9+
from tests.adapters.test_lp_deserializer import GOLDEN_RAW_HEX
10+
11+
12+
def test_lp_deserializer_shim_reexports_and_warns():
13+
with warnings.catch_warnings(record=True) as caught:
14+
warnings.simplefilter("always", DeprecationWarning)
15+
from eval_protocol.adapters import lp_deserializer as shim
16+
17+
assert any(
18+
"eval_protocol.adapters.lp_deserializer is deprecated" in str(w.message)
19+
for w in caught
20+
)
21+
raw = bytes.fromhex(GOLDEN_RAW_HEX)
22+
logprobs, token_ids, metadata = shim.parse_logprobs(raw)
23+
assert logprobs == [-0.25, -0.5]
24+
assert token_ids == [7, 8]
25+
assert metadata["completion_token_count"] == 2
26+
27+
28+
def test_r3_deserializer_shim_reexports_and_warns():
29+
with warnings.catch_warnings(record=True) as caught:
30+
warnings.simplefilter("always", DeprecationWarning)
31+
from eval_protocol.adapters import r3_deserializer as shim
32+
33+
assert any(
34+
"eval_protocol.adapters.r3_deserializer is deprecated" in str(w.message)
35+
for w in caught
36+
)
37+
assert shim.MAGIC == b"R3V1"
38+
assert shim._SelectorMode.ALL == 0

0 commit comments

Comments
 (0)