-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from Mustaballer/share-magic-wormhole
- Loading branch information
Showing
13 changed files
with
1,273 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
OPENAI_API_KEY=<set your api key> | ||
DB_FNAME=openadapt.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""Module for log message filtering, excluding strings & limiting warnings.""" | ||
|
||
from collections import defaultdict | ||
import time | ||
|
||
from openadapt import config | ||
|
||
MESSAGE_TIMESTAMPS = defaultdict(list) | ||
|
||
# TODO: move utils.configure_logging to here | ||
|
||
|
||
def filter_log_messages(data: dict) -> bool: | ||
"""Filter log messages based on the defined criteria. | ||
Args: | ||
data: The log message data from a loguru logger. | ||
Returns: | ||
bool: True if the log message should not be ignored, False otherwise. | ||
""" | ||
# TODO: ultimately, we want to fix the underlying issues, but for now, | ||
# we can ignore these messages | ||
for msg in config.MESSAGES_TO_FILTER: | ||
if msg in data["message"]: | ||
if config.MAX_NUM_WARNINGS_PER_SECOND > 0: | ||
current_timestamp = time.time() | ||
MESSAGE_TIMESTAMPS[msg].append(current_timestamp) | ||
timestamps = MESSAGE_TIMESTAMPS[msg] | ||
|
||
# Remove timestamps older than 1 second | ||
timestamps = [ | ||
ts | ||
for ts in timestamps | ||
if current_timestamp - ts <= config.WARNING_SUPPRESSION_PERIOD | ||
] | ||
|
||
if len(timestamps) > config.MAX_NUM_WARNINGS_PER_SECOND: | ||
return False | ||
|
||
MESSAGE_TIMESTAMPS[msg] = timestamps | ||
|
||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
"""Package for interacting with the OpenAdapt database.""" | ||
|
||
from .db import export_recording # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.