Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit b3f2679

Browse files
committed
Add help messages for deployments
1 parent e211ed7 commit b3f2679

File tree

2 files changed

+46
-41
lines changed

2 files changed

+46
-41
lines changed

paperspace/cli.py

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -353,48 +353,52 @@ def get_experiment_details(experiment_handle, api_key):
353353
)
354354

355355

356-
@cli.group("deployments")
356+
@cli.group("deployments", help="Manage deployments")
357357
def deployments():
358358
pass
359359

360360

361-
@deployments.command("create")
361+
@deployments.command("create", help="Create new deployment")
362362
@click.option(
363363
"--deploymentType",
364364
"deploymentType",
365365
type=ChoiceType(DEPLOYMENT_TYPES_MAP, case_sensitive=False),
366366
required=True,
367+
help="Model deployment type",
367368
)
368369
@click.option(
369370
"--modelId",
370371
"modelId",
371372
required=True,
373+
help="ID of a trained model",
372374
)
373375
@click.option(
374376
"--name",
375377
"name",
376378
required=True,
379+
help="Human-friendly name for new model deployment",
377380
)
378381
@click.option(
379382
"--machineType",
380383
"machineType",
384+
type=click.Choice(constants.MACHINE_TYPES),
381385
required=True,
386+
help="Type of machine for new deployment",
382387
)
383388
@click.option(
384389
"--imageUrl",
385390
"imageUrl",
386391
required=True,
392+
help="Docker image for model serving",
387393
)
388394
@click.option(
389395
"--instanceCount",
390396
"instanceCount",
391397
type=int,
392398
required=True,
399+
help="Number of machine instances",
393400
)
394-
@click.option(
395-
"--apiKey",
396-
"api_key",
397-
)
401+
@api_key_option
398402
def create_deployment(api_key=None, **kwargs):
399403
del_if_value_is_none(kwargs)
400404
deployments_api = client.API(config.CONFIG_HOST, api_key=api_key)
@@ -415,90 +419,88 @@ def create_deployment(api_key=None, **kwargs):
415419
)
416420

417421

418-
@deployments.command("list")
422+
@deployments.command("list", help="List deployments with optional filtering")
419423
@click.option(
420424
"--state",
421425
"state",
422-
type=ChoiceType(DEPLOYMENT_STATES_MAP, case_sensitive=False)
423-
)
424-
@click.option(
425-
"--apiKey",
426-
"api_key",
426+
type=ChoiceType(DEPLOYMENT_STATES_MAP, case_sensitive=False),
427+
help="Filter by deployment state",
427428
)
429+
@api_key_option
428430
def get_deployments_list(api_key=None, **kwargs):
429431
del_if_value_is_none(kwargs)
430432
deployments_api = client.API(config.CONFIG_HOST, api_key=api_key)
431433
command = deployments_commands.ListDeploymentsCommand(api=deployments_api)
432434
command.execute(kwargs)
433435

434436

435-
@deployments.command("update")
437+
@deployments.command("update", help="Update deployment properties")
436438
@click.option(
437439
"--id",
438-
"id",
440+
"id_",
439441
required=True,
442+
help="Deployment ID",
440443
)
441444
@click.option(
442445
"--modelId",
443446
"modelId",
447+
help="ID of a trained model",
444448
)
445449
@click.option(
446450
"--name",
447451
"name",
452+
help="Human-friendly name for new model deployment",
448453
)
449454
@click.option(
450455
"--machineType",
451456
"machineType",
457+
help="Type of machine for new deployment",
452458
)
453459
@click.option(
454460
"--imageUrl",
455461
"imageUrl",
462+
help="Docker image for model serving",
456463
)
457464
@click.option(
458465
"--instanceCount",
459466
"instanceCount",
467+
type=int,
468+
help="Number of machine instances",
460469
)
461-
@click.option(
462-
"--apiKey",
463-
"api_key",
464-
)
465-
def update_deployment_model(id=None, api_key=None, **kwargs):
470+
@api_key_option
471+
def update_deployment_model(id_, api_key, **kwargs):
466472
del_if_value_is_none(kwargs)
467473
deployments_api = client.API(config.CONFIG_HOST, api_key=api_key)
468474
command = deployments_commands.UpdateModelCommand(api=deployments_api)
469-
command.execute(id, kwargs)
475+
command.execute(id_, kwargs)
470476

