langfun 0.1.2.dev202409160804__py3-none-any.whl → 0.1.2.dev202409170804__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/__init__.py +1 -0
- langfun/core/logging.py +13 -7
- {langfun-0.1.2.dev202409160804.dist-info → langfun-0.1.2.dev202409170804.dist-info}/METADATA +1 -1
- {langfun-0.1.2.dev202409160804.dist-info → langfun-0.1.2.dev202409170804.dist-info}/RECORD +7 -7
- {langfun-0.1.2.dev202409160804.dist-info → langfun-0.1.2.dev202409170804.dist-info}/WHEEL +1 -1
- {langfun-0.1.2.dev202409160804.dist-info → langfun-0.1.2.dev202409170804.dist-info}/LICENSE +0 -0
- {langfun-0.1.2.dev202409160804.dist-info → langfun-0.1.2.dev202409170804.dist-info}/top_level.txt +0 -0
langfun/core/__init__.py
CHANGED
@@ -45,6 +45,7 @@ use_context = context
|
|
45
45
|
from langfun.core.component import use_settings
|
46
46
|
|
47
47
|
from langfun.core.component import get_contextual_override
|
48
|
+
from langfun.core.component import context_value
|
48
49
|
|
49
50
|
# Value marker for attribute whose values will be provided from parent
|
50
51
|
# objects or from the `pg.component_context` context manager.
|
langfun/core/logging.py
CHANGED
@@ -13,11 +13,14 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
"""Langfun event logging."""
|
15
15
|
|
16
|
+
from collections.abc import Iterator
|
17
|
+
import contextlib
|
16
18
|
import datetime
|
17
19
|
import io
|
18
20
|
import typing
|
19
|
-
from typing import Any, Literal
|
21
|
+
from typing import Any, Literal
|
20
22
|
|
23
|
+
from langfun.core import component
|
21
24
|
from langfun.core import console
|
22
25
|
from langfun.core import repr_utils
|
23
26
|
import pyglove as pg
|
@@ -25,18 +28,21 @@ import pyglove as pg
|
|
25
28
|
|
26
29
|
LogLevel = Literal['debug', 'info', 'error', 'warning', 'fatal']
|
27
30
|
_LOG_LEVELS = list(typing.get_args(LogLevel))
|
28
|
-
_TLS_KEY_MIN_LOG_LEVEL = '_event_log_level'
|
29
31
|
|
30
32
|
|
31
|
-
|
33
|
+
@contextlib.contextmanager
|
34
|
+
def use_log_level(log_level: LogLevel = 'info') -> Iterator[None]:
|
32
35
|
"""Contextmanager to enable logging at a given level."""
|
33
|
-
|
34
|
-
|
36
|
+
with component.context(__event_log_level__=log_level):
|
37
|
+
try:
|
38
|
+
yield
|
39
|
+
finally:
|
40
|
+
pass
|
35
41
|
|
36
42
|
|
37
|
-
def get_log_level() -> LogLevel
|
43
|
+
def get_log_level() -> LogLevel:
|
38
44
|
"""Gets the current minimum log level."""
|
39
|
-
return
|
45
|
+
return component.context_value('__event_log_level__', 'info')
|
40
46
|
|
41
47
|
|
42
48
|
class LogEntry(pg.Object):
|
@@ -1,5 +1,5 @@
|
|
1
1
|
langfun/__init__.py,sha256=mCES7t3R7Z-ZQYvG38-yrVqZubrXNfGCa8tI5HGB7mE,2274
|
2
|
-
langfun/core/__init__.py,sha256=
|
2
|
+
langfun/core/__init__.py,sha256=gKoZrxwxdR_UweutfeeECUEL6ogcr8lKk9ub5_9NaM0,4884
|
3
3
|
langfun/core/component.py,sha256=nxF4UD7NLduPjrf4IAtysMAIg3IChfoQHjY77vC8f_E,10263
|
4
4
|
langfun/core/component_test.py,sha256=q15Xn51cVTu2RKxZ9U5VQgT3bm6RQ4638bKhWBtvW5o,8220
|
5
5
|
langfun/core/concurrent.py,sha256=D_zoLGFREGfm0G93V27wzOlFh3MjaDxUZKb9g6Z69d4,28019
|
@@ -10,7 +10,7 @@ langfun/core/langfunc.py,sha256=G50YgoVZ0y1GFw2ev41MlOqr6qa8YakbvNC0h_E0PiA,1114
|
|
10
10
|
langfun/core/langfunc_test.py,sha256=ZLlj6ysNIWUlm0jcq6PbNUwdJ2XstW5QQT0L2s5GlGY,8753
|
11
11
|
langfun/core/language_model.py,sha256=o1MPDdiZ7eRUhcCjxLMT6IYYXge6nM7elvCWQ-NANaU,26286
|
12
12
|
langfun/core/language_model_test.py,sha256=ebJ1vnaxKSKvlwi6v07yHjn91xMiDw2bQ9DBnyVorYw,23303
|
13
|
-
langfun/core/logging.py,sha256=
|
13
|
+
langfun/core/logging.py,sha256=wYDuPuGeS1hyJBzjMQgquyfLw-TUVO-b7H68UA8X-Eg,4279
|
14
14
|
langfun/core/logging_test.py,sha256=poSsNGKi6G9LWOcWnTY0BQjj0BtaQknH-NK6FcQrVT4,2152
|
15
15
|
langfun/core/memory.py,sha256=f-asN1F7Vehgdn_fK84v73GrEUOxRtaW934keutTKjk,2416
|
16
16
|
langfun/core/message.py,sha256=7UOxNMA1Le0ZGkleryqwXcWojZ-l_hku5Sc58BsIOGw,18586
|
@@ -119,8 +119,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
|
|
119
119
|
langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
|
120
120
|
langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
|
121
121
|
langfun/core/templates/selfplay_test.py,sha256=rBW2Qr8yi-aWYwoTwRR-n1peKyMX9QXPZXURjLgoiRs,2264
|
122
|
-
langfun-0.1.2.
|
123
|
-
langfun-0.1.2.
|
124
|
-
langfun-0.1.2.
|
125
|
-
langfun-0.1.2.
|
126
|
-
langfun-0.1.2.
|
122
|
+
langfun-0.1.2.dev202409170804.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
123
|
+
langfun-0.1.2.dev202409170804.dist-info/METADATA,sha256=atoHFAR24zaLtcMo2sp5-Wpbt6zWK8IHVx8RkjltNMc,8890
|
124
|
+
langfun-0.1.2.dev202409170804.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
125
|
+
langfun-0.1.2.dev202409170804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
126
|
+
langfun-0.1.2.dev202409170804.dist-info/RECORD,,
|
File without changes
|
{langfun-0.1.2.dev202409160804.dist-info → langfun-0.1.2.dev202409170804.dist-info}/top_level.txt
RENAMED
File without changes
|