Skip to content

Commit a4dbb00

Browse files
committed
SnapShooter: Shortened hook ids when logging.
1 parent 3e9fef1 commit a4dbb00

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

dp3/snapshots/snapshot_hooks.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def __init__(self, log: logging.Logger, model_spec: ModelSpec, elog: EventGroupT
7777
self.model_spec = model_spec
7878

7979
self._hooks: defaultdict[str, list[tuple[str, Callable]]] = defaultdict(list)
80+
self._short_hook_ids: dict = {}
8081

8182
self._dependency_graph = DependencyGraph(self.log)
8283
self.used_links = set()
@@ -118,11 +119,9 @@ def register(
118119
depends_on = self._get_attr_path_destinations(entity_type, depends_on)
119120
may_change = self._get_attr_path_destinations(entity_type, may_change)
120121

121-
hook_id = (
122-
f"{get_func_name(hook)}("
123-
f"{entity_type}, [{','.join(depends_on)}], [{','.join(may_change)}]"
124-
f")"
125-
)
122+
hook_args = f"({entity_type}, [{','.join(depends_on)}], [{','.join(may_change)}])"
123+
hook_id = f"{get_func_name(hook)}{hook_args}"
124+
self._short_hook_ids[hook_id] = hook_args
126125
self._dependency_graph.add_hook_dependency(hook_id, depends_on, may_change)
127126

128127
self._hooks[entity_type].append((hook_id, hook))
@@ -208,8 +207,9 @@ def run(self, entities: dict) -> list[DataPointTask]:
208207

209208
with task_context(self.model_spec):
210209
for hook_id, hook, etype in hook_subset:
210+
short_id = hook_id if len(hook_id) < 160 else self._short_hook_ids[hook_id]
211211
for eid, entity_values in entities_by_etype[etype].items():
212-
self.log.debug("Running hook %s on entity %s", hook_id, eid)
212+
self.log.debug("Running hook %s on entity %s", short_id, eid)
213213
try:
214214
tasks = hook(etype, entity_values)
215215
if tasks is not None and tasks:

0 commit comments

Comments
 (0)