|
8 | 8 | from eval_protocol.pytest.openenv_rollout_processor import OpenEnvRolloutProcessor |
9 | 9 | import pytest |
10 | 10 |
|
| 11 | +try: |
| 12 | + # Preferred import when using the monolithic `openenv` package |
| 13 | + from openenv.envs.echo_env import EchoEnv # type: ignore |
| 14 | + |
| 15 | + _HAS_ECHO = True |
| 16 | +except Exception: |
| 17 | + _HAS_ECHO = False |
| 18 | + |
11 | 19 | # Skip these integration-heavy tests on CI runners by default |
12 | 20 | pytestmark = pytest.mark.skipif(os.getenv("CI") == "true", reason="Skip OpenEnv integration tests on CI") |
13 | 21 |
|
@@ -35,20 +43,20 @@ def action_parser(response_text: str): |
35 | 43 | Convert raw model response to EchoAction. |
36 | 44 | """ |
37 | 45 | try: |
38 | | - from envs.echo_env import EchoAction # type: ignore |
| 46 | + from openenv.envs.echo_env import EchoAction # type: ignore |
39 | 47 | except Exception: |
40 | | - pytest.skip("OpenEnv (envs.echo_env) is not installed; skipping Echo hub test.") |
| 48 | + pytest.skip("OpenEnv (openenv.envs.echo_env) is not installed; skipping Echo hub test.") |
41 | 49 | raise |
42 | 50 | text = response_text.strip() if isinstance(response_text, str) else "" |
43 | 51 | return EchoAction(message=text or "hello") |
44 | 52 |
|
45 | 53 |
|
46 | | -try: |
47 | | - from envs.echo_env import EchoEnv # type: ignore |
| 54 | +# try: |
| 55 | +# from envs.echo_env import EchoEnv # type: ignore |
48 | 56 |
|
49 | | - _HAS_ECHO = True |
50 | | -except Exception: |
51 | | - _HAS_ECHO = False |
| 57 | +# _HAS_ECHO = True |
| 58 | +# except Exception: |
| 59 | +# _HAS_ECHO = False |
52 | 60 |
|
53 | 61 |
|
54 | 62 | # Inline test data |
@@ -93,23 +101,15 @@ def test_openenv_echo_hub(row: EvaluationRow) -> EvaluationRow: |
93 | 101 | Extracts env rewards (from rollout policy extras) and sets evaluation_result. |
94 | 102 | """ |
95 | 103 | if not _HAS_ECHO: |
96 | | - pytest.skip("OpenEnv (envs.echo_env) is not installed; skipping Echo hub test.") |
97 | | - # Try to read rewards/usage left in execution metadata extra or system messages. |
| 104 | + pytest.skip("OpenEnv (openenv.envs.echo_env) is not installed; skipping Echo hub test.") |
| 105 | + # Try to read rewards/usage left in execution metadata extra. |
98 | 106 | total_reward = 0.0 |
99 | 107 | try: |
100 | | - # Preferred path: system sentinel "__ep_step_rewards__" |
| 108 | + extra = getattr(row.execution_metadata, "extra", None) |
101 | 109 | step_rewards: List[float] = [] |
102 | | - for msg in row.messages or []: |
103 | | - if ( |
104 | | - msg.role == "system" |
105 | | - and isinstance(msg.content, str) |
106 | | - and msg.content.startswith("__ep_step_rewards__:") |
107 | | - ): |
108 | | - import json as _json |
109 | | - |
110 | | - payload = msg.content.split(":", 1)[1] |
111 | | - step_rewards = _json.loads(payload) or [] |
112 | | - break |
| 110 | + if isinstance(extra, dict): |
| 111 | + raw = extra.get("step_rewards") or [] |
| 112 | + step_rewards = [float(r) for r in raw] |
113 | 113 | total_reward = float(sum(step_rewards)) if step_rewards else 0.0 |
114 | 114 | except Exception: |
115 | 115 | total_reward = 0.0 |
|
0 commit comments