langfun 0.1.2.dev202504110804__py3-none-any.whl → 0.1.2.dev202504130803__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.

@@ -134,6 +134,10 @@ class ExecutionTrace(pg.Object, pg.views.html.HtmlTreeView.Extension):
134
134
  self._tab_control = None
135
135
  self._time_badge = None
136
136
 
137
+ def reset(self) -> None:
138
+ """Resets the execution trace."""
139
+ self.rebind(items=[], skip_notification=True, raise_on_no_change=False)
140
+
137
141
  def start(self) -> None:
138
142
  assert self.start_time is None, 'Execution already started.'
139
143
  self.rebind(start_time=time.time(), skip_notification=True)
@@ -724,18 +724,15 @@ class EvaluationState:
724
724
  filter: Callable[[example_lib.Example], bool] | None = None, # pylint: disable=redefined-builtin
725
725
  ) -> None:
726
726
  """Loads the state from the example sequence file."""
727
- with pg.io.sequence.open_sequence(state_file) as f:
728
- for record in f:
729
- example = pg.from_json_str(
730
- record,
731
- example_input_by_id=example_input_by_id,
732
- load_example_metadata=load_example_metadata
733
- )
734
- assert isinstance(example, example_lib.Example), example
735
- if filter is not None and not filter(example):
736
- continue
737
- example.newly_processed = False
738
- self._ckpt_examples[example.id] = example
727
+ for example in example_lib.Example.iter_ckpts(
728
+ state_file,
729
+ example_input_by_id=example_input_by_id,
730
+ load_example_metadata=load_example_metadata,
731
+ ):
732
+ if filter is not None and not filter(example):
733
+ continue
734
+ example.newly_processed = False
735
+ self._ckpt_examples[example.id] = example
739
736
 
740
737
  @property
741
738
  def evaluation_status(self) -> dict[int, ExampleStatus]:
@@ -15,7 +15,7 @@
15
15
 
16
16
  import dataclasses
17
17
  import inspect
18
- from typing import Any, Callable
18
+ from typing import Any, Callable, Iterator
19
19
  import langfun.core as lf
20
20
  import pyglove as pg
21
21
 
@@ -145,6 +145,26 @@ class Example(pg.JSONConvertible, pg.views.HtmlTreeView.Extension):
145
145
  example.metadata = pg.from_json(metadata_dict, **kwargs)
146
146
  return example
147
147
 
148
+ @classmethod
149
+ def iter_ckpts(
150
+ cls,
151
+ ckpt_file: str | list[str],
152
+ example_input_by_id: Callable[[int], Any] | None = None,
153
+ load_example_metadata: bool = True,
154
+ ) -> Iterator['Example']:
155
+ """Iterates Examples from the checkpoint files."""
156
+ ckpt_files = [ckpt_file] if isinstance(ckpt_file, str) else ckpt_file
157
+ for ckpt_file in ckpt_files:
158
+ with pg.io.open_sequence(ckpt_file) as f:
159
+ for record in f:
160
+ example = pg.from_json_str(
161
+ record,
162
+ example_input_by_id=example_input_by_id,
163
+ load_example_metadata=load_example_metadata
164
+ )
165
+ assert isinstance(example, cls), example
166
+ yield example
167
+
148
168
  #
149
169
  # HTML rendering.
150
170
  #
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langfun
3
- Version: 0.1.2.dev202504110804
3
+ Version: 0.1.2.dev202504130803
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -26,7 +26,7 @@ langfun/core/subscription_test.py,sha256=Y4ZdbZEwm83YNZBxHff0QR4QUa4rdaNXA3_jfIc
26
26
  langfun/core/template.py,sha256=jNhYSrbLIn9kZOa03w5QZbyjgfnzJzE_ZrrMvvWY4t4,24929
27
27
  langfun/core/template_test.py,sha256=g7x4mgNIAXEEj-4W1D5whGfl5YikLEQoylKPzaeDomk,17069
28
28
  langfun/core/agentic/__init__.py,sha256=qR3jlfUO4rhIoYdRDLz-d22YZf3FvU4FW88vsjiGDQQ,1224
