pyglove 0.4.5.dev202504260808__py3-none-any.whl → 0.4.5.dev202504262309__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.
- pyglove/core/logging.py +30 -0
- {pyglove-0.4.5.dev202504260808.dist-info → pyglove-0.4.5.dev202504262309.dist-info}/METADATA +1 -1
- {pyglove-0.4.5.dev202504260808.dist-info → pyglove-0.4.5.dev202504262309.dist-info}/RECORD +6 -6
- {pyglove-0.4.5.dev202504260808.dist-info → pyglove-0.4.5.dev202504262309.dist-info}/WHEEL +0 -0
- {pyglove-0.4.5.dev202504260808.dist-info → pyglove-0.4.5.dev202504262309.dist-info}/licenses/LICENSE +0 -0
- {pyglove-0.4.5.dev202504260808.dist-info → pyglove-0.4.5.dev202504262309.dist-info}/top_level.txt +0 -0
pyglove/core/logging.py
CHANGED
@@ -17,17 +17,47 @@ This module allows PyGlove to use external created logger for logging PyGlove
|
|
17
17
|
events without introducing library dependencies in PyGlove.
|
18
18
|
"""
|
19
19
|
|
20
|
+
import inspect
|
20
21
|
import logging
|
22
|
+
from typing import Any, Callable, List, Union
|
21
23
|
|
22
24
|
|
23
25
|
_DEFAULT_LOGGER = logging.getLogger()
|
24
26
|
|
25
27
|
|
28
|
+
def register_frame_to_skip(
|
29
|
+
method: Union[Callable[..., Any], List[Callable[..., Any]]]
|
30
|
+
) -> bool:
|
31
|
+
"""Skips the source of the given method when logging.
|
32
|
+
|
33
|
+
Args:
|
34
|
+
method: The method to skip. Can be a single method or a list of methods.
|
35
|
+
|
36
|
+
Returns:
|
37
|
+
True if the method is registered to skip.
|
38
|
+
|
39
|
+
Raises:
|
40
|
+
TypeError: The source file of the method cannot be inspected.
|
41
|
+
"""
|
42
|
+
register_fn = getattr(
|
43
|
+
_DEFAULT_LOGGER.__class__, 'register_frame_to_skip', None
|
44
|
+
)
|
45
|
+
if register_fn is None:
|
46
|
+
return False
|
47
|
+
methods = [method] if not isinstance(method, list) else method
|
48
|
+
for m in methods:
|
49
|
+
register_fn(inspect.getsourcefile(m), m.__name__)
|
50
|
+
return True
|
51
|
+
|
52
|
+
|
26
53
|
def set_logger(logger: logging.Logger) -> None:
|
27
54
|
"""Sets current logger."""
|
28
55
|
global _DEFAULT_LOGGER
|
29
56
|
_DEFAULT_LOGGER = logger
|
30
57
|
|
58
|
+
# Skip logging frames in pyglove.logging.
|
59
|
+
register_frame_to_skip([debug, info, warning, error, critical])
|
60
|
+
|
31
61
|
|
32
62
|
def get_logger() -> logging.Logger:
|
33
63
|
"""Gets the current logger."""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
pyglove/__init__.py,sha256=YPUWALRDu4QuI7N3TUmVaVr513hUt0qXrjY582I1q5c,1352
|
2
2
|
pyglove/core/__init__.py,sha256=BF-8v1D5lTBAo4vlpDt0qyOG9NQ71oh_UfthBVrPaN4,9614
|
3
|
-
pyglove/core/logging.py,sha256=
|
3
|
+
pyglove/core/logging.py,sha256=pD5A6K8TOWoQdYZ1IgGHHd_vIcqtcWQ51Eep5Hswfwc,3305
|
4
4
|
pyglove/core/logging_test.py,sha256=3z_c6wnxbqDbwUmSOAZzeDPXvzoweYL5QHUQVMJ5Xgo,1917
|
5
5
|
pyglove/core/coding/__init__.py,sha256=tuHIg19ZchtkOQbdFVTVLkUpBa5f1eo66XtnKw3lcIU,1645
|
6
6
|
pyglove/core/coding/errors.py,sha256=aP3Y4amBzOKdlb5JnESJ3kdoijQXbiBiPDMeA88LNrk,3310
|
@@ -212,8 +212,8 @@ pyglove/ext/scalars/randoms.py,sha256=LkMIIx7lOq_lvJvVS3BrgWGuWl7Pi91-lA-O8x_gZs
|
|
212
212
|
pyglove/ext/scalars/randoms_test.py,sha256=nEhiqarg8l_5EOucp59CYrpO2uKxS1pe0hmBdZUzRNM,2000
|
213
213
|
pyglove/ext/scalars/step_wise.py,sha256=IDw3tuTpv0KVh7AN44W43zqm1-E0HWPUlytWOQC9w3Y,3789
|
214
214
|
pyglove/ext/scalars/step_wise_test.py,sha256=TL1vJ19xVx2t5HKuyIzGoogF7N3Rm8YhLE6JF7i0iy8,2540
|
215
|
-
pyglove-0.4.5.
|
216
|
-
pyglove-0.4.5.
|
217
|
-
pyglove-0.4.5.
|
218
|
-
pyglove-0.4.5.
|
219
|
-
pyglove-0.4.5.
|
215
|
+
pyglove-0.4.5.dev202504262309.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
216
|
+
pyglove-0.4.5.dev202504262309.dist-info/METADATA,sha256=RQ6ip45zT5abaYRJx7jQ8NM4q5TpmJdZlNRHNw0uJ0g,7089
|
217
|
+
pyglove-0.4.5.dev202504262309.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
218
|
+
pyglove-0.4.5.dev202504262309.dist-info/top_level.txt,sha256=wITzJSKcj8GZUkbq-MvUQnFadkiuAv_qv5qQMw0fIow,8
|
219
|
+
pyglove-0.4.5.dev202504262309.dist-info/RECORD,,
|
File without changes
|
{pyglove-0.4.5.dev202504260808.dist-info → pyglove-0.4.5.dev202504262309.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
{pyglove-0.4.5.dev202504260808.dist-info → pyglove-0.4.5.dev202504262309.dist-info}/top_level.txt
RENAMED
File without changes
|