Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Versionless model deploy/upload #356

Merged
merged 7 commits into from
Jan 31, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adds the ability of specific n projects and make the version option o…
…n models cli upload
lrosemberg committed Jan 28, 2025
commit bce71bce00cad7dd831cfd7491d173d6033ffc12
29 changes: 23 additions & 6 deletions roboflow/roboflowpy.py
Original file line number Diff line number Diff line change
@@ -79,10 +79,20 @@ def upload_model(args):
rf = roboflow.Roboflow(args.api_key)
workspace = rf.workspace(args.workspace)

# 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))
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_ids=args.project,
model_name=str(args.model_name),
filename=str(args.filename),
)


def list_projects(args):
@@ -479,13 +489,15 @@ 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",
help="version number to upload the model to (optional)",
default=None,
)
upload_model_parser.add_argument(
"-t",
@@ -503,6 +515,11 @@ def _add_upload_model_parser(subparsers):
default="weights/best.pt",
help="name of the model file",
)
upload_model_parser.add_argument(
"-n",
dest="model_name",
help="name of the model",
)
upload_model_parser.set_defaults(func=upload_model)