From 67cbdf6de8feccb21d83ea6d42dc94c8c46775ca Mon Sep 17 00:00:00 2001 From: Peter Rowlands Date: Thu, 9 Jun 2022 13:31:26 +0900 Subject: [PATCH] exp queue: remove `dvc queue attach` command --- dvc/commands/queue/__init__.py | 3 +- dvc/commands/queue/attach.py | 44 ----------------------------- dvc/repo/experiments/queue/base.py | 13 --------- dvc/repo/experiments/queue/local.py | 19 ------------- tests/unit/command/test_queue.py | 23 --------------- 5 files changed, 1 insertion(+), 101 deletions(-) delete mode 100644 dvc/commands/queue/attach.py diff --git a/dvc/commands/queue/__init__.py b/dvc/commands/queue/__init__.py index efd60a5ed..6b08a63de 100644 --- a/dvc/commands/queue/__init__.py +++ b/dvc/commands/queue/__init__.py @@ -1,14 +1,13 @@ import argparse from dvc.cli.utils import append_doc_link, fix_subparsers -from dvc.commands.queue import attach, kill, logs, remove, start, status, stop +from dvc.commands.queue import kill, logs, remove, start, status, stop SUB_COMMANDS = [ remove, kill, start, stop, - attach, status, logs, ] diff --git a/dvc/commands/queue/attach.py b/dvc/commands/queue/attach.py deleted file mode 100644 index efb6c16d6..000000000 --- a/dvc/commands/queue/attach.py +++ /dev/null @@ -1,44 +0,0 @@ -import argparse -import logging - -from dvc.cli.command import CmdBase -from dvc.cli.utils import append_doc_link - -logger = logging.getLogger(__name__) - - -class CmdQueueAttach(CmdBase): - """Attach outputs of a exp task in queue.""" - - def run(self): - self.repo.experiments.celery_queue.attach( - rev=self.args.experiment, - encoding=self.args.encoding, - ) - - return 0 - - -def add_parser(queue_subparsers, parent_parser): - QUEUE_ATTACH_HELP = "Attach outputs of a experiment task in queue." - queue_attach_parser = queue_subparsers.add_parser( - "attach", - parents=[parent_parser], - description=append_doc_link(QUEUE_ATTACH_HELP, "queue/attach"), - help=QUEUE_ATTACH_HELP, - formatter_class=argparse.RawDescriptionHelpFormatter, - ) - queue_attach_parser.add_argument( - "-e", - "--encoding", - help=( - "Text encoding for redirected output. Defaults to" - "`locale.getpreferredencoding()`." - ), - ) - queue_attach_parser.add_argument( - "experiment", - help="Experiments in queue to attach.", - metavar="", - ) - queue_attach_parser.set_defaults(func=CmdQueueAttach) diff --git a/dvc/repo/experiments/queue/base.py b/dvc/repo/experiments/queue/base.py index 69d16e337..aef4902ea 100644 --- a/dvc/repo/experiments/queue/base.py +++ b/dvc/repo/experiments/queue/base.py @@ -260,19 +260,6 @@ class BaseStashQueue(ABC): finish any active experiments before shutting down. """ - def attach( - self, - rev: str, - encoding: Optional[str] = None, - ): - """Attach to a running exp process and print redirected output. - - Args: - rev: Stash rev or running exp name to be attached. - encoding: Text encoding for redirected output. Defaults to - `locale.getpreferredencoding()`. - """ - def logs( self, rev: str, diff --git a/dvc/repo/experiments/queue/local.py b/dvc/repo/experiments/queue/local.py index a0a5ae789..2bed25ae0 100644 --- a/dvc/repo/experiments/queue/local.py +++ b/dvc/repo/experiments/queue/local.py @@ -268,18 +268,6 @@ class LocalCeleryQueue(BaseStashQueue): except ProcessLookupError: continue - def attach( - self, - rev: str, - encoding: Optional[str] = None, - ): - queue_entry: Optional[QueueEntry] = self.match_queue_entry_by_name( - {rev}, self.iter_active() - ).get(rev) - if queue_entry is None: - raise UnresolvedQueueExpNamesError([rev]) - return self.follow(queue_entry, encoding=encoding) - def follow( self, entry: QueueEntry, @@ -453,13 +441,6 @@ class WorkspaceQueue(BaseStashQueue): def shutdown(self, kill: bool = False): raise NotImplementedError - def attach( - self, - rev: str, - encoding: Optional[str] = None, - ): - raise NotImplementedError - def logs( self, rev: str, diff --git a/tests/unit/command/test_queue.py b/tests/unit/command/test_queue.py index e46a49a87..d30a4d0fd 100644 --- a/tests/unit/command/test_queue.py +++ b/tests/unit/command/test_queue.py @@ -1,5 +1,4 @@ from dvc.cli import parse_args -from dvc.commands.queue.attach import CmdQueueAttach from dvc.commands.queue.kill import CmdQueueKill from dvc.commands.queue.logs import CmdQueueLogs from dvc.commands.queue.remove import CmdQueueRemove @@ -118,28 +117,6 @@ def test_experiments_status(dvc, scm, mocker): m.assert_called_once_with() -def test_experiments_attach(dvc, scm, mocker): - cli_args = parse_args( - [ - "queue", - "attach", - "exp1", - "-e", - "utf8", - ] - ) - assert cli_args.func == CmdQueueAttach - - cmd = cli_args.func(cli_args) - m = mocker.patch( - "dvc.repo.experiments.queue.local.LocalCeleryQueue.attach", - return_value={}, - ) - - assert cmd.run() == 0 - m.assert_called_once_with(rev="exp1", encoding="utf8") - - def test_queue_logs(dvc, scm, mocker): cli_args = parse_args(["queue", "logs", "exp1", "-e", "utf8", "-f"]) assert cli_args.func == CmdQueueLogs