Skip to content

Commit

Permalink
accept model without version in cli
Browse files Browse the repository at this point in the history
  • Loading branch information
lrosemberg committed Dec 16, 2024
1 parent 4477641 commit ae820ac
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions roboflow/roboflowpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,20 @@ def upload_image(args):
def upload_model(args):
rf = roboflow.Roboflow(args.api_key)
workspace = rf.workspace(args.workspace)
project = workspace.project(args.project)
version = project.version(args.version_number)
print(args.model_type, args.model_path, args.filename)
version.deploy(str(args.model_type), str(args.model_path), str(args.filename))

if args.version_number is not None:
# Deploy to specific version
project = workspace.project(args.project)
version = project.version(args.version_number)
version.deploy(str(args.model_type), str(args.model_path), str(args.filename))
else:
# Deploy to multiple projects
workspace.deploy_model(
model_type=str(args.model_type),
model_path=str(args.model_path),
project_urls=args.project,
filename=str(args.filename),
)


def list_projects(args):
Expand Down Expand Up @@ -478,13 +488,11 @@ def _add_upload_model_parser(subparsers):
upload_model_parser.add_argument(
"-p",
dest="project",
help="project_id to upload the model into",
action="append", # Allow multiple projects
help="project_id to upload the model into (can be specified multiple times)",
)
upload_model_parser.add_argument(
"-v",
dest="version_number",
type=int,
help="version number to upload the model to",
"-v", dest="version_number", type=int, help="version number to upload the model to (optional)", default=None
)
upload_model_parser.add_argument(
"-t",
Expand Down

0 comments on commit ae820ac

Please sign in to comment.