Skip to content

Commit 7a80221

Browse files
Merge pull request #204 from roboflow/fix_projectID
Changed upload_dataset into taking project_id instead of project_name
2 parents 8864d37 + 9a4edcb commit 7a80221

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

roboflow/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from roboflow.models import CLIPModel, GazeModel
1414
from roboflow.util.general import write_line
1515

16-
__version__ = "1.1.10"
16+
__version__ = "1.1.11"
1717

1818

1919
def check_key(api_key, model, notebook, num_retries=0):

roboflow/core/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ def single_upload(
476476
is_prediction: bool = False,
477477
**kwargs,
478478
):
479+
project_url = self.id.rsplit("/")[1]
479480
if image_path and image_id:
480481
raise Exception("You can't pass both image_id and image_path")
481482
if not (image_path or image_id):
@@ -484,7 +485,6 @@ def single_upload(
484485
annotation_labelmap = load_labelmap(annotation_labelmap)
485486
uploaded_image, uploaded_annotation = None, None
486487
if image_path:
487-
project_url = self.id.rsplit("/")[1]
488488
uploaded_image = retry(
489489
num_retry_uploads,
490490
Exception,

roboflow/core/workspace.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ def projects(self):
6464

6565
return projects_array
6666

67-
def project(self, project_name):
67+
def project(self, project_id):
6868
"""
6969
Retrieve a Project() object that represents a project in the workspace.
7070
7171
This object can be used to retrieve the model through which to run inference.
7272
7373
Args:
74-
project_name (str): name of the project
74+
project_id (str): id of the project
7575
7676
Returns:
7777
Project Object
@@ -83,17 +83,17 @@ def project(self, project_name):
8383
if self.__api_key in DEMO_KEYS:
8484
return Project(self.__api_key, {}, self.model_format)
8585

86-
project_name = project_name.replace(self.url + "/", "")
86+
# project_id = project_id.replace(self.url + "/", "")
8787

88-
if "/" in project_name:
88+
if "/" in project_id:
8989
raise RuntimeError(
9090
"The {} project is not available in this ({}) workspace".format(
91-
project_name, self.url
91+
project_id, self.url
9292
)
9393
)
9494

9595
dataset_info = requests.get(
96-
API_URL + "/" + self.url + "/" + project_name + "?api_key=" + self.__api_key
96+
API_URL + "/" + self.url + "/" + project_id + "?api_key=" + self.__api_key
9797
)
9898

9999
# Throw error if dataset isn't valid/user doesn't have permissions to access the dataset
@@ -333,7 +333,7 @@ def _upload_dataset_auto(
333333
):
334334
parsed_dataset = folderparser.parsefolder(dataset_path)
335335
project, created = self._get_or_create_project(
336-
project_name, license=project_license, type=project_type
336+
project_id=project_name, license=project_license, type=project_type
337337
)
338338
if created:
339339
print(f"Created project {project.id}")
@@ -371,6 +371,7 @@ def _upload_image(imagedesc):
371371
image_path = f"{location}{imagedesc['file']}"
372372
split = imagedesc["split"]
373373
annotation_path = None
374+
labelmap = None
374375
annotationdesc = imagedesc.get("annotationfile")
375376
if annotationdesc:
376377
annotation_path = f"{location}{annotationdesc['file']}"
@@ -390,20 +391,17 @@ def _upload_image(imagedesc):
390391
list(executor.map(_upload_image, images))
391392

392393
def _get_or_create_project(
393-
self, project_name, license: str = "MIT", type: str = "object-detection"
394+
self, project_id, license: str = "MIT", type: str = "object-detection"
394395
):
395-
found_project = next(
396-
(p for p in self.project_list if p["name"] == project_name), None
397-
)
398-
if found_project:
399-
project_url = found_project["id"].split("/")[1]
400-
return self.project(project_url), False
401-
else:
396+
try:
397+
existing_project = self.project(project_id)
398+
return existing_project, False
399+
except RuntimeError:
402400
return (
403401
self.create_project(
404-
project_name,
402+
project_name=project_id,
405403
project_license=license,
406-
annotation=project_name,
404+
annotation=project_id,
407405
project_type=type,
408406
),
409407
True,
@@ -426,7 +424,6 @@ def _upload_dataset_legacy(
426424
raise Exception(
427425
"dataset_format not supported - please use voc, yolov8, yolov5. PS, you can always convert your dataset in the Roboflow UI"
428426
)
429-
430427
# check type stuff and convert
431428
if dataset_format == "yolov8" or dataset_format == "yolov5":
432429
# convert to voc

0 commit comments

Comments
 (0)