langfun 0.1.2.dev202509250804__py3-none-any.whl → 0.1.2.dev202509260805__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/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.EnvironmentId:
38
- return interface.EnvironmentId('testing-env')
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.1)
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.SandboxId(
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.1)
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.1)
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 TestingEnvironmentEventHandler(
234
- pg.Object, interface.EnvironmentEventHandler
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langfun
3
- Version: 0.1.2.dev202509250804
3
+ Version: 0.1.2.dev202509260805
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -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=1u5hRfO2i-shsPaoOsbYrnvwldo3Mvkd3BfqhV4dOC0,1538
169
- langfun/env/base_environment.py,sha256=FvAVfwfh3sT_XDrYH3adWo_ED6af-t6U3DuVamxv6YU,17636
170
- langfun/env/base_feature.py,sha256=UArKlAZMYpftakLD25apLw84RqtJA_XcA_nkFt_iBRQ,6162
171
- langfun/env/base_sandbox.py,sha256=Ena8GN_DaJj-4oMLH6kJQh1TMmBwo6_aU6IcdNWKNrw,36436
172
- langfun/env/base_test.py,sha256=sGNTylTxQsX9gfc8IMt6_7L9VgLn7q5W2xuDHl8LFuQ,57170
173
- langfun/env/interface.py,sha256=cuuBrFgCCEvKZx5EkKfIIKu1XfeijLr7sff9jyjrdg0,33359
174
- langfun/env/interface_test.py,sha256=nrqFLtpHd0vnOjoIX9cjV5WD1c-7J3WW29aogNu_94A,1395
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=gJKJ3K5_WS7hsz9Jv3nPEjlb04Z6MmrZpfCu86siYKU,3967
177
- langfun/env/test_utils.py,sha256=piNl09bQUW0GzEyQkyTCCJwzfxQ3z8s3M1lYcHCnmdo,14248
178
- langfun-0.1.2.dev202509250804.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
179
- langfun-0.1.2.dev202509250804.dist-info/METADATA,sha256=pAaeHsBcf9oirhLuF2RMulQm-r08T0lz48kO4xWv6Rw,7380
180
- langfun-0.1.2.dev202509250804.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
181
- langfun-0.1.2.dev202509250804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
182
- langfun-0.1.2.dev202509250804.dist-info/RECORD,,
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.dev202509260805.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
183
+ langfun-0.1.2.dev202509260805.dist-info/METADATA,sha256=Tee4run8k20LEd7W2ZXxM6E_TzH4g6GFQF-ude-fhS4,7380
184
+ langfun-0.1.2.dev202509260805.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
185
+ langfun-0.1.2.dev202509260805.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
186
+ langfun-0.1.2.dev202509260805.dist-info/RECORD,,