Skip to content

Commit a0cd6c6

Browse files
committed
adds model_name to workspace.deploy_model()
1 parent b3ab193 commit a0cd6c6

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

roboflow/core/workspace.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ def deploy_model(
574574
model_type: str,
575575
model_path: str,
576576
project_ids: list[str],
577+
model_name: str,
577578
filename: str = "weights/best.pt",
578579
):
579580
"""Uploads provided weights file to Roboflow.
@@ -599,12 +600,19 @@ def deploy_model(
599600
if zip_file_name is None:
600601
raise RuntimeError("Failed to process model")
601602

602-
self._upload_zip(model_type, model_path, project_ids, zip_file_name)
603+
self._upload_zip(model_type, model_path, project_ids, model_name, zip_file_name)
603604

604-
def _upload_zip(self, model_type: str, model_path: str, project_ids: list[str], model_file_name: str):
605+
def _upload_zip(
606+
self,
607+
model_type: str,
608+
model_path: str,
609+
project_ids: list[str],
610+
model_name: str,
611+
model_file_name: str,
612+
):
605613
# TODO: Need to create this endpoint
606614
res = requests.post(
607-
f"{API_URL}/{self.url}/uploadModel?api_key={self.__api_key}&modelType={model_type}&project_ids={','.join(project_ids)}&nocache=true"
615+
f"{API_URL}/{self.url}/uploadModel?api_key={self.__api_key}&modelType={model_type}&modelName={model_name}&projectIds={','.join(project_ids)}&nocache=true"
608616
)
609617
try:
610618
res.raise_for_status()

roboflow/roboflowpy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def upload_model(args):
9090
model_type=str(args.model_type),
9191
model_path=str(args.model_path),
9292
project_ids=args.project,
93+
model_name=str(args.model_name),
9394
filename=str(args.filename),
9495
)
9596

@@ -510,6 +511,11 @@ def _add_upload_model_parser(subparsers):
510511
default="weights/best.pt",
511512
help="name of the model file",
512513
)
514+
upload_model_parser.add_argument(
515+
"-n",
516+
dest="model_name",
517+
help="name of the model",
518+
)
513519
upload_model_parser.set_defaults(func=upload_model)
514520

515521

0 commit comments

Comments
 (0)