MCPcopy
hub / github.com/ray-project/ray / log_once

Function log_once

python/ray/util/debug.py:18–55  ·  view source on GitHub ↗

Returns True if this is the "first" call for a given key. Various logging settings can adjust the definition of "first". Args: key: A unique identifier for the call site. Returns: True if this is the first call for ``key`` (subject to the current ``log_once`` s

(key: str)

Source from the content-addressed store, hash-verified

16
17@DeveloperAPI
18def log_once(key: str) -> bool:
19 """Returns True if this is the "first" call for a given key.
20
21 Various logging settings can adjust the definition of "first".
22
23 Args:
24 key: A unique identifier for the call site.
25
26 Returns:
27 True if this is the first call for ``key`` (subject to the current
28 ``log_once`` settings), False otherwise.
29
30 Example:
31
32 .. testcode::
33
34 import logging
35 from ray.util.debug import log_once
36
37 logger = logging.getLogger(__name__)
38 if log_once("some_key"):
39 logger.info("Some verbose logging statement")
40 """
41
42 global _last_logged
43
44 if _disabled:
45 return False
46 elif key not in _logged:
47 _logged.add(key)
48 _last_logged = time.time()
49 return True
50 elif _periodic_log and time.time() - _last_logged > 60.0:
51 _logged.clear()
52 _last_logged = time.time()
53 return False
54 else:
55 return False
56
57
58@DeveloperAPI

Callers 15

patched_initFunction · 0.90
_ctorFunction · 0.90
_bootstrap_configFunction · 0.90
batch_to_blockMethod · 0.90
handle_traceFunction · 0.90
executeMethod · 0.90
addMethod · 0.90
_derive_metadataFunction · 0.90
truncate_operator_nameFunction · 0.90
get_progress_managerFunction · 0.90
_iter_batches_fallbackFunction · 0.90

Calls 3

addMethod · 0.45
timeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…