-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into video_inference_fps
- Loading branch information
Showing
10 changed files
with
158 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
certifi | ||
chardet==4.0.0 | ||
idna==3.7 | ||
cycler | ||
kiwisolver>=1.3.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import requests | ||
|
||
from roboflow.config import DEDICATED_DEPLOYMENT_URL | ||
|
||
|
||
class DeploymentApiError(Exception): | ||
pass | ||
|
||
|
||
def add_deployment(api_key, machine_type, deployment_name, inference_version): | ||
url = f"{DEDICATED_DEPLOYMENT_URL}/add" | ||
response = requests.post( | ||
url, | ||
json={ | ||
"api_key": api_key, | ||
# "security_level": security_level, | ||
"machine_type": machine_type, | ||
"deployment_name": deployment_name, | ||
"inference_version": inference_version, | ||
}, | ||
) | ||
if response.status_code != 200: | ||
raise DeploymentApiError(f"{response.status_code}: {response.text}") | ||
result = response.json() | ||
return result | ||
|
||
|
||
def get_deployment(api_key, deployment_id): | ||
url = f"{DEDICATED_DEPLOYMENT_URL}/get" | ||
response = requests.get(url, json={"api_key": api_key, "deployment_id": deployment_id}) | ||
if response.status_code != 200: | ||
raise DeploymentApiError(f"{response.status_code}: {response.text}") | ||
result = response.json() | ||
return result | ||
|
||
|
||
def list_deployment(api_key): | ||
url = f"{DEDICATED_DEPLOYMENT_URL}/list" | ||
response = requests.get(url, json={"api_key": api_key}) | ||
if response.status_code != 200: | ||
raise DeploymentApiError(f"{response.status_code}: {response.text}") | ||
result = response.json() | ||
return result | ||
|
||
|
||
def delete_deployment(api_key, deployment_id): | ||
url = f"{DEDICATED_DEPLOYMENT_URL}/delete" | ||
response = requests.post(url, json={"api_key": api_key, "deployment_id": deployment_id}) | ||
if response.status_code != 200: | ||
raise DeploymentApiError(f"{response.status_code}: {response.text}") | ||
result = response.json() | ||
return result | ||
|
||
|
||
def list_machine_types(api_key): | ||
url = f"{DEDICATED_DEPLOYMENT_URL}/machine_types" | ||
response = requests.get(url, json={"api_key": api_key}) | ||
if response.status_code != 200: | ||
raise DeploymentApiError(f"{response.status_code}: {response.text}") | ||
result = response.json() | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import json | ||
|
||
from roboflow.adapters import deploymentapi | ||
from roboflow.config import load_roboflow_api_key | ||
|
||
|
||
def add_deployment_parser(subparsers): | ||
deployment_parser = subparsers.add_parser( | ||
"deployment", | ||
help="deployment related commands. type 'roboflow deployment' to see detailed command help", | ||
) | ||
deployment_subparsers = deployment_parser.add_subparsers(title="deployment subcommands") | ||
deployment_machine_type_parser = deployment_subparsers.add_parser("machine_type", help="list machine types") | ||
deployment_add_parser = deployment_subparsers.add_parser("add", help="create a dedicated deployment") | ||
deployment_get_parser = deployment_subparsers.add_parser( | ||
"get", help="show detailed info for a dedicated deployment" | ||
) | ||
deployment_list_parser = deployment_subparsers.add_parser("list", help="list dedicated deployments in a workspace") | ||
deployment_delete_parser = deployment_subparsers.add_parser("delete", help="delete a dedicated deployment") | ||
|
||
deployment_machine_type_parser.set_defaults(func=list_machine_types) | ||
deployment_machine_type_parser.add_argument("-a", dest="api_key", help="api key") | ||
|
||
deployment_add_parser.set_defaults(func=add_deployment) | ||
deployment_add_parser.add_argument("-a", dest="api_key", help="api key") | ||
# deployment_add_parser.add_argument( | ||
# "-s", dest="security_level", help="security level (protected)", default="protected" | ||
# ) | ||
deployment_add_parser.add_argument( | ||
"-m", dest="machine_type", help="machine type, run `roboflow deployment machine_type` to see available options" | ||
) | ||
deployment_add_parser.add_argument( | ||
"-n", dest="deployment_name", help="deployment name, must contain 3-10 lowercase characters" | ||
) | ||
deployment_add_parser.add_argument( | ||
"-v", dest="inference_version", help="inference server version (default: latest)", default="latest" | ||
) | ||
|
||
deployment_get_parser.set_defaults(func=get_deployment) | ||
deployment_get_parser.add_argument("-a", dest="api_key", help="api key") | ||
deployment_get_parser.add_argument("-d", dest="deployment_id", help="deployment id") | ||
|
||
deployment_list_parser.set_defaults(func=list_deployment) | ||
deployment_list_parser.add_argument("-a", dest="api_key", help="api key") | ||
|
||
deployment_delete_parser.set_defaults(func=delete_deployment) | ||
deployment_delete_parser.add_argument("-a", dest="api_key", help="api key") | ||
deployment_delete_parser.add_argument("-d", dest="deployment_id", help="deployment id") | ||
|
||
|
||
def list_machine_types(args): | ||
api_key = args.api_key or load_roboflow_api_key(None) | ||
ret_json = deploymentapi.list_machine_types(api_key) | ||
print(json.dumps(ret_json, indent=2)) | ||
|
||
|
||
def add_deployment(args): | ||
api_key = args.api_key or load_roboflow_api_key(None) | ||
ret_json = deploymentapi.add_deployment( | ||
api_key, | ||
# args.security_level, | ||
args.machine_type, | ||
args.deployment_name, | ||
args.inference_version, | ||
) | ||
print(json.dumps(ret_json, indent=2)) | ||
|
||
|
||
def get_deployment(args): | ||
api_key = args.api_key or load_roboflow_api_key(None) | ||
ret_json = deploymentapi.get_deployment(api_key, args.deployment_id) | ||
print(json.dumps(ret_json, indent=2)) | ||
|
||
|
||
def list_deployment(args): | ||
api_key = args.api_key or load_roboflow_api_key(None) | ||
ret_json = deploymentapi.list_deployment(api_key) | ||
print(json.dumps(ret_json, indent=2)) | ||
|
||
|
||
def delete_deployment(args): | ||
api_key = args.api_key or load_roboflow_api_key(None) | ||
ret_json = deploymentapi.delete_deployment(api_key, args.deployment_id) | ||
print(json.dumps(ret_json, indent=2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters