11import click
22
33from paperspace import commands
4+ from paperspace .constants import MULTI_NODE_TYPES
45
56
67class OptionRequiredIfMultinode (click .Option ):
78 def full_process_value (self , ctx , value ):
89 value = super (OptionRequiredIfMultinode , self ).full_process_value (ctx , value )
910
10- if value is None and ctx .params ["workercount " ] > 1 :
11- msg = "Required if --workerCount > 1"
11+ if value is None and ctx .params ["experimentTypeId " ] in MULTI_NODE_TYPES :
12+ msg = "Required if --experimentTypeId is one of: " + ", " . join ( * MULTI_NODE_TYPES )
1213 raise click .MissingParameter (ctx = ctx , param = self , message = msg )
1314
1415 return value
@@ -33,7 +34,8 @@ def experiments():
3334
3435@experiments .command ()
3536@click .option ("--name" , required = True )
36- @click .option ("--workerCount" , "workerCount" , required = True , type = int )
37+ @click .option ("--experimentTypeId" , "experimentTypeId" , type = int )
38+ @click .option ("--workerCount" , "workerCount" , required = True , type = int , cls = OptionRequiredIfMultinode )
3739@click .option ("--workerContainer" , "workerContainer" , cls = OptionRequiredIfMultinode )
3840@click .option ("--workerMachineType" , "workerMachineType" , cls = OptionRequiredIfMultinode )
3941@click .option ("--workerCommand" , "workerCommand" , cls = OptionRequiredIfMultinode )
@@ -48,7 +50,6 @@ def experiments():
4850@click .option ("--artifactDirectory" , "artifactDirectory" )
4951@click .option ("--clusterId" , "clusterId" , type = int )
5052# @click.option("--experimentEnv", type=dict)
51- @click .option ("--experimentTypeId" , "experimentTypeId" , type = int )
5253@click .option ("--workerContainerUser" , "workerContainerUser" )
5354@click .option ("--workerRegistryUsername" , "workerRegistryUsername" )
5455@click .option ("--workerRegistryPassword" , "workerRegistryPassword" )
0 commit comments