Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V2 Logger] Feature branch #1516

Merged
merged 37 commits into from
Feb 15, 2024
Merged

[V2 Logger] Feature branch #1516

merged 37 commits into from
Feb 15, 2024

Conversation

horheynm
Copy link
Member

@horheynm horheynm commented Jan 8, 2024

PRs that compose the main functionality of this feature branch

Recommended order of review:

[MERGED] #1533: config file -- Pydantic validation, and config file skeleton
[MERGED] #1536: utils (for import) -- config file may provide a name or path/to/file.py:ClassName, import helpers
[MERGED] #1539: registry for default func/class -- Default func, classnames
[MERGED] #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] #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] #1537: Logger factory -- factory to get the root loggers and instantiate the leaf loggers
[MERGED] #1538: Async Submitter -- run something async
[MERGED] #1541: Logger Manager -- responsible for instantiating and assigning logging jobs to the root loggers
[MERGED] #1543: Logger middleware -- responsible to log output using middleware
[MERGED] #1553 -- tests with pipeline

#1516: Current feature branch

Changes

  • 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.
Screenshot 2024-01-19 at 1 40 27 PM

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

  1. Parse the config into pydantic, check if in appropriate format
  2. 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(...)

  1. Send all kwargs to AsyncExecutor to execute downstream code async
  2. Select which log_type RootLoggers to use (that root logger already have loggers and frequencies set up)
  3. 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
  4. 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}) ***
  5. compute func(value) and proceed, reuse the func(value) for any of the next frequency counter matches
  6. For each leaf logger, log it out

*** Example with the filters from config

metric:
  "a":
    - func: max
      freq: 2
      uses:
        - prometheus
        - default

  "b":
    - func: max
      freq: 3
      uses:
        - prometheus
        - python
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)

@rahul-tuli rahul-tuli changed the title logger feature beanch logger feature branch Jan 12, 2024
@horheynm horheynm changed the title logger feature branch [V2 Logger] Feature branch Jan 17, 2024
* utils for import

* clean up + tests
* registry for default func/class

* prometheus logger

* clean up

* clean up

* remove ListLogger import, moved to tests

* add base logger for type checking

* exmaple
* filters

* cleaner logic

* fix bug -- if config has duplicated tag.func with different freq

* delete config test

* move unravel_value_as_generator to pattern.py

* tests

* doc string

* exact match
* config file

* test

* comments

* comments
* root logger

* only get func's with respect to the tag

* fix bug for duplicated tag.log_type

* clena up

* doc strings:

* loosen up rules for capture
* factory

* docstring
* logger middleware

* yield individual eleeents in a list

* comments

* edit state
@horheynm horheynm marked this pull request as ready for review January 25, 2024 18:54
@horheynm horheynm requested review from dsikka, dbogunowicz and bfineran and removed request for dbogunowicz January 25, 2024 18:57
bfineran
bfineran previously approved these changes Jan 25, 2024
@horheynm horheynm merged commit e6f9276 into main Feb 15, 2024
@horheynm horheynm deleted the v2/logger branch February 15, 2024 15:06
horheynm added a commit that referenced this pull request Feb 20, 2024
* logger feature beanch

* [V2 Logger]  utils for import (#1536)

* utils for import

* clean up + tests

* [V2 Logger] registry for default func/class (#1539)

* registry for default func/class

* prometheus logger

* clean up

* clean up

* remove ListLogger import, moved to tests

* add base logger for type checking

* exmaple

* [V2 Logger] Filters (#1540)

* filters

* cleaner logic

* fix bug -- if config has duplicated tag.func with different freq

* delete config test

* move unravel_value_as_generator to pattern.py

* tests

* doc string

* exact match

* async submitter (#1538)

* manager (#1541)

* [V2 Loggers] logger manager patch (#1560)

* manager

* doc string

* [V2 Loggers] config file (#1533)

* config file

* test

* comments

* comments

* pipeline tests (#1553)

* [V2 Logger] root logger (#1542)

* root logger

* only get func's with respect to the tag

* fix bug for duplicated tag.log_type

* clena up

* doc strings:

* loosen up rules for capture

* [V2 Logger]  factory (#1537)

* factory

* docstring

* [V2 Logger] logger middleware (#1543)

* logger middleware

* yield individual eleeents in a list

* comments

* edit state

* polish, passes tests

* pass middleware

* edit condition to add logger to inference state

* set default logger manager

* delete og prometheus logger test

* fix in test_basic_logger

* move loggers to legacy and pass tests, circular imports

* move tests/deepsparse/loggers to tests/deepsparse/legacy/loggers and pass tests

* move loggers_v2 to logger for src and tests, pass logger tests

* fix tests and rename legacy logger tests to _legacy_

* pass tests, wait for async logs to complete'

* doc string typo and change default to re:.*

* fix frequency test bug on text gen

* wait for async loggers to finish before counting

* get rid of capture, inconsistent number of fields per log calls cause error
horheynm added a commit that referenced this pull request Feb 22, 2024
* [V2 Logger] Feature branch (#1516)

* logger feature beanch

* [V2 Logger]  utils for import (#1536)

* utils for import

* clean up + tests

* [V2 Logger] registry for default func/class (#1539)

* registry for default func/class

* prometheus logger

* clean up

* clean up

* remove ListLogger import, moved to tests

* add base logger for type checking

* exmaple

* [V2 Logger] Filters (#1540)

* filters

* cleaner logic

* fix bug -- if config has duplicated tag.func with different freq

* delete config test

* move unravel_value_as_generator to pattern.py

* tests

* doc string

* exact match

* async submitter (#1538)

* manager (#1541)

* [V2 Loggers] logger manager patch (#1560)

* manager

* doc string

* [V2 Loggers] config file (#1533)

* config file

* test

* comments

* comments

* pipeline tests (#1553)

* [V2 Logger] root logger (#1542)

* root logger

* only get func's with respect to the tag

* fix bug for duplicated tag.log_type

* clena up

* doc strings:

* loosen up rules for capture

* [V2 Logger]  factory (#1537)

* factory

* docstring

* [V2 Logger] logger middleware (#1543)

* logger middleware

* yield individual eleeents in a list

* comments

* edit state

* polish, passes tests

* pass middleware

* edit condition to add logger to inference state

* set default logger manager

* delete og prometheus logger test

* fix in test_basic_logger

* move loggers to legacy and pass tests, circular imports

* move tests/deepsparse/loggers to tests/deepsparse/legacy/loggers and pass tests

* move loggers_v2 to logger for src and tests, pass logger tests

* fix tests and rename legacy logger tests to _legacy_

* pass tests, wait for async logs to complete'

* doc string typo and change default to re:.*

* fix frequency test bug on text gen

* wait for async loggers to finish before counting

* get rid of capture, inconsistent number of fields per log calls cause error

* fix src. reference (#1607)

---------

Co-authored-by: Benjamin Fineran <bfineran@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants