previous deepsparse/loggers are moved to deepsparse/legacy/loggers. Tests and imports are moved to tests/legacy folder for the above.
Newly implemented loggers are now under deepsparse/loggers.
Description
Given a yaml config file that describes the logger, tag, function to apply, rate to log (frequency) for three log_type entrypoints: system, performance, metrics, create .log(log_type, value, tag).
What happens under the hood
Instantiation
Parse the config into pydantic, check if in appropriate format
Build and create leaf loggers (singleton), root loggers, frequency state (with respect to log_type, wrt tag wrt func), and instantiate Async callable. Note that the root logger can share the same leaf logger, bc they are singletons.
Basic dependencies:
LoggerManager(AsyncExecutor, LoggerFactory)
AsyncExecutor
LoggerFactory -> instantiates singleton loggers and builds the root loggers
FrequencyExecutor -> Register dict({tag}.{func}: counter), and handler filtering logic.
RootLogger(FrequencyExecutor) -> what loggers to run given a tag {tag: loggers[]}, what func to run given tag.
SystemLogger(RootLogger)
PerformanceLogger(RootLogger)
MetricLogger(RootLogger)
calling .log(...)
Send all kwargs to AsyncExecutor to execute downstream code async
Select which log_type RootLoggers to use (that root logger already have loggers and frequencies set up)
Tag filter. Check if the given tag from kwargs is valid with the tag in the config file (tag in the config file can be a regex). If matches with any of the tag, then proceed
Frequency filter. Check if the current log call is valid via frequency filter (filter wrt tag, log_type, func, one counter for the combination of the three.. AKA {log_type.tag.func: counter}) ***
compute func(value) and proceed, reuse the func(value) for any of the next frequency counter matches
log(tag=a, value=1, log_type="system") # no log to any of "a"
log(tag=a, value=1, log_type="system") # log to prometheus and default (python logger)
log(tag=b, value=1, log_type="system") # log to none of "b" (prometheus does not get trigered, bc different tag)
PRs that compose the main functionality of this feature branch
Recommended order of review:
[MERGED] https://github.com/neuralmagic/deepsparse/pull/1533: config file -- Pydantic validation, and config file skeleton [MERGED] https://github.com/neuralmagic/deepsparse/pull/1536: utils (for import) -- config file may provide a name or path/to/file.py:ClassName, import helpers [MERGED] https://github.com/neuralmagic/deepsparse/pull/1539: registry for default func/class -- Default func, classnames [MERGED] https://github.com/neuralmagic/deepsparse/pull/1540: Filters -- we apply three filters (1) filter by tag (2) filer by frequency (3) only for metric loggers, filter by capture (keys, properties of an obj) [MERGED] https://github.com/neuralmagic/deepsparse/pull/1542: Root logger -- Responsible for organizing the parameters (freq, func, tag) into a data structure, so that it can apply the filtering rules in a simple fashion to log [MERGED] https://github.com/neuralmagic/deepsparse/pull/1537: Logger factory -- factory to get the root loggers and instantiate the leaf loggers [MERGED] https://github.com/neuralmagic/deepsparse/pull/1538: Async Submitter -- run something async [MERGED] https://github.com/neuralmagic/deepsparse/pull/1541: Logger Manager -- responsible for instantiating and assigning logging jobs to the root loggers [MERGED] https://github.com/neuralmagic/deepsparse/pull/1543: Logger middleware -- responsible to log output using middleware [MERGED] https://github.com/neuralmagic/deepsparse/pull/1553 -- tests with pipeline
https://github.com/neuralmagic/deepsparse/pull/1516: Current feature branch
Changes
Description
Given a yaml config file that describes the logger, tag, function to apply, rate to log (frequency) for three log_type entrypoints: system, performance, metrics, create
.log(log_type, value, tag)
.What happens under the hood
Instantiation
Basic dependencies:
LoggerManager(AsyncExecutor, LoggerFactory)
AsyncExecutor
LoggerFactory -> instantiates singleton loggers and builds the root loggers
FrequencyExecutor -> Register dict({tag}.{func}: counter), and handler filtering logic.
RootLogger(FrequencyExecutor) -> what loggers to run given a tag {tag: loggers[]}, what func to run given tag.
SystemLogger(RootLogger)
PerformanceLogger(RootLogger)
MetricLogger(RootLogger)
calling
.log(...)
{log_type.tag.func: counter})
****** Example with the filters from config