Update Settings (#16610)
Signed-off-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
281ad050b7
commit
1413355364
2 changed files with 48 additions and 48 deletions
|
|
@ -170,7 +170,7 @@ def smart_request(method, url, retry=3, timeout=30, thread=True, code=-1, verbos
|
||||||
class Events:
|
class Events:
|
||||||
"""
|
"""
|
||||||
A class for collecting anonymous event analytics. Event analytics are enabled when sync=True in settings and
|
A class for collecting anonymous event analytics. Event analytics are enabled when sync=True in settings and
|
||||||
disabled when sync=False. Run 'yolo settings' to see and update settings YAML file.
|
disabled when sync=False. Run 'yolo settings' to see and update settings.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
url (str): The URL to send anonymous events.
|
url (str): The URL to send anonymous events.
|
||||||
|
|
|
||||||
|
|
@ -971,7 +971,7 @@ def threaded(func):
|
||||||
def set_sentry():
|
def set_sentry():
|
||||||
"""
|
"""
|
||||||
Initialize the Sentry SDK for error tracking and reporting. Only used if sentry_sdk package is installed and
|
Initialize the Sentry SDK for error tracking and reporting. Only used if sentry_sdk package is installed and
|
||||||
sync=True in settings. Run 'yolo settings' to see and update settings YAML file.
|
sync=True in settings. Run 'yolo settings' to see and update settings.
|
||||||
|
|
||||||
Conditions required to send errors (ALL conditions must be met or no errors will be reported):
|
Conditions required to send errors (ALL conditions must be met or no errors will be reported):
|
||||||
- sentry_sdk package is installed
|
- sentry_sdk package is installed
|
||||||
|
|
@ -983,36 +983,11 @@ def set_sentry():
|
||||||
- online environment
|
- online environment
|
||||||
- CLI used to run package (checked with 'yolo' as the name of the main CLI command)
|
- CLI used to run package (checked with 'yolo' as the name of the main CLI command)
|
||||||
|
|
||||||
The function also configures Sentry SDK to ignore KeyboardInterrupt and FileNotFoundError
|
The function also configures Sentry SDK to ignore KeyboardInterrupt and FileNotFoundError exceptions and to exclude
|
||||||
exceptions and to exclude events with 'out of memory' in their exception message.
|
events with 'out of memory' in their exception message.
|
||||||
|
|
||||||
Additionally, the function sets custom tags and user information for Sentry events.
|
Additionally, the function sets custom tags and user information for Sentry events.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
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, tb = 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
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
SETTINGS["sync"]
|
SETTINGS["sync"]
|
||||||
and RANK in {-1, 0}
|
and RANK in {-1, 0}
|
||||||
|
|
@ -1028,8 +1003,32 @@ def set_sentry():
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
sentry_sdk.init(
|
sentry_sdk.init(
|
||||||
dsn="https://5ff1556b71594bfea135ff0203a0d290@o4504521589325824.ingest.sentry.io/4504521592406016",
|
dsn="https://888e5a0778212e1d0314c37d4b9aae5d@o4504521589325824.ingest.us.sentry.io/4504521592406016",
|
||||||
debug=False,
|
debug=False,
|
||||||
traces_sample_rate=1.0,
|
traces_sample_rate=1.0,
|
||||||
release=__version__,
|
release=__version__,
|
||||||
|
|
@ -1170,25 +1169,26 @@ class SettingsManager(JSONDict):
|
||||||
self.file = Path(file)
|
self.file = Path(file)
|
||||||
self.version = version
|
self.version = version
|
||||||
self.defaults = {
|
self.defaults = {
|
||||||
"settings_version": version,
|
"settings_version": version, # Settings schema version
|
||||||
"datasets_dir": str(datasets_root / "datasets"),
|
"datasets_dir": str(datasets_root / "datasets"), # Datasets directory
|
||||||
"weights_dir": str(root / "weights"),
|
"weights_dir": str(root / "weights"), # Model weights directory
|
||||||
"runs_dir": str(root / "runs"),
|
"runs_dir": str(root / "runs"), # Experiment runs directory
|
||||||
"uuid": hashlib.sha256(str(uuid.getnode()).encode()).hexdigest(),
|
"uuid": hashlib.sha256(str(uuid.getnode()).encode()).hexdigest(), # SHA-256 anonymized UUID hash
|
||||||
"sync": True,
|
"sync": True, # Enable synchronization
|
||||||
"api_key": "",
|
"api_key": "", # Ultralytics API Key
|
||||||
"openai_api_key": "",
|
"openai_api_key": "", # OpenAI API Key
|
||||||
"clearml": True, # integrations
|
"clearml": True, # ClearML integration
|
||||||
"comet": True,
|
"comet": True, # Comet integration
|
||||||
"dvc": True,
|
"dvc": True, # DVC integration
|
||||||
"hub": True,
|
"hub": True, # Ultralytics HUB integration
|
||||||
"mlflow": True,
|
"mlflow": True, # MLflow integration
|
||||||
"neptune": True,
|
"neptune": True, # Neptune integration
|
||||||
"raytune": True,
|
"raytune": True, # Ray Tune integration
|
||||||
"tensorboard": True,
|
"tensorboard": True, # TensorBoard logging
|
||||||
"wandb": True,
|
"wandb": True, # Weights & Biases logging
|
||||||
"vscode_msg": True,
|
"vscode_msg": True, # VSCode messaging
|
||||||
}
|
}
|
||||||
|
|
||||||
self.help_msg = (
|
self.help_msg = (
|
||||||
f"\nView Ultralytics Settings with 'yolo settings' or at '{self.file}'"
|
f"\nView Ultralytics Settings with 'yolo settings' or at '{self.file}'"
|
||||||
"\nUpdate Settings with 'yolo settings key=value', i.e. 'yolo settings runs_dir=path/to/dir'. "
|
"\nUpdate Settings with 'yolo settings key=value', i.e. 'yolo settings runs_dir=path/to/dir'. "
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue