6
6
import click
7
7
8
8
from paperspace import constants , client , config
9
- from paperspace .commands import experiments as experiments_commands , deployments as deployments_commands , machines as machines_commands
9
+ from paperspace .commands import experiments as experiments_commands , deployments as deployments_commands , \
10
+ machines as machines_commands
10
11
11
12
12
13
class ChoiceType (click .Choice ):
@@ -425,6 +426,7 @@ def create_deployment(api_key=None, **kwargs):
425
426
"api_key" ,
426
427
)
427
428
def get_deployments_list (api_key = None , ** kwargs ):
429
+ del_if_value_is_none (kwargs )
428
430
deployments_api = client .API (config .CONFIG_HOST , api_key = api_key )
429
431
command = deployments_commands .ListDeploymentsCommand (api = deployments_api )
430
432
command .execute (kwargs )
@@ -498,6 +500,7 @@ def delete_deployment(id, api_key=None):
498
500
command = deployments_commands .DeleteDeploymentCommand (api = deployments_api )
499
501
command .execute (id )
500
502
503
+
501
504
REGIONS_MAP = collections .OrderedDict (
502
505
(
503
506
("CA1" , constants .Region .CA1 ),
@@ -512,7 +515,12 @@ def machines_group():
512
515
pass
513
516
514
517
515
- @machines_group .command ("availability" )
518
+ check_machine_availability_help = "Get machine availability for the given region and machine type. " \
519
+ "Note: availability is only provided for the dedicated GPU machine types. " \
520
+ "Also, not all machine types are available in all regions"
521
+
522
+
523
+ @machines_group .command ("availability" , help = check_machine_availability_help )
516
524
@click .option (
517
525
"--region" ,
518
526
"region" ,
@@ -534,7 +542,14 @@ def check_machine_availability(region, machine_type, api_key):
534
542
command .execute (region , machine_type )
535
543
536
544
537
- @machines_group .command ("create" )
545
+ create_machine_help = "Create a new Paperspace virtual machine. If you are using an individual account, you will " \
546
+ "be assigned as the owner of the machine. If you are a team administrator, you must specify " \
547
+ "the user that should be assigned to the machine, either by specifing a user id, or by " \
548
+ "providing an email address, password, first name and last name for the creation of a new " \
549
+ "user on the team."
550
+
551
+
552
+ @machines_group .command ("create" , help = create_machine_help )
538
553
@click .option (
539
554
"--region" ,
540
555
"region" ,
@@ -660,7 +675,15 @@ def create_machine(api_key, **kwargs):
660
675
command .execute (kwargs )
661
676
662
677
663
- @machines_group .command ("destroy" )
678
+ destroy_machine_help = "Destroy the machine with the given id. When this action is performed, the machine is " \
679
+ "immediately shut down and marked for deletion from the datacenter. Any snapshots that " \
680
+ "were derived from the machine are also deleted. Access to the machine is terminated " \
681
+ "immediately and billing for the machine is prorated to the hour. This action can only " \
682
+ "be performed by the user who owns the machine, or in the case of a team, the team " \
683
+ "administrator."
684
+
685
+
686
+ @machines_group .command ("destroy" , help = destroy_machine_help )
664
687
@click .option (
665
688
"--machineId" ,
666
689
"machine_id" ,
@@ -680,7 +703,12 @@ def destroy_machine(machine_id, release_public_ip, api_key):
680
703
command .execute (machine_id , release_public_ip )
681
704
682
705
683
- @machines_group .command ("list" )
706
+ list_machines_help = "List information about all machines available to either the current authenticated user or " \
707
+ "the team, if the user belongs to a team. The list method takes an optional first argument " \
708
+ "to limit the returned machine objects."
709
+
710
+
711
+ @machines_group .command ("list" , help = list_machines_help )
684
712
@click .option (
685
713
"--params" ,
686
714
"params" ,
@@ -827,10 +855,16 @@ def list_machines(api_key, params, **kwargs):
827
855
command .execute (params or kwargs )
828
856
829
857
830
- @machines_group .command ("restart" )
858
+ restart_machine_help = "Restart an individual machine. If the machine is already restarting, this action will " \
859
+ "request the machine be restarted again. This action can only be performed by the user " \
860
+ "who owns the machine"
861
+
862
+
863
+ @machines_group .command ("restart" , help = restart_machine_help )
831
864
@click .option (
832
865
"--machineId" ,
833
866
"machine_id" ,
867
+ help = "Id of the machine to restart" ,
834
868
required = True ,
835
869
)
836
870
@api_key_option
@@ -844,6 +878,7 @@ def restart_machine(machine_id, api_key):
844
878
@click .option (
845
879
"--machineId" ,
846
880
"machine_id" ,
881
+ help = "Id of the machine to show" ,
847
882
required = True ,
848
883
)
849
884
@api_key_option
@@ -853,60 +888,75 @@ def show_machine_details(machine_id, api_key):
853
888
command .execute (machine_id )
854
889
855
890
856
- @machines_group .command ("update" )
891
+ update_machine_help = "Update attributes of a machine"
892
+
893
+
894
+ @machines_group .command ("update" , help = update_machine_help )
857
895
@click .option (
858
896
"--machineId" ,
859
897
"machine_id" ,
898
+ help = "Id of the machine to update" ,
860
899
required = True ,
861
900
)
862
901
@click .option (
863
902
"--machineName" ,
864
903
"machineName" ,
904
+ help = "New name for the machine" ,
865
905
)
866
906
@click .option (
867
907
"--shutdownTimeoutInHours" ,
868
908
"shutdownTimeoutInHours" ,
909
+ help = "Number of hours before machine is shutdown if no one is logged in via the Paperspace client" ,
869
910
type = int ,
870
911
)
871
912
@click .option (
872
913
"--shutdownTimeoutForces" ,
873
914
"shutdownTimeoutForces" ,
874
- is_flag = True ,
875
- default = None , # None is used so it can be filtered with `del_if_value_is_none` when flag was not set
915
+ help = "Force shutdown at shutdown timeout, even if there is a Paperspace client connection" ,
916
+ type = bool ,
876
917
)
877
918
@click .option (
878
919
"--performAutoSnapshot" ,
879
920
"performAutoSnapshot" ,
880
- is_flag = True ,
881
- default = None , # None is used so it can be filtered with `del_if_value_is_none` when flag was not set
921
+ help = "Perform auto snapshots" ,
922
+ type = bool ,
882
923
)
883
924
@click .option (
884
925
"--autoSnapshotFrequency" ,
885
926
"autoSnapshotFrequency" ,
927
+ help = "One of 'hour', 'day', 'week', or null" ,
886
928
type = click .Choice (["hour" , "day" , "week" ], case_sensitive = False ),
887
929
)
888
930
@click .option (
889
931
"--autoSnapshotSaveCount" ,
890
932
"autoSnapshotSaveCount" ,
933
+ help = "Number of snapshots to save" ,
891
934
type = int ,
892
935
)
893
936
@click .option (
894
937
"--dynamicPublicIp" ,
895
938
"dynamicPublicIp" ,
896
- is_flag = True ,
897
- default = None , # None is used so it can be filtered with `del_if_value_is_none` when flag was not set
939
+ help = "If true, assigns a new public ip address on machine start and releases it from the account on machine stop" ,
940
+ type = bool ,
898
941
)
899
942
@api_key_option
900
- def update_machine (api_key , ** kwargs ):
943
+ def update_machine (machine_id , api_key , ** kwargs ):
944
+ del_if_value_is_none (kwargs )
901
945
machines_api = client .API (config .CONFIG_HOST , api_key = api_key )
902
946
command = machines_commands .UpdateMachineCommand (api = machines_api )
903
- command .execute (kwargs )
947
+ command .execute (machine_id , kwargs )
904
948
905
949
906
- @machines_group .command ("start" )
950
+ start_machine_help = "Start up an individual machine. If the machine is already started, this action is a no-op. " \
951
+ "If the machine is off, it will be booted up. This action can only be performed by the user " \
952
+ "who owns the machine"
953
+
954
+
955
+ @machines_group .command ("start" , help = start_machine_help )
907
956
@click .option (
908
957
"--machineId" ,
909
958
"machine_id" ,
959
+ help = "Id of the machine to start" ,
910
960
required = True ,
911
961
)
912
962
@api_key_option
@@ -916,10 +966,16 @@ def start_machine(machine_id, api_key):
916
966
command .execute (machine_id )
917
967
918
968
919
- @machines_group .command ("stop" )
969
+ stop_machine_help = "Stop an individual machine. If the machine is already stopped or has been shut down, this " \
970
+ "action is a no-op. If the machine is running, it will be stopped and any users logged in " \
971
+ "will be immediately kicked out. This action can only be performed by the user who owns the machine"
972
+
973
+
974
+ @machines_group .command ("stop" , help = stop_machine_help )
920
975
@click .option (
921
976
"--machineId" ,
922
977
"machine_id" ,
978
+ help = "Id of the machine to start" ,
923
979
required = True ,
924
980
)
925
981
@api_key_option
@@ -929,10 +985,15 @@ def stop_machine(machine_id, api_key):
929
985
command .execute (machine_id )
930
986
931
987
932
- @machines_group .command ("utilization" )
988
+ show_machine_utilization_help = "Get machine utilization data for the machine with the given id. Machine upgrades " \
989
+ "are not represented in utilization data"
990
+
991
+
992
+ @machines_group .command ("utilization" , help = show_machine_utilization_help )
933
993
@click .option (
934
994
"--machineId" ,
935
995
"machine_id" ,
996
+ help = "Id of the machine to start" ,
936
997
required = True ,
937
998
)
938
999
@click .option (
@@ -948,15 +1009,22 @@ def show_machine_utilization(machine_id, billing_month, api_key):
948
1009
command .execute (machine_id , billing_month )
949
1010
950
1011
951
- @machines_group .command ("waitfor" )
1012
+ wait_for_machine_state_help = "Wait for the machine with the given id to enter a certain machine state. " \
1013
+ "This action polls the server and returns only when we detect that the machine " \
1014
+ "has transitioned into the given state."
1015
+
1016
+
1017
+ @machines_group .command ("waitfor" , help = wait_for_machine_state_help )
952
1018
@click .option (
953
1019
"--machineId" ,
954
1020
"machine_id" ,
1021
+ help = "Id of the machine to start" ,
955
1022
required = True ,
956
1023
)
957
1024
@click .option (
958
1025
"--state" ,
959
1026
"state" ,
1027
+ help = "Name of the state to wait for" ,
960
1028
type = click .Choice (["off" , "serviceready" , "ready" ], case_sensitive = False ),
961
1029
required = True ,
962
1030
)
0 commit comments