Ultralytics Code Refactor https://ultralytics.com/actions (#16712)
Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
73e6861d95
commit
830e8334d7
18 changed files with 99 additions and 99 deletions
|
|
@ -989,55 +989,56 @@ def set_sentry():
|
|||
Additionally, the function sets custom tags and user information for Sentry events.
|
||||
"""
|
||||
if (
|
||||
SETTINGS["sync"]
|
||||
and RANK in {-1, 0}
|
||||
and Path(ARGV[0]).name == "yolo"
|
||||
and not TESTS_RUNNING
|
||||
and ONLINE
|
||||
and IS_PIP_PACKAGE
|
||||
and not IS_GIT_DIR
|
||||
not SETTINGS["sync"]
|
||||
or RANK not in {-1, 0}
|
||||
or Path(ARGV[0]).name != "yolo"
|
||||
or TESTS_RUNNING
|
||||
or not ONLINE
|
||||
or not IS_PIP_PACKAGE
|
||||
or IS_GIT_DIR
|
||||
):
|
||||
# If sentry_sdk package is not installed then return and do not use Sentry
|
||||
try:
|
||||
import sentry_sdk # noqa
|
||||
except ImportError:
|
||||
return
|
||||
return
|
||||
# If sentry_sdk package is not installed then return and do not use Sentry
|
||||
try:
|
||||
import sentry_sdk # noqa
|
||||
except ImportError:
|
||||
return
|
||||
|
||||
def before_send(event, hint):
|
||||
"""
|
||||
Modify the event before sending it to Sentry based on specific exception types and messages.
|
||||
def before_send(event, hint):
|
||||
"""
|
||||
Modify the event before sending it to Sentry based on specific exception types and messages.
|
||||
|
||||
Args:
|
||||
event (dict): The event dictionary containing information about the error.
|
||||
hint (dict): A dictionary containing additional information about the error.
|
||||
Args:
|
||||
event (dict): The event dictionary containing information about the error.
|
||||
hint (dict): A dictionary containing additional information about the error.
|
||||
|
||||
Returns:
|
||||
dict: The modified event or None if the event should not be sent to Sentry.
|
||||
"""
|
||||
if "exc_info" in hint:
|
||||
exc_type, exc_value, _ = hint["exc_info"]
|
||||
if exc_type in {KeyboardInterrupt, FileNotFoundError} or "out of memory" in str(exc_value):
|
||||
return None # do not send event
|
||||
Returns:
|
||||
dict: The modified event or None if the event should not be sent to Sentry.
|
||||
"""
|
||||
if "exc_info" in hint:
|
||||
exc_type, exc_value, _ = hint["exc_info"]
|
||||
if exc_type in {KeyboardInterrupt, FileNotFoundError} or "out of memory" in str(exc_value):
|
||||
return None # do not send event
|
||||
|
||||
event["tags"] = {
|
||||
"sys_argv": ARGV[0],
|
||||
"sys_argv_name": Path(ARGV[0]).name,
|
||||
"install": "git" if IS_GIT_DIR else "pip" if IS_PIP_PACKAGE else "other",
|
||||
"os": ENVIRONMENT,
|
||||
}
|
||||
return event
|
||||
event["tags"] = {
|
||||
"sys_argv": ARGV[0],
|
||||
"sys_argv_name": Path(ARGV[0]).name,
|
||||
"install": "git" if IS_GIT_DIR else "pip" if IS_PIP_PACKAGE else "other",
|
||||
"os": ENVIRONMENT,
|
||||
}
|
||||
return event
|
||||
|
||||
sentry_sdk.init(
|
||||
dsn="https://888e5a0778212e1d0314c37d4b9aae5d@o4504521589325824.ingest.us.sentry.io/4504521592406016",
|
||||
debug=False,
|
||||
auto_enabling_integrations=False,
|
||||
traces_sample_rate=1.0,
|
||||
release=__version__,
|
||||
environment="production", # 'dev' or 'production'
|
||||
before_send=before_send,
|
||||
ignore_errors=[KeyboardInterrupt, FileNotFoundError],
|
||||
)
|
||||
sentry_sdk.set_user({"id": SETTINGS["uuid"]}) # SHA-256 anonymized UUID hash
|
||||
sentry_sdk.init(
|
||||
dsn="https://888e5a0778212e1d0314c37d4b9aae5d@o4504521589325824.ingest.us.sentry.io/4504521592406016",
|
||||
debug=False,
|
||||
auto_enabling_integrations=False,
|
||||
traces_sample_rate=1.0,
|
||||
release=__version__,
|
||||
environment="production", # 'dev' or 'production'
|
||||
before_send=before_send,
|
||||
ignore_errors=[KeyboardInterrupt, FileNotFoundError],
|
||||
)
|
||||
sentry_sdk.set_user({"id": SETTINGS["uuid"]}) # SHA-256 anonymized UUID hash
|
||||
|
||||
|
||||
class JSONDict(dict):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue