Skip to content

Commit 79c7013

Browse files
Merge pull request #198 from roboflow/feature/bump_ultralitics_pin
Suggest users new version of ultralytics package
2 parents 0d1527a + 4feaf95 commit 79c7013

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

roboflow/core/version.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ def __init__(
7474
else:
7575
self.__api_key = api_key
7676
self.name = name
77-
78-
# FIXME: the version argument is inconsistently passed into this object.
79-
# Sometimes it is passed as: test-workspace/test-project/2
80-
# Other times, it is passed as: 2
81-
self.version = version
77+
self.version = unwrap_version_id(version_id=version)
8278
self.type = type
8379
self.augmentation = version_dict["augmentation"]
8480
self.created = version_dict["created"]
@@ -139,7 +135,6 @@ def __check_if_generating(self):
139135
url = f"{API_URL}/{self.workspace}/{self.project}/{self.version}?nocache=true"
140136
response = requests.get(url, params={"api_key": self.__api_key})
141137
response.raise_for_status()
142-
143138
if response.json()["version"]["progress"] == None:
144139
progress = 0.0
145140
else:
@@ -197,11 +192,11 @@ def download(self, model_format=None, location=None, overwrite: bool = True):
197192
try:
198193
import_module("ultralytics")
199194
print_warn_for_wrong_dependencies_versions(
200-
[("ultralytics", "==", "8.0.134")]
195+
[("ultralytics", "==", "8.0.196")]
201196
)
202197
except ImportError as e:
203198
print(
204-
"[WARNING] we noticed you are downloading a `yolov8` datasets but you don't have `ultralytics` installed. Roboflow `.deploy` supports only models trained with `ultralytics==8.0.134`, to intall it `pip install ultralytics==8.0.134`."
199+
"[WARNING] we noticed you are downloading a `yolov8` datasets but you don't have `ultralytics` installed. Roboflow `.deploy` supports only models trained with `ultralytics==8.0.196`, to intall it `pip install ultralytics==8.0.196`."
205200
)
206201
# silently fail
207202
pass
@@ -460,7 +455,7 @@ def live_plot(epochs, mAP, loss, title=""):
460455
# return the model object
461456
return self.model
462457

463-
# @warn_for_wrong_dependencies_versions([("ultralytics", "==", "8.0.134")])
458+
# @warn_for_wrong_dependencies_versions([("ultralytics", "==", "8.0.196")])
464459
def deploy(self, model_type: str, model_path: str) -> None:
465460
"""Uploads provided weights file to Roboflow
466461
@@ -490,7 +485,7 @@ def deploy(self, model_type: str, model_path: str) -> None:
490485
)
491486

492487
print_warn_for_wrong_dependencies_versions(
493-
[("ultralytics", "==", "8.0.134")], ask_to_continue=True
488+
[("ultralytics", "==", "8.0.196")], ask_to_continue=True
494489
)
495490

496491
elif "yolov5" in model_type or "yolov7" in model_type:
@@ -775,7 +770,7 @@ def data_yaml_callback(content: dict) -> dict:
775770
try:
776771
# get_wrong_dependencies_versions raises exception if ultralytics is not installed at all
777772
if format == "yolov8" and not get_wrong_dependencies_versions(
778-
dependencies_versions=[("ultralytics", "==", "8.0.134")]
773+
dependencies_versions=[("ultralytics", "==", "8.0.196")]
779774
):
780775
content["train"] = "train/images"
781776
content["val"] = "valid/images"
@@ -802,3 +797,7 @@ def __str__(self):
802797
"workspace": self.workspace,
803798
}
804799
return json.dumps(json_value, indent=2)
800+
801+
802+
def unwrap_version_id(version_id: str) -> str:
803+
return version_id if "/" not in str(version_id) else version_id.split("/")[-1]

tests/test_version.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from unittest.mock import patch
77

88
from .helpers import get_version
9-
from roboflow.core.version import Version
9+
from roboflow.core.version import Version, unwrap_version_id
1010

1111

1212
class TestDownload(unittest.TestCase):
@@ -168,3 +168,19 @@ def test_raises_runtime_error_if_model_format_is_none(self):
168168
self.version.model_format = None
169169
with self.assertRaises(RuntimeError):
170170
self.get_format_identifier(None)
171+
172+
173+
def test_unwrap_version_id_when_full_identifier_is_given() -> None:
174+
# when
175+
result = unwrap_version_id(version_id="some-workspace/some-project/3")
176+
177+
# then
178+
assert result == "3"
179+
180+
181+
def test_unwrap_version_id_when_only_version_id_is_given() -> None:
182+
# when
183+
result = unwrap_version_id(version_id="3")
184+
185+
# then
186+
assert result == "3"

0 commit comments

Comments
 (0)