Skip to content

Commit

Permalink
chore: report ntsc names via cli at launch (#9228)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidzr authored May 15, 2024
1 parent 93c8d81 commit 7bce6ff
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
6 changes: 5 additions & 1 deletion e2e_tests/tests/command/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self, process: subprocess.Popen, detach: bool = False):
self.process = process
self.detach = detach
self.task_id = None # type: Optional[str]
self.task_name: Optional[str] = None

if self.detach:
iterator = iter(self.process.stdout) # type: ignore
Expand All @@ -29,9 +30,12 @@ def __init__(self, process: subprocess.Popen, detach: bool = False):
while not m and iterations < max_iterations:
line = next(iterator)
iterations += 1
m = re.search(rb"Launched .* \(id: (.*)\)", line)
m = re.search(rb"Launched .* \(id: (.*), name: (.*)\)", line)
assert m is not None
self.task_id = m.group(1).decode() if m else None
self.task_name = m.group(2).decode() if m else None
assert self.task_id is not None, "Task ID could not be found"
assert self.task_name is not None, "Task name could not be found"

@property
def stdout(self) -> Iterator[str]:
Expand Down
12 changes: 7 additions & 5 deletions harness/determined/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from determined import cli
from determined.cli import ntsc, render, task, workspace
from determined.common import api
from determined.common.api import bindings


def run_command(args: argparse.Namespace) -> None:
Expand All @@ -21,22 +22,23 @@ def run_command(args: argparse.Namespace) -> None:
context_path=args.context,
includes=args.include,
workspace_id=workspace_id,
)["command"]
)
cmd = bindings.v1LaunchCommandResponse.from_json(resp).command

if args.detach:
print(resp["id"])
print(cmd.id)
return

render.report_job_launched("command", resp["id"])
render.report_job_launched("command", cmd.id, cmd.description)

try:
logs = api.task_logs(sess, resp["id"], follow=True)
logs = api.task_logs(sess, cmd.id, follow=True)
api.pprint_logs(logs)
finally:
print(
termcolor.colored(
"Task log stream ended. To reopen log stream, run: "
"det task logs -f {}".format(resp["id"]),
"det task logs -f {}".format(cmd.id),
"green",
)
)
Expand Down
2 changes: 1 addition & 1 deletion harness/determined/cli/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def start_notebook(args: argparse.Namespace) -> None:
print(nb.id)
return

render.report_job_launched("notebook", resp.notebook.id)
render.report_job_launched("notebook", resp.notebook.id, nb.description)

if resp.warnings:
cli.print_launch_warnings(resp.warnings)
Expand Down
4 changes: 2 additions & 2 deletions harness/determined/cli/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ def print_json(data: Union[str, Any]) -> None:
print(data)


def report_job_launched(_type: str, _id: str) -> None:
msg = f"Launched {_type} (id: {_id})."
def report_job_launched(_type: str, _id: str, name: str) -> None:
msg = f"Launched {_type} (id: {_id}, name: {name})."
print(termcolor.colored(msg, "green"))


Expand Down
11 changes: 4 additions & 7 deletions harness/determined/cli/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,14 @@ def start_shell(args: argparse.Namespace) -> None:
includes=args.include,
data=data,
workspace_id=workspace_id,
)["shell"]

sid = resp["id"]
)
shell = bindings.v1LaunchShellResponse.from_json(resp).shell

if args.detach:
print(sid)
print(shell.id)
return

render.report_job_launched("shell", sid)

shell = bindings.get_GetShell(sess, shellId=sid).shell
render.report_job_launched("shell", shell.id, shell.description)
_open_shell(
sess,
shell.to_json(),
Expand Down
2 changes: 1 addition & 1 deletion harness/determined/cli/tensorboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def start_tensorboard(args: argparse.Namespace) -> None:
print(resp.tensorboard.id)
return

render.report_job_launched("tensorboard", tsb.id)
render.report_job_launched("tensorboard", tsb.id, tsb.description)

if resp.warnings:
cli.print_launch_warnings(resp.warnings)
Expand Down

0 comments on commit 7bce6ff

Please sign in to comment.