From 164efe089fa7e30c89c654f9e6ea33809eea8ffe Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 13 Jun 2022 12:58:29 -0400 Subject: [PATCH] queue: ui cleanup --- dvc/commands/queue/__init__.py | 6 +++--- dvc/commands/queue/kill.py | 10 +++++----- dvc/commands/queue/logs.py | 14 +++++++------- dvc/commands/queue/remove.py | 18 ++++++++---------- dvc/commands/queue/start.py | 9 ++++----- dvc/commands/queue/status.py | 4 ++-- dvc/commands/queue/stop.py | 11 ++++------- tests/unit/command/test_queue.py | 2 +- 8 files changed, 34 insertions(+), 40 deletions(-) diff --git a/dvc/commands/queue/__init__.py b/dvc/commands/queue/__init__.py index 6b08a63de..e04e40172 100644 --- a/dvc/commands/queue/__init__.py +++ b/dvc/commands/queue/__init__.py @@ -4,17 +4,17 @@ from dvc.cli.utils import append_doc_link, fix_subparsers 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", diff --git a/dvc/commands/queue/kill.py b/dvc/commands/queue/kill.py index 703b98457..52fe70cd5 100644 --- a/dvc/commands/queue/kill.py +++ b/dvc/commands/queue/kill.py @@ -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], @@ -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="", + help="Tasks in queue to kill.", + metavar="", ) queue_kill_parser.set_defaults(func=CmdQueueKill) diff --git a/dvc/commands/queue/logs.py b/dvc/commands/queue/logs.py index 40d401d70..6a722321c 100644 --- a/dvc/commands/queue/logs.py +++ b/dvc/commands/queue/logs.py @@ -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, ) @@ -21,7 +21,7 @@ class CmdQueueLogs(CmdBase): 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], @@ -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="", + "task", + help="Task to show.", + metavar="", ) queue_logs_parser.set_defaults(func=CmdQueueLogs) diff --git a/dvc/commands/queue/remove.py b/dvc/commands/queue/remove.py index 7b899ee44..ef68f8ef3 100644 --- a/dvc/commands/queue/remove.py +++ b/dvc/commands/queue/remove.py @@ -16,23 +16,21 @@ class CmdQueueRemove(CmdBase): 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], @@ -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="", + help="Tasks in queue to remove.", + metavar="", ) queue_remove_parser.set_defaults(func=CmdQueueRemove) diff --git a/dvc/commands/queue/start.py b/dvc/commands/queue/start.py index a74864b9f..cc7f44b76 100644 --- a/dvc/commands/queue/start.py +++ b/dvc/commands/queue/start.py @@ -17,8 +17,7 @@ class CmdQueueStart(CmdBase): 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 @@ -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], @@ -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) diff --git a/dvc/commands/queue/status.py b/dvc/commands/queue/status.py index 8a4cc8cad..3a32ce6e2 100644 --- a/dvc/commands/queue/status.py +++ b/dvc/commands/queue/status.py @@ -18,7 +18,7 @@ class CmdQueueStatus(CmdBase): 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")) @@ -31,7 +31,7 @@ class CmdQueueStatus(CmdBase): 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], diff --git a/dvc/commands/queue/stop.py b/dvc/commands/queue/stop.py index caf40a2ea..dea6d5a4f 100644 --- a/dvc/commands/queue/stop.py +++ b/dvc/commands/queue/stop.py @@ -16,20 +16,18 @@ class CmdQueueStop(CmdBase): 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], @@ -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) diff --git a/tests/unit/command/test_queue.py b/tests/unit/command/test_queue.py index 8c6067b35..bc9ebac40 100644 --- a/tests/unit/command/test_queue.py +++ b/tests/unit/command/test_queue.py @@ -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