From 66aa98e84581619e3dfb118b9a23c7bf5e7656e2 Mon Sep 17 00:00:00 2001 From: Solomon Lake Giffen-Hunter Date: Thu, 7 Sep 2023 15:08:14 -0500 Subject: [PATCH] Add input continue warning for wrong ultralytics version in model deploy (#185) * Add input continue warning for wrong ultralytics version in model deploy * Put import sys in correct order in versions.py * Bump package version to 1.1.6 --- roboflow/__init__.py | 2 +- roboflow/core/version.py | 2 +- roboflow/util/versions.py | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/roboflow/__init__.py b/roboflow/__init__.py index 2ba06739..4e90da78 100644 --- a/roboflow/__init__.py +++ b/roboflow/__init__.py @@ -12,7 +12,7 @@ from roboflow.core.workspace import Workspace from roboflow.util.general import write_line -__version__ = "1.1.5" +__version__ = "1.1.6" def check_key(api_key, model, notebook, num_retries=0): diff --git a/roboflow/core/version.py b/roboflow/core/version.py index f0742fad..85d09cbe 100644 --- a/roboflow/core/version.py +++ b/roboflow/core/version.py @@ -490,7 +490,7 @@ def deploy(self, model_type: str, model_path: str) -> None: ) print_warn_for_wrong_dependencies_versions( - [("ultralytics", "==", "8.0.134")] + [("ultralytics", "==", "8.0.134")], ask_to_continue=True ) elif "yolov5" in model_type or "yolov7" in model_type: diff --git a/roboflow/util/versions.py b/roboflow/util/versions.py index fab46f06..f5c86359 100644 --- a/roboflow/util/versions.py +++ b/roboflow/util/versions.py @@ -1,3 +1,4 @@ +import sys from importlib import import_module from typing import List, Tuple @@ -42,13 +43,19 @@ def get_wrong_dependencies_versions( def print_warn_for_wrong_dependencies_versions( - dependencies_versions: List[Tuple[str, str, str]] + dependencies_versions: List[Tuple[str, str, str]], ask_to_continue: bool = False ): wrong_dependencies_versions = get_wrong_dependencies_versions(dependencies_versions) for dependency, order, version, module_version in wrong_dependencies_versions: print( f"Dependency {dependency}{order}{version} is required but found version={module_version}, to fix: `pip install {dependency}{order}{version}`" ) + if ask_to_continue: + answer = input( + f"Would you like to continue with the wrong version of {dependency}? y/n: " + ) + if answer.lower() != "y": + sys.exit(1) def warn_for_wrong_dependencies_versions(