mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-06 23:09:55 +01:00
exp queue: remove dvc queue attach command
This commit is contained in:
committed by
Peter Rowlands (변기호)
parent
f12091002f
commit
67cbdf6de8
@@ -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,
|
||||
]
|
||||
|
||||
@@ -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="<experiment>",
|
||||
)
|
||||
queue_attach_parser.set_defaults(func=CmdQueueAttach)
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user