Skip to content

Commit 77f87b4

Browse files
author
maddogghoek
committed
- Improve error handling and reporting around project name
- Allow mulitple images to be uploaded in a single upload command - Improve upload command documentation
1 parent 1dd0500 commit 77f87b4

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

roboflow/core/workspace.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ def project(self, project_id):
8686
if self.__api_key in DEMO_KEYS:
8787
return Project(self.__api_key, {}, self.model_format)
8888

89-
# project_id = project_id.replace(self.url + "/", "")
89+
if not project_id:
90+
raise RuntimeError(f"Project id is required but none was specified.")
9091

9192
if "/" in project_id:
92-
raise RuntimeError(f"The {project_id} project is not available in this ({self.url}) workspace")
93+
raise RuntimeError(f"{project_id=} cannot contain a '/', use workspace argument to change the URL.")
9394

9495
dataset_info = rfapi.get_project(self.__api_key, self.url, project_id)
9596
dataset_info = dataset_info["project"]

roboflow/roboflowpy.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,18 @@ def upload_image(args):
7272
rf = roboflow.Roboflow()
7373
workspace = rf.workspace(args.workspace)
7474
project = workspace.project(args.project)
75-
project.single_upload(
76-
image_path=args.imagefile,
77-
annotation_path=args.annotation,
78-
annotation_labelmap=args.labelmap,
79-
split=args.split,
80-
num_retry_uploads=args.num_retries,
81-
batch_name=args.batch,
82-
tag_names=args.tag_names.split(",") if args.tag_names else [],
83-
is_prediction=args.is_prediction,
84-
)
75+
tag_names = args.tag_names.split(",") if args.tag_names else []
76+
for image_path in args.imagefile:
77+
project.single_upload(
78+
image_path=image_path,
79+
annotation_path=args.annotation,
80+
annotation_labelmap=args.labelmap,
81+
split=args.split,
82+
num_retry_uploads=args.num_retries,
83+
batch_name=args.batch,
84+
tag_names=tag_names,
85+
is_prediction=args.is_prediction,
86+
)
8587

8688

8789
def upload_model(args):
@@ -263,10 +265,11 @@ def _add_download_parser(subparsers):
263265

264266

265267
def _add_upload_parser(subparsers):
266-
upload_parser = subparsers.add_parser("upload", help="Upload a single image to a dataset")
268+
upload_parser = subparsers.add_parser("upload", help="Upload one or more images to a dataset")
267269
upload_parser.add_argument(
268270
"imagefile",
269-
help="path to image file",
271+
nargs="+",
272+
help="path to one or more image files to upload",
270273
)
271274
upload_parser.add_argument(
272275
"-w",
@@ -276,7 +279,8 @@ def _add_upload_parser(subparsers):
276279
upload_parser.add_argument(
277280
"-p",
278281
dest="project",
279-
help="project_id to upload the image into",
282+
required=True,
283+
help="project_id to upload the image into (required)",
280284
)
281285
upload_parser.add_argument(
282286
"-a",

0 commit comments

Comments
 (0)