Skip to content

Commit 9734029

Browse files
committed
time if debugging
1 parent 4e437b8 commit 9734029

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

src/graphnet/data/extractors/extractor.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ class Extractor(ABC, Logger):
2323
An extractor is used in conjunction with a specific `FileReader`.
2424
"""
2525

26-
def __init__(
27-
self, extractor_name: str, exclude: list = [None], timed: bool = False
28-
) -> None:
26+
def __init__(self, extractor_name: str, exclude: list = [None]):
2927
"""Construct Extractor.
3028
3129
Args:
@@ -34,12 +32,10 @@ def __init__(
3432
data, and to name tables to which this data is
3533
saved. E.g. "mc_truth".
3634
exclude: List of keys to exclude from the extracted data.
37-
timed: Whether to time the execution of the __call__ method.
3835
"""
3936
# Member variable(s)
4037
self._extractor_name: str = extractor_name
4138
self._exclude = exclude
42-
self._timed = timed
4339

4440
# Base class constructor
4541
super().__init__(name=__name__, class_name=self.__class__.__name__)
@@ -76,7 +72,7 @@ def name(self) -> str:
7672
def __init_subclass__(cls) -> None:
7773
"""Initialize subclass and apply the exclude decorator to __call__."""
7874
super().__init_subclass__()
79-
if not cls._timed:
75+
if cls._get_root_logger().getEffectiveLevel() > 10:
8076
cls.__call__ = cls.exclude(cls.__call__) # type: ignore
8177
else:
8278
import time
@@ -91,7 +87,7 @@ def timed_call(
9187
start_time = time.time()
9288
result = original_call(cls, *args)
9389
end_time = time.time()
94-
cls._logger.info(
90+
cls._logger.debug(
9591
f"Extractor {cls.name} took {end_time - start_time:.4f} seconds."
9692
)
9793
return result

0 commit comments

Comments
 (0)