From e9ab157330236ddcacb2421943760c5698cc2e21 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 23 Jan 2023 04:30:50 +0100 Subject: [PATCH] DDP config error fix (#578) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- ultralytics/yolo/utils/__init__.py | 11 ++++++----- ultralytics/yolo/utils/dist.py | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ultralytics/yolo/utils/__init__.py b/ultralytics/yolo/utils/__init__.py index 4f1dab1..efcc80c 100644 --- a/ultralytics/yolo/utils/__init__.py +++ b/ultralytics/yolo/utils/__init__.py @@ -446,18 +446,19 @@ def set_sentry(): """ def before_send(event, hint): - if is_git_dir() and get_git_origin_url() != "https://github.com/ultralytics/ultralytics.git": - return None - event_os = 'colab' if is_colab() else 'kaggle' if is_kaggle() else 'jupyter' if is_jupyter() else \ + oss = 'colab' if is_colab() else 'kaggle' if is_kaggle() else 'jupyter' if is_jupyter() else \ 'docker' if is_docker() else platform.system() event['tags'] = { "sys_argv": sys.argv[0], "sys_argv_name": Path(sys.argv[0]).name, "install": 'git' if is_git_dir() else 'pip' if is_pip_package() else 'other', - "os": event_os} + "os": oss} return event - if SETTINGS['sync'] and not is_pytest_running() or is_github_actions_ci(): + if SETTINGS['sync'] and \ + not is_pytest_running() and \ + not is_github_actions_ci() and \ + (is_pip_package() or get_git_origin_url() == "https://github.com/ultralytics/ultralytics.git"): import sentry_sdk # noqa import ultralytics diff --git a/ultralytics/yolo/utils/dist.py b/ultralytics/yolo/utils/dist.py index d5873a4..d380535 100644 --- a/ultralytics/yolo/utils/dist.py +++ b/ultralytics/yolo/utils/dist.py @@ -28,10 +28,10 @@ def generate_ddp_file(trainer): if not trainer.resume: shutil.rmtree(trainer.save_dir) # remove the save_dir - content = f'''config = {vars(trainer.args)} \nif __name__ == "__main__": + content = f'''cfg = {vars(trainer.args)} \nif __name__ == "__main__": from ultralytics.{import_path} import {trainer.__class__.__name__} - trainer = {trainer.__class__.__name__}(config=config) + trainer = {trainer.__class__.__name__}(cfg=cfg) trainer.train()''' (USER_CONFIG_DIR / 'DDP').mkdir(exist_ok=True) with tempfile.NamedTemporaryFile(prefix="_temp_",