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

Commit 48ac838

Browse files
committed
single/multi node depends on experimentTypeId
1 parent ae7f00a commit 48ac838

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

paperspace/cli.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import click
22

33
from paperspace import commands
4+
from paperspace.constants import MULTI_NODE_TYPES
45

56

67
class 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")

paperspace/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
EXPERIMENT_TYPE_SINGLE_NODE_ID = 1
2+
EXPERIMENT_TYPE_GRPC_MULTI_NODE_ID = 2
3+
EXPERIMENT_TYPE_MPI_MULTI_NODE_ID = 3
4+
5+
MULTI_NODE_TYPES = (EXPERIMENT_TYPE_GRPC_MULTI_NODE_ID, EXPERIMENT_TYPE_MPI_MULTI_NODE_ID)

0 commit comments

Comments
 (0)