langfun 0.1.2.dev202509250804__py3-none-any.whl → 0.1.2.dev202509270803__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of langfun might be problematic. Click here for more details.
- langfun/core/llms/__init__.py +2 -0
- langfun/core/llms/openai.py +57 -0
- langfun/env/__init__.py +4 -5
- langfun/env/base_environment.py +41 -34
- langfun/env/base_feature.py +10 -1
- langfun/env/base_sandbox.py +27 -26
- langfun/env/base_test.py +106 -33
- langfun/env/event_handlers/__init__.py +12 -0
- langfun/env/event_handlers/base.py +271 -0
- langfun/env/event_handlers/event_logger.py +415 -0
- langfun/env/event_handlers/event_logger_test.py +289 -0
- langfun/env/interface.py +103 -380
- langfun/env/interface_test.py +3 -3
- langfun/env/load_balancers_test.py +3 -15
- langfun/env/test_utils.py +12 -26
- {langfun-0.1.2.dev202509250804.dist-info → langfun-0.1.2.dev202509270803.dist-info}/METADATA +1 -1
- {langfun-0.1.2.dev202509250804.dist-info → langfun-0.1.2.dev202509270803.dist-info}/RECORD +20 -16
- {langfun-0.1.2.dev202509250804.dist-info → langfun-0.1.2.dev202509270803.dist-info}/WHEEL +0 -0
- {langfun-0.1.2.dev202509250804.dist-info → langfun-0.1.2.dev202509270803.dist-info}/licenses/LICENSE +0 -0
- {langfun-0.1.2.dev202509250804.dist-info → langfun-0.1.2.dev202509270803.dist-info}/top_level.txt +0 -0
langfun/env/test_utils.py
CHANGED
|
@@ -21,50 +21,47 @@ from langfun.env import base_environment
|
|
|
21
21
|
from langfun.env import base_feature
|
|
22
22
|
from langfun.env import base_sandbox
|
|
23
23
|
from langfun.env import interface
|
|
24
|
+
from langfun.env.event_handlers import base as event_handler_base
|
|
24
25
|
import pyglove as pg
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
class TestingEnvironment(base_environment.BaseEnvironment):
|
|
28
29
|
"""Testing environment for unit tests."""
|
|
29
30
|
|
|
31
|
+
housekeep_interval: float = 0.0
|
|
30
32
|
simulate_start_error: Type[BaseException] | None = None
|
|
31
33
|
simulate_shutdown_error: Type[BaseException] | None = None
|
|
32
34
|
simulate_ping_error: Type[BaseException] | None = None
|
|
33
|
-
keepalive_interval: float | None = 60.0
|
|
34
35
|
offline: bool = False
|
|
35
36
|
|
|
36
37
|
@property
|
|
37
|
-
def id(self) -> interface.
|
|
38
|
-
return interface.
|
|
38
|
+
def id(self) -> interface.Environment.Id:
|
|
39
|
+
return interface.Environment.Id('testing-env')
|
|
39
40
|
|
|
40
41
|
def wait_for_housekeeping(self):
|
|
41
42
|
housekeep_counter = self.housekeep_counter
|
|
42
43
|
while self.housekeep_counter == housekeep_counter:
|
|
43
|
-
time.sleep(0.
|
|
44
|
+
time.sleep(0.01)
|
|
44
45
|
|
|
45
46
|
def _create_sandbox(
|
|
46
47
|
self,
|
|
47
48
|
sandbox_id: str,
|
|
48
49
|
reusable: bool,
|
|
49
50
|
proactive_session_setup: bool,
|
|
51
|
+
keepalive_interval: float | None,
|
|
50
52
|
) -> base_sandbox.BaseSandbox:
|
|
51
|
-
if self.offline:
|
|
52
|
-
raise interface.EnvironmentError(
|
|
53
|
-
'Unknown environment error.',
|
|
54
|
-
environment=self,
|
|
55
|
-
)
|
|
56
53
|
return TestingSandbox(
|
|
57
54
|
environment=self,
|
|
58
|
-
id=interface.
|
|
55
|
+
id=interface.Sandbox.Id(
|
|
59
56
|
environment_id=self.id,
|
|
60
57
|
sandbox_id=sandbox_id
|
|
61
58
|
),
|
|
62
59
|
reusable=reusable,
|
|
63
60
|
proactive_session_setup=proactive_session_setup,
|
|
61
|
+
keepalive_interval=keepalive_interval,
|
|
64
62
|
simulate_start_error=self.simulate_start_error,
|
|
65
63
|
simulate_shutdown_error=self.simulate_shutdown_error,
|
|
66
64
|
simulate_ping_error=self.simulate_ping_error,
|
|
67
|
-
keepalive_interval=self.keepalive_interval,
|
|
68
65
|
)
|
|
69
66
|
|
|
70
67
|
|
|
@@ -88,15 +85,6 @@ class TestingSandbox(base_sandbox.BaseSandbox):
|
|
|
88
85
|
else:
|
|
89
86
|
raise error_type(message)
|
|
90
87
|
|
|
91
|
-
def wait_until(
|
|
92
|
-
self,
|
|
93
|
-
status: interface.Sandbox.Status | tuple[interface.Sandbox.Status, ...]
|
|
94
|
-
) -> None:
|
|
95
|
-
if not isinstance(status, tuple):
|
|
96
|
-
status = (status,)
|
|
97
|
-
while self.status not in status:
|
|
98
|
-
time.sleep(0.1)
|
|
99
|
-
|
|
100
88
|
def wait_until_not(
|
|
101
89
|
self,
|
|
102
90
|
status: interface.Sandbox.Status | tuple[interface.Sandbox.Status, ...]
|
|
@@ -104,12 +92,12 @@ class TestingSandbox(base_sandbox.BaseSandbox):
|
|
|
104
92
|
if not isinstance(status, tuple):
|
|
105
93
|
status = (status,)
|
|
106
94
|
while self.status in status:
|
|
107
|
-
time.sleep(0.
|
|
95
|
+
time.sleep(0.01)
|
|
108
96
|
|
|
109
97
|
def wait_until_next_housekeep(self) -> None:
|
|
110
98
|
housekeep_counter = self.housekeep_counter
|
|
111
99
|
while self.housekeep_counter == housekeep_counter:
|
|
112
|
-
time.sleep(0.
|
|
100
|
+
time.sleep(0.01)
|
|
113
101
|
|
|
114
102
|
def _start(self) -> None:
|
|
115
103
|
if self.simulate_start_error:
|
|
@@ -230,8 +218,8 @@ class TestingFeature(base_feature.BaseFeature):
|
|
|
230
218
|
)
|
|
231
219
|
|
|
232
220
|
|
|
233
|
-
class
|
|
234
|
-
pg.Object,
|
|
221
|
+
class TestingEventHandler(
|
|
222
|
+
pg.Object, event_handler_base.EventHandler
|
|
235
223
|
):
|
|
236
224
|
"""Testing environment event handler for unit tests."""
|
|
237
225
|
|
|
@@ -296,7 +284,6 @@ class TestingEnvironmentEventHandler(
|
|
|
296
284
|
duration: float,
|
|
297
285
|
error: BaseException | None
|
|
298
286
|
) -> None:
|
|
299
|
-
assert isinstance(environment, TestingEnvironment)
|
|
300
287
|
assert duration > 0
|
|
301
288
|
self._add_message(f'[{sandbox.id}] sandbox started', error)
|
|
302
289
|
|
|
@@ -459,7 +446,6 @@ class TestingEnvironmentEventHandler(
|
|
|
459
446
|
**kwargs
|
|
460
447
|
) -> None:
|
|
461
448
|
"""Called when a sandbox activity is performed."""
|
|
462
|
-
assert duration > 0
|
|
463
449
|
del environment, kwargs
|
|
464
450
|
if session_id is None:
|
|
465
451
|
log_id = sandbox.id
|
|
@@ -90,7 +90,7 @@ langfun/core/eval/v2/reporting.py,sha256=yUIPCAMnp7InIzpv1DDWrcLO-75iiOUTpscj7sm
|
|
|
90
90
|
langfun/core/eval/v2/reporting_test.py,sha256=CMK-vwho8cNRJwlbkCqm_v5fykE7Y3V6SaIOCY0CDyA,5671
|
|
91
91
|
langfun/core/eval/v2/runners.py,sha256=bEniZDNu44AQgvqpwLsvBU4V_7WltAe-NPhYgIsLj1E,16848
|
|
92
92
|
langfun/core/eval/v2/runners_test.py,sha256=spjkmqlls_vyERdZMdjv6dhIN9ZfxsDDvIQAWTj2kMk,11954
|
|
93
|
-
langfun/core/llms/__init__.py,sha256=
|
|
93
|
+
langfun/core/llms/__init__.py,sha256=SViaAza5E00WG_vdsB69FF1n1vTm5pQrqR6eTfjXlhE,9793
|
|
94
94
|
langfun/core/llms/anthropic.py,sha256=YcQ2VG8iOfXtry_tTpAukmiwXa2hK_9LkpkmXk41Nm0,26226
|
|
95
95
|
langfun/core/llms/anthropic_test.py,sha256=qA9vByp_cwwXNlXzcwHpPWFnO9lfFo8NKfDi5nBNqgI,9052
|
|
96
96
|
langfun/core/llms/azure_openai.py,sha256=-KkSLaR54MlsIqz_XIwv0TnsBnvNTAxnjA2Q2O2u5KM,2733
|
|
@@ -109,7 +109,7 @@ langfun/core/llms/groq.py,sha256=S9V10kFo3cgX89qPgt_umq-SpRnxEDLTt_hJmpERfbo,120
|
|
|
109
109
|
langfun/core/llms/groq_test.py,sha256=P4EgexCqsh4K2x11w0UL_vz-YYNaPdQU0WsDAdnTRQ8,2045
|
|
110
110
|
langfun/core/llms/llama_cpp.py,sha256=Z7P3gc4xeIjc2bX0Ey1y5EUYJVMnMa2Q67PZ9iye9sE,1409
|
|
111
111
|
langfun/core/llms/llama_cpp_test.py,sha256=wfTO7nmUwL65U2kK9P9fcMt92JjNDuVia4G1E7znf_4,1086
|
|
112
|
-
langfun/core/llms/openai.py,sha256=
|
|
112
|
+
langfun/core/llms/openai.py,sha256=UZM0j3BHRz5NVLs8q7YYRkneM1CwuGQSt7sFaM4IAPU,44164
|
|
113
113
|
langfun/core/llms/openai_compatible.py,sha256=JlFUTiK4e3ox2DGeGBcAD-cXkxmBdx5g6LrYkyMIaps,5777
|
|
114
114
|
langfun/core/llms/openai_compatible_test.py,sha256=KwOMA7tsmOxFBjezltkBDSU77AvOQkI23dO2nHLAlB4,17689
|
|
115
115
|
langfun/core/llms/openai_test.py,sha256=gwuO6aoa296iM2welWV9ua4KF8gEVGsEPakgbtkWkFQ,2687
|
|
@@ -165,18 +165,22 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
|
|
|
165
165
|
langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
|
|
166
166
|
langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
|
|
167
167
|
langfun/core/templates/selfplay_test.py,sha256=Ot__1P1M8oJfoTp-M9-PQ6HUXqZKyMwvZ5f7yQ3yfyM,2326
|
|
168
|
-
langfun/env/__init__.py,sha256=
|
|
169
|
-
langfun/env/base_environment.py,sha256=
|
|
170
|
-
langfun/env/base_feature.py,sha256=
|
|
171
|
-
langfun/env/base_sandbox.py,sha256=
|
|
172
|
-
langfun/env/base_test.py,sha256=
|
|
173
|
-
langfun/env/interface.py,sha256=
|
|
174
|
-
langfun/env/interface_test.py,sha256=
|
|
168
|
+
langfun/env/__init__.py,sha256=m6Y8y16ms9lytvO_r-Br8HmTp2rNDhb3R6JJaH5dEEk,1491
|
|
169
|
+
langfun/env/base_environment.py,sha256=Vjpmck3k3UE3KaHq69dIuGbevbRJFlY6PvQEeZ18MtY,18087
|
|
170
|
+
langfun/env/base_feature.py,sha256=dztFq1lcdXgUh3m8pNRC3vruyIdHCob27reiXz_02q8,6436
|
|
171
|
+
langfun/env/base_sandbox.py,sha256=tR__USJZojDrGtnhmDqkbCHrvcrNUDrTwc9mpStyYZ0,36721
|
|
172
|
+
langfun/env/base_test.py,sha256=cBZEcoJG16L_XLVyTgSCxUxy1cukrkpSNNEgiM5LZb4,59137
|
|
173
|
+
langfun/env/interface.py,sha256=2Amf-_op7dGRF8c4-wYxcFxs1UCBYz1AB20Lk7__V4E,25724
|
|
174
|
+
langfun/env/interface_test.py,sha256=hfQn4RRTEo1YfVHXTPzH1puzD14BTo8R_5v1IpXVZ90,1398
|
|
175
175
|
langfun/env/load_balancers.py,sha256=qRhCthqzjZIQBwta8qC1C0s0J-VQAVomJQqI7Nqv-r4,1948
|
|
176
|
-
langfun/env/load_balancers_test.py,sha256=
|
|
177
|
-
langfun/env/test_utils.py,sha256=
|
|
178
|
-
langfun
|
|
179
|
-
langfun
|
|
180
|
-
langfun
|
|
181
|
-
langfun
|
|
182
|
-
langfun-0.1.2.
|
|
176
|
+
langfun/env/load_balancers_test.py,sha256=KIDIwZeQHcW0fCL5ScZD0lm0QV4_X2y-rMqdd6R1gLc,3737
|
|
177
|
+
langfun/env/test_utils.py,sha256=Cx4J69r_dLcmDyzEVqOzAZ1Gtk5CnbM2K6nSnRHzIAc,13874
|
|
178
|
+
langfun/env/event_handlers/__init__.py,sha256=sZTUeYpnUMzfH6AghhT-hnBHnFxg5UaH-AOmw3YbyMM,376
|
|
179
|
+
langfun/env/event_handlers/base.py,sha256=w2pdAKfGL-TDTQD2lQ-c_BD3jWeAXF5SYBkAj2GNRz0,7532
|
|
180
|
+
langfun/env/event_handlers/event_logger.py,sha256=4jDV6siGRXR95QFJj_9rnQ_BYMaR6IaPb-wuZ7YzCls,11200
|
|
181
|
+
langfun/env/event_handlers/event_logger_test.py,sha256=OpObIB9IXuuNaRFxOuYcmV4RV6sUTbH5zr3-R7B5UGQ,8536
|
|
182
|
+
langfun-0.1.2.dev202509270803.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
183
|
+
langfun-0.1.2.dev202509270803.dist-info/METADATA,sha256=gw4qV51Ivfqu6p7oCpYsvs_P8wzQTV7AwgTyvNyDW4o,7380
|
|
184
|
+
langfun-0.1.2.dev202509270803.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
185
|
+
langfun-0.1.2.dev202509270803.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
|
186
|
+
langfun-0.1.2.dev202509270803.dist-info/RECORD,,
|
|
File without changes
|
{langfun-0.1.2.dev202509250804.dist-info → langfun-0.1.2.dev202509270803.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{langfun-0.1.2.dev202509250804.dist-info → langfun-0.1.2.dev202509270803.dist-info}/top_level.txt
RENAMED
|
File without changes
|