@@ -79,10 +79,20 @@ def upload_model(args):
79
79
rf = roboflow .Roboflow (args .api_key )
80
80
workspace = rf .workspace (args .workspace )
81
81
82
- # Deploy to specific version
83
- project = workspace .project (args .project )
84
- version = project .version (args .version_number )
85
- version .deploy (str (args .model_type ), str (args .model_path ), str (args .filename ))
82
+ if args .version_number is not None :
83
+ # Deploy to specific version
84
+ project = workspace .project (args .project )
85
+ version = project .version (args .version_number )
86
+ version .deploy (str (args .model_type ), str (args .model_path ), str (args .filename ))
87
+ else :
88
+ # Deploy to multiple projects
89
+ workspace .deploy_model (
90
+ model_type = str (args .model_type ),
91
+ model_path = str (args .model_path ),
92
+ project_ids = args .project ,
93
+ model_name = str (args .model_name ),
94
+ filename = str (args .filename ),
95
+ )
86
96
87
97
88
98
def list_projects (args ):
@@ -479,13 +489,15 @@ def _add_upload_model_parser(subparsers):
479
489
upload_model_parser .add_argument (
480
490
"-p" ,
481
491
dest = "project" ,
482
- help = "project_id to upload the model into" ,
492
+ action = "append" , # Allow multiple projects
493
+ help = "project_id to upload the model into (can be specified multiple times)" ,
483
494
)
484
495
upload_model_parser .add_argument (
485
496
"-v" ,
486
497
dest = "version_number" ,
487
498
type = int ,
488
- help = "version number to upload the model to" ,
499
+ help = "version number to upload the model to (optional)" ,
500
+ default = None ,
489
501
)
490
502
upload_model_parser .add_argument (
491
503
"-t" ,
@@ -503,6 +515,11 @@ def _add_upload_model_parser(subparsers):
503
515
default = "weights/best.pt" ,
504
516
help = "name of the model file" ,
505
517
)
518
+ upload_model_parser .add_argument (
519
+ "-n" ,
520
+ dest = "model_name" ,
521
+ help = "name of the model" ,
522
+ )
506
523
upload_model_parser .set_defaults (func = upload_model )
507
524
508
525
0 commit comments