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

Commit 1751183

Browse files
committed
feat: Stream logs after an experiment is started.
1 parent bca44bb commit 1751183

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

paperspace/cli/experiments.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,30 +259,38 @@ def create_single_node(api_key, **kwargs):
259259
@create_and_start_experiment.command(name="multinode", help="Create and start new multi node experiment")
260260
@common_experiments_create_options
261261
@common_experiment_create_multi_node_options
262-
def create_and_start_multi_node(api_key, **kwargs):
262+
@click.pass_context
263+
def create_and_start_multi_node(ctx, api_key, **kwargs):
263264
del_if_value_is_none(kwargs)
264265
experiments_api = client.API(config.CONFIG_EXPERIMENTS_HOST, api_key=api_key)
265266
command = experiments_commands.CreateAndStartExperimentCommand(api=experiments_api)
266-
command.execute(kwargs)
267+
experiment = command.execute(kwargs)
268+
if experiment is not None:
269+
ctx.invoke(list_logs, experiment_id=experiment["handle"], line=0, limit=100, follow=True, api_key=api_key)
267270

268271

269272
@create_and_start_experiment.command(name="singlenode", help="Create and start new single node experiment")
270273
@common_experiments_create_options
271274
@common_experiments_create_single_node_options
272-
def create_and_start_single_node(api_key, **kwargs):
275+
@click.pass_context
276+
def create_and_start_single_node(ctx, api_key, **kwargs):
273277
kwargs["experimentTypeId"] = constants.ExperimentType.SINGLE_NODE
274278
del_if_value_is_none(kwargs)
275279
experiments_api = client.API(config.CONFIG_EXPERIMENTS_HOST, api_key=api_key)
276280
command = experiments_commands.CreateAndStartExperimentCommand(api=experiments_api)
277-
command.execute(kwargs)
281+
experiment = command.execute(kwargs)
282+
if experiment is not None:
283+
ctx.invoke(list_logs, experiment_id=experiment["handle"], line=0, limit=100, follow=True, api_key=api_key)
278284

279285

280286
@experiments.command("start", help="Start experiment")
281287
@click.argument("experiment-id")
282288
@api_key_option
283-
def start_experiment(experiment_id, api_key):
289+
@click.pass_context
290+
def start_experiment(ctx, experiment_id, api_key):
284291
experiments_api = client.API(config.CONFIG_EXPERIMENTS_HOST, api_key=api_key)
285292
experiments_commands.start_experiment(experiment_id, api=experiments_api)
293+
ctx.invoke(list_logs, experiment_id=experiment_id, line=0, limit=100, follow=True, api_key=api_key)
286294

287295

288296
@experiments.command("stop", help="Stop experiment")

0 commit comments

Comments
 (0)