Skip to content

Commit

Permalink
queue: ui cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dberenbaum authored and pmrowla committed Jul 12, 2022
1 parent 4e82eb4 commit 164efe0
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 40 deletions.
6 changes: 3 additions & 3 deletions dvc/commands/queue/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
from dvc.commands.queue import kill, logs, remove, start, status, stop

SUB_COMMANDS = [
remove,
kill,
start,
stop,
status,
logs,
remove,
kill,
]


def add_parser(subparsers, parent_parser):
QUEUE_HELP = "Commands to manage dvc task queue."
QUEUE_HELP = "Commands to manage experiments queue."

queue_parser = subparsers.add_parser(
"queue",
Expand Down
10 changes: 5 additions & 5 deletions dvc/commands/queue/kill.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ class CmdQueueKill(CmdBase):
"""Kill exp task in queue."""

def run(self):
self.repo.experiments.celery_queue.kill(revs=self.args.experiment)
self.repo.experiments.celery_queue.kill(revs=self.args.task)

return 0


def add_parser(queue_subparsers, parent_parser):
QUEUE_KILL_HELP = "Kill experiments in queue"
QUEUE_KILL_HELP = "Kill tasks in experiments queue."
queue_kill_parser = queue_subparsers.add_parser(
"kill",
parents=[parent_parser],
Expand All @@ -26,9 +26,9 @@ def add_parser(queue_subparsers, parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
queue_kill_parser.add_argument(
"experiment",
"task",
nargs="*",
help="Experiments in queue to kill.",
metavar="<experiment>",
help="Tasks in queue to kill.",
metavar="<task>",
)
queue_kill_parser.set_defaults(func=CmdQueueKill)
14 changes: 7 additions & 7 deletions dvc/commands/queue/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CmdQueueLogs(CmdBase):

def run(self):
self.repo.experiments.celery_queue.logs(
rev=self.args.experiment,
rev=self.args.task,
encoding=self.args.encoding,
follow=self.args.follow,
)
Expand All @@ -21,7 +21,7 @@ def run(self):


def add_parser(queue_subparsers, parent_parser):
QUEUE_LOGS_HELP = "Show output logs for a queued experiment."
QUEUE_LOGS_HELP = "Show output logs for a task in the experiments queue."
queue_logs_parser = queue_subparsers.add_parser(
"logs",
parents=[parent_parser],
Expand All @@ -40,14 +40,14 @@ def add_parser(queue_subparsers, parent_parser):
"-f",
"--follow",
help=(
"Attach to experiment and follow additional live output. Only "
"applicable if the experiment is still running."
"Attach to task and follow additional live output. Only "
"applicable if the task is still running."
),
action="store_true",
)
queue_logs_parser.add_argument(
"experiment",
help="Experiment to show.",
metavar="<experiment>",
"task",
help="Task to show.",
metavar="<task>",
)
queue_logs_parser.set_defaults(func=CmdQueueLogs)
18 changes: 8 additions & 10 deletions dvc/commands/queue/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@ def run(self):
removed_list = self.repo.experiments.celery_queue.clear()
else:
removed_list = self.repo.experiments.celery_queue.remove(
revs=self.args.experiment
revs=self.args.task
)

if removed_list:
removed = ", ".join(removed_list)
ui.write(f"Removed experiments in queue: {removed}")
ui.write(f"Removed tasks in queue: {removed}")
else:
ui.write(
f"No experiments found in queue named {self.args.experiment}"
)
ui.write(f"No tasks found in queue named {self.args.task}")

return 0


def add_parser(queue_subparsers, parent_parser):

QUEUE_REMOVE_HELP = "Remove experiments in queue"
QUEUE_REMOVE_HELP = "Remove tasks in experiments queue."
queue_remove_parser = queue_subparsers.add_parser(
"remove",
parents=[parent_parser],
Expand All @@ -41,12 +39,12 @@ def add_parser(queue_subparsers, parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
queue_remove_parser.add_argument(
"--all", action="store_true", help="Remove all experiments in queue."
"--all", action="store_true", help="Remove all tasks in queue."
)
queue_remove_parser.add_argument(
"experiment",
"task",
nargs="*",
help="Experiments in queue to remove.",
metavar="<experiment>",
help="Tasks in queue to remove.",
metavar="<task>",
)
queue_remove_parser.set_defaults(func=CmdQueueRemove)
9 changes: 4 additions & 5 deletions dvc/commands/queue/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ def run(self):

suffix = "s" if self.args.jobs > 1 else ""
ui.write(
f"Start {self.args.jobs} queue worker{suffix} to process "
"the queue tasks"
f"Start {self.args.jobs} worker{suffix} to process the queue."
)

return 0
Expand All @@ -31,12 +30,12 @@ def job_type(job):
return job
except ValueError:
pass
raise argparse.ArgumentTypeError("Worker number must be a natural number")
raise argparse.ArgumentTypeError("Worker number must be a natural number.")


def add_parser(queue_subparsers, parent_parser):

QUEUE_START_HELP = "Start experiments queue workers"
QUEUE_START_HELP = "Start experiments queue workers."
queue_start_parser = queue_subparsers.add_parser(
"start",
parents=[parent_parser],
Expand All @@ -49,6 +48,6 @@ def add_parser(queue_subparsers, parent_parser):
"--jobs",
type=job_type,
default=1,
help="Number of queue workers to be started.",
help="Number of queue workers to start.",
)
queue_start_parser.set_defaults(func=CmdQueueStart)
4 changes: 2 additions & 2 deletions dvc/commands/queue/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def run(self):
result: List[
Mapping[str, Optional[str]]
] = self.repo.experiments.celery_queue.status()
all_headers = ["Rev", "Name", "Created", "Status"]
all_headers = ["Task", "Name", "Created", "Status"]
td = TabularData(all_headers)
for exp in result:
created = format_time(exp.get("timestamp"))
Expand All @@ -31,7 +31,7 @@ def run(self):


def add_parser(queue_subparsers, parent_parser):
QUEUE_STATUS_HELP = "List the status of the queue tasks and workers"
QUEUE_STATUS_HELP = "List the status of the queue tasks and workers."
queue_status_parser = queue_subparsers.add_parser(
"status",
parents=[parent_parser],
Expand Down
11 changes: 4 additions & 7 deletions dvc/commands/queue/stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,18 @@ def run(self):

if self.args.kill:
ui.write(
"All of the Queue tasked had already been killed, "
"All running tasks in the queue have been killed."
"Queue workers are stopping."
)
else:
ui.write(
"Queue workers will be stopped after current tasks finished."
)
ui.write("Queue workers will stop after running tasks finish.")

return 0


def add_parser(queue_subparsers, parent_parser):

QUEUE_STOP_HELP = "Stop experiment queue workers"
QUEUE_STOP_HELP = "Stop experiments queue workers."
queue_stop_parser = queue_subparsers.add_parser(
"stop",
parents=[parent_parser],
Expand All @@ -40,7 +38,6 @@ def add_parser(queue_subparsers, parent_parser):
queue_stop_parser.add_argument(
"--kill",
action="store_true",
help="Kill the current running experiments in queue "
"before shutting down.",
help="Kill all running tasks before stopping the queue workers.",
)
queue_stop_parser.set_defaults(func=CmdQueueStop)
2 changes: 1 addition & 1 deletion tests/unit/command/test_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_experiments_status(dvc, scm, mocker, capsys, caplog):
assert cmd.run() == 0
m.assert_called_once_with()
log, _ = capsys.readouterr()
assert "Rev Name Created Status" in log
assert "Task Name Created Status" in log
assert "c61a525 I40 Jun 09, 2022 Queued" in log
assert "8da9c33 I60 Jun 09, 2022 Running" in log

Expand Down

0 comments on commit 164efe0

Please sign in to comment.