29
- langfun/core/agentic/action.py,sha256=ViGRwYuqIjNF_A3iUI5mdiGJ-bSXm85GrCX5ZdFOpLw,32602
29
+ langfun/core/agentic/action.py,sha256=8o8UUPKZO2TdUGWU3QrJ4fmm4JdV-kH7G12JdrrYHZE,32744
30
30
  langfun/core/agentic/action_eval.py,sha256=-ZcWt_eYqnTyOe9HFGyrLJkQRd4iG3hfN4IZ-NYAWwA,4534
31
31
  langfun/core/agentic/action_eval_test.py,sha256=tRUkWmOE9p0rpNOq19xAY2oDEnYsEEykjg6sUpAwJk0,2832
32
32
  langfun/core/agentic/action_test.py,sha256=e2INg-E7MaRNuN1qaSXLSnrjrsyVY3uSICiZpMuJr8c,5521
@@ -63,9 +63,9 @@ langfun/core/eval/v2/__init__.py,sha256=9lNKJwbvl0lcFblAXYT_OHI8fOubJsTOdSkxEqsP
63
63
  langfun/core/eval/v2/checkpointing.py,sha256=t47rBfzGZYgIqWW1N1Ak9yQnNtHd-IRbEO0cZjG2VRo,11755
64
64
  langfun/core/eval/v2/checkpointing_test.py,sha256=NggOSJ_6XSa4cNP6nGIu9wLsK59dUwe8SPWDiXtGGDE,9197
65
65
  langfun/core/eval/v2/eval_test_helper.py,sha256=sKFi_wPYCNmr96WyTduuXY0KnxjFxcJyEhXey-_nGX8,3962
66
- langfun/core/eval/v2/evaluation.py,sha256=faL-G98rdGBW9hMSlzZJtkGMytBqvTZRue1k9m_BWRQ,24029
66
+ langfun/core/eval/v2/evaluation.py,sha256=E5PlPb9AA4VV12wHkwH-TXj-3BmYzr1GqhGFcY8gVvs,23882
67
67
  langfun/core/eval/v2/evaluation_test.py,sha256=TKbeyeenoaUDH23E3TXXJ4otuq3VZBuWkWdV7c5vMk4,6804
68
- langfun/core/eval/v2/example.py,sha256=4-LNr8Ke-fhaF6gyeXX4JMyw0s8YkVTC63pXZ-CXKrE,10144
68
+ langfun/core/eval/v2/example.py,sha256=Jegt-viQSNYzPVkOZE_M19GON2TYGTct4Cp9HnJ7DGo,10861
69
69
  langfun/core/eval/v2/example_test.py,sha256=1DNm6EuyZOq827DKvf3oTRVFkMNM_qTnLUpvOjpgz5I,3419
70
70
  langfun/core/eval/v2/experiment.py,sha256=hHNyIw1uSV-hW2nMMx4hV-uul7KwXCmp7jAWNRyT5fU,32938
71
71
  langfun/core/eval/v2/experiment_test.py,sha256=UmCobeS6ifPcaGkTJp0WPISolXrVFbeFCBiyJeA0Lt4,13666
@@ -156,8 +156,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
156
156
  langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
157
157
  langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
158
158
  langfun/core/templates/selfplay_test.py,sha256=Ot__1P1M8oJfoTp-M9-PQ6HUXqZKyMwvZ5f7yQ3yfyM,2326
159
- langfun-0.1.2.dev202504110804.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
160
- langfun-0.1.2.dev202504110804.dist-info/METADATA,sha256=UuGetAgxCOtGnl_sRK-qCacVQ47Sol26gShG223KEgw,7692
161
- langfun-0.1.2.dev202504110804.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
162
- langfun-0.1.2.dev202504110804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
163
- langfun-0.1.2.dev202504110804.dist-info/RECORD,,
159
+ langfun-0.1.2.dev202504130803.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
160
+ langfun-0.1.2.dev202504130803.dist-info/METADATA,sha256=REdBb2tEomjUvwUM6kYaKn-uSChGNpeTuXli3WK5KlM,7692
161
+ langfun-0.1.2.dev202504130803.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
162
+ langfun-0.1.2.dev202504130803.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
163
+ langfun-0.1.2.dev202504130803.dist-info/RECORD,,