471477

472-
@deployments.command("start")
478+
@deployments.command("start", help="Start deployment")
473479
@click.option(
474480
"--id",
475-
"id",
481+
"id_",
476482
required=True,
483+
help="Deployment ID",
477484
)
478-
@click.option(
479-
"--apiKey",
480-
"api_key",
481-
)
482-
def start_deployment(id, api_key=None):
485+
@api_key_option
486+
def start_deployment(id_, api_key=None):
483487
deployments_api = client.API(config.CONFIG_HOST, api_key=api_key)
484488
command = deployments_commands.StartDeploymentCommand(api=deployments_api)
485-
command.execute(id)
489+
command.execute(id_)
486490

487491

488-
@deployments.command("delete")
492+
@deployments.command("delete", help="Delete deployment")
489493
@click.option(
490494
"--id",
491-
"id",
495+
"id_",
492496
required=True,
497+
help="Deployment ID",
493498
)
494-
@click.option(
495-
"--apiKey",
496-
"api_key",
497-
)
498-
def delete_deployment(id, api_key=None):
499+
@api_key_option
500+
def delete_deployment(id_, api_key=None):
499501
deployments_api = client.API(config.CONFIG_HOST, api_key=api_key)
500502
command = deployments_commands.DeleteDeploymentCommand(api=deployments_api)
501-
command.execute(id)
503+
command.execute(id_)
502504

503505

504506
REGIONS_MAP = collections.OrderedDict(
@@ -510,7 +512,7 @@ def delete_deployment(id, api_key=None):
510512
)
511513

512514

513-
@cli.group("machines")
515+
@cli.group("machines", help="Manage machines")
514516
def machines_group():
515517
pass
516518

@@ -874,7 +876,10 @@ def restart_machine(machine_id, api_key):
874876
command.execute(machine_id)
875877

876878

877-
@machines_group.command("show")
879+
show_machine_details_help = "Show machine information for the machine with the given id."
880+
881+
882+
@machines_group.command("show", help=show_machine_details_help)
878883
@click.option(
879884
"--machineId",
880885
"machine_id",

tests/functional/test_deployments.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TestDeploymentsCreate(object):
1818
"--deploymentType", "tfserving",
1919
"--modelId", "some_model_id",
2020
"--name", "some_name",
21-
"--machineType", "HAL9000",
21+
"--machineType", "Air",
2222
"--imageUrl", "https://www.latlmes.com/breaking/paperspace-now-has-a-100-bilion-valuation",
2323
"--instanceCount", "666",
2424
]
@@ -27,13 +27,13 @@ class TestDeploymentsCreate(object):
2727
"--deploymentType", "tfserving",
2828
"--modelId", "some_model_id",
2929
"--name", "some_name",
30-
"--machineType", "HAL9000",
30+
"--machineType", "Air",
3131
"--imageUrl", "https://www.latlmes.com/breaking/paperspace-now-has-a-100-bilion-valuation",
3232
"--instanceCount", "666",
3333
"--apiKey", "some_key",
3434
]
3535
BASIC_OPTIONS_REQUEST = {
36-
"machineType": u"HAL9000",
36+
"machineType": u"Air",
3737
"name": u"some_name",
3838
"imageUrl": u"https://www.latlmes.com/breaking/paperspace-now-has-a-100-bilion-valuation",
3939
"deploymentType": "Tensorflow Serving on K8s",

0 commit comments

Comments
 (0)