From d43fcecc8a2df47f79cf0c70d3e02ac5316cf41b Mon Sep 17 00:00:00 2001
From: Glenn Jocher <glenn.jocher@ultralytics.com>
Date: Mon, 20 Nov 2023 14:16:41 +0100
Subject: [PATCH] `ultralytics 8.0.214` Windows UTF-8 notebook fix (#6459)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jorge Torres <63155200+JorgeT42@users.noreply.github.com>
Co-authored-by: slxiu <121917717+slxiu@users.noreply.github.com>
---
 .github/dependabot.yml        |  2 +-
 .github/translate-readme.yml  | 26 -----------------------
 .github/workflows/ci.yaml     | 39 -----------------------------------
 tests/test_python.py          |  1 -
 ultralytics/__init__.py       |  2 +-
 ultralytics/utils/__init__.py | 21 ++++++++++++-------
 ultralytics/utils/checks.py   | 10 ++++++++-
 7 files changed, 25 insertions(+), 76 deletions(-)
 delete mode 100644 .github/translate-readme.yml

diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 6f391174..2d4ae318 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -16,7 +16,7 @@ updates:
       - dependencies
 
   - package-ecosystem: github-actions
-    directory: "/"
+    directory: "/.github/workflows"
     schedule:
       interval: weekly
       time: "04:00"
diff --git a/.github/translate-readme.yml b/.github/translate-readme.yml
deleted file mode 100644
index 102bba60..00000000
--- a/.github/translate-readme.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-# Ultralytics YOLO 🚀, AGPL-3.0 license
-# README translation action to translate README.md to Chinese as README.zh-CN.md on any change to README.md
-
-name: Translate README
-
-on:
-  push:
-    branches:
-      - translate_readme  # replace with 'main' to enable action
-    paths:
-      - README.md
-
-jobs:
-  Translate:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v3
-      - name: Setup Node.js
-        uses: actions/setup-node@v3
-        with:
-          node-version: 16
-      # ISO Language Codes: https://cloud.google.com/translate/docs/languages
-      - name: Adding README - Chinese Simplified
-        uses: dephraiim/translate-readme@main
-        with:
-          LANG: zh-CN
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 6b05e1c4..994522bd 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -56,14 +56,6 @@ jobs:
       - name: Check environment
         run: |
           yolo checks
-          echo "RUNNER_OS is ${{ runner.os }}"
-          echo "GITHUB_EVENT_NAME is ${{ github.event_name }}"
-          echo "GITHUB_WORKFLOW is ${{ github.workflow }}"
-          echo "GITHUB_ACTOR is ${{ github.actor }}"
-          echo "GITHUB_REPOSITORY is ${{ github.repository }}"
-          echo "GITHUB_REPOSITORY_OWNER is ${{ github.repository_owner }}"
-          python --version
-          pip --version
           pip list
       - name: Test HUB training
         shell: python
@@ -123,14 +115,6 @@ jobs:
       - name: Check environment
         run: |
           yolo checks
-          echo "RUNNER_OS is ${{ runner.os }}"
-          echo "GITHUB_EVENT_NAME is ${{ github.event_name }}"
-          echo "GITHUB_WORKFLOW is ${{ github.workflow }}"
-          echo "GITHUB_ACTOR is ${{ github.actor }}"
-          echo "GITHUB_REPOSITORY is ${{ github.repository }}"
-          echo "GITHUB_REPOSITORY_OWNER is ${{ github.repository_owner }}"
-          python --version
-          pip --version
           pip list
       #      - name: Benchmark DetectionModel
       #        shell: bash
@@ -191,14 +175,6 @@ jobs:
       - name: Check environment
         run: |
           yolo checks
-          echo "RUNNER_OS is ${{ runner.os }}"
-          echo "GITHUB_EVENT_NAME is ${{ github.event_name }}"
-          echo "GITHUB_WORKFLOW is ${{ github.workflow }}"
-          echo "GITHUB_ACTOR is ${{ github.actor }}"
-          echo "GITHUB_REPOSITORY is ${{ github.repository }}"
-          echo "GITHUB_REPOSITORY_OWNER is ${{ github.repository_owner }}"
-          python --version
-          pip --version
           pip list
       - name: Pytest tests
         shell: bash  # for Windows compatibility
@@ -228,14 +204,6 @@ jobs:
       - name: Check environment
         run: |
           yolo checks
-          echo "RUNNER_OS is ${{ runner.os }}"
-          echo "GITHUB_EVENT_NAME is ${{ github.event_name }}"
-          echo "GITHUB_WORKFLOW is ${{ github.workflow }}"
-          echo "GITHUB_ACTOR is ${{ github.actor }}"
-          echo "GITHUB_REPOSITORY is ${{ github.repository }}"
-          echo "GITHUB_REPOSITORY_OWNER is ${{ github.repository_owner }}"
-          python --version
-          pip --version
           pip list
       - name: Pytest tests
         run: pytest --cov=ultralytics/ --cov-report xml tests/test_cuda.py
@@ -276,13 +244,6 @@ jobs:
           pip install pytest 'coremltools>=7.0'
       - name: Check environment
         run: |
-          echo "RUNNER_OS is ${{ runner.os }}"
-          echo "GITHUB_EVENT_NAME is ${{ github.event_name }}"
-          echo "GITHUB_WORKFLOW is ${{ github.workflow }}"
-          echo "GITHUB_ACTOR is ${{ github.actor }}"
-          echo "GITHUB_REPOSITORY is ${{ github.repository }}"
-          echo "GITHUB_REPOSITORY_OWNER is ${{ github.repository_owner }}"
-          python --version
           conda list
       - name: Test CLI
         run: |
diff --git a/tests/test_python.py b/tests/test_python.py
index 83ee6596..20e9a4fd 100644
--- a/tests/test_python.py
+++ b/tests/test_python.py
@@ -155,7 +155,6 @@ def test_track_stream():
     import yaml
 
     model = YOLO(MODEL)
-    model.predict('https://youtu.be/G17sBkb38XQ', imgsz=96, save=True)
     model.track('https://ultralytics.com/assets/decelera_portrait_min.mov', imgsz=160, tracker='bytetrack.yaml')
     model.track('https://ultralytics.com/assets/decelera_portrait_min.mov', imgsz=160, tracker='botsort.yaml')
 
diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py
index 26699e6b..d1d88723 100644
--- a/ultralytics/__init__.py
+++ b/ultralytics/__init__.py
@@ -1,6 +1,6 @@
 # Ultralytics YOLO 🚀, AGPL-3.0 license
 
-__version__ = '8.0.213'
+__version__ = '8.0.214'
 
 from ultralytics.models import RTDETR, SAM, YOLO
 from ultralytics.models.fastsam import FastSAM
diff --git a/ultralytics/utils/__init__.py b/ultralytics/utils/__init__.py
index 0f02736c..b4cd96ca 100644
--- a/ultralytics/utils/__init__.py
+++ b/ultralytics/utils/__init__.py
@@ -229,8 +229,15 @@ def set_logging(name=LOGGING_NAME, verbose=True):
     level = logging.INFO if verbose and RANK in {-1, 0} else logging.ERROR  # rank in world for Multi-GPU trainings
 
     # Configure the console (stdout) encoding to UTF-8
-    if WINDOWS:  # for Windows
-        sys.stdout.reconfigure(encoding='utf-8')
+    if WINDOWS and sys.stdout.encoding != 'utf-8':
+        try:
+            if hasattr(sys.stdout, 'reconfigure'):
+                sys.stdout.reconfigure(encoding='utf-8')
+            else:
+                import io
+                sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
+        except Exception as e:
+            print(f'ERROR setting UTF-8 encoding: {e}')
 
     # Create and configure the StreamHandler
     stream_handler = logging.StreamHandler(sys.stdout)
@@ -501,14 +508,14 @@ def is_pytest_running():
     return ('PYTEST_CURRENT_TEST' in os.environ) or ('pytest' in sys.modules) or ('pytest' in Path(sys.argv[0]).stem)
 
 
-def is_github_actions_ci() -> bool:
+def is_github_action_running() -> bool:
     """
-    Determine if the current environment is a GitHub Actions CI Python runner.
+    Determine if the current environment is a GitHub Actions runner.
 
     Returns:
-        (bool): True if the current environment is a GitHub Actions CI Python runner, False otherwise.
+        (bool): True if the current environment is a GitHub Actions runner, False otherwise.
     """
-    return 'GITHUB_ACTIONS' in os.environ and 'RUNNER_OS' in os.environ and 'RUNNER_TOOL_CACHE' in os.environ
+    return 'GITHUB_ACTIONS' in os.environ and 'GITHUB_WORKFLOW' in os.environ and 'RUNNER_OS' in os.environ
 
 
 def is_git_dir():
@@ -913,7 +920,7 @@ WEIGHTS_DIR = Path(SETTINGS['weights_dir'])  # global weights directory
 RUNS_DIR = Path(SETTINGS['runs_dir'])  # global runs directory
 ENVIRONMENT = 'Colab' if is_colab() else 'Kaggle' if is_kaggle() else 'Jupyter' if is_jupyter() else \
     'Docker' if is_docker() else platform.system()
-TESTS_RUNNING = is_pytest_running() or is_github_actions_ci()
+TESTS_RUNNING = is_pytest_running() or is_github_action_running()
 set_sentry()
 
 # Apply monkey patches
diff --git a/ultralytics/utils/checks.py b/ultralytics/utils/checks.py
index 9aaf5f4f..e830978f 100644
--- a/ultralytics/utils/checks.py
+++ b/ultralytics/utils/checks.py
@@ -23,7 +23,7 @@ from matplotlib import font_manager
 
 from ultralytics.utils import (ASSETS, AUTOINSTALL, LINUX, LOGGER, ONLINE, ROOT, USER_CONFIG_DIR, SimpleNamespace,
                                ThreadingLocked, TryExcept, clean_url, colorstr, downloads, emojis, is_colab, is_docker,
-                               is_jupyter, is_kaggle, is_online, is_pip_package, url2file)
+                               is_github_action_running, is_jupyter, is_kaggle, is_online, is_pip_package, url2file)
 
 
 def parse_requirements(file_path=ROOT.parent / 'requirements.txt', package=''):
@@ -552,6 +552,14 @@ def collect_system_info():
             is_met = '❌ '
         LOGGER.info(f'{r.name:<20}{is_met}{current}{r.specifier}')
 
+    if is_github_action_running():
+        LOGGER.info(f"\nRUNNER_OS: {os.getenv('RUNNER_OS')}\n"
+                    f"GITHUB_EVENT_NAME: {os.getenv('GITHUB_EVENT_NAME')}\n"
+                    f"GITHUB_WORKFLOW: {os.getenv('GITHUB_WORKFLOW')}\n"
+                    f"GITHUB_ACTOR: {os.getenv('GITHUB_ACTOR')}\n"
+                    f"GITHUB_REPOSITORY: {os.getenv('GITHUB_REPOSITORY')}\n"
+                    f"GITHUB_REPOSITORY_OWNER: {os.getenv('GITHUB_REPOSITORY_OWNER')}\n")
+
 
 def check_amp(model):
     """