-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
exp queue: monitor queue status (#7590)
fix: #7590 1. Add two new command `queue status` and `queue attach` 2. Add unit test for the CLI 3. Make `Running` exps can be found by `get_queue_entry_by_names`
- Loading branch information
1 parent
6b9538b
commit d13a2be
Showing
7 changed files
with
207 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import argparse | ||
import logging | ||
from typing import List, Mapping, Optional | ||
|
||
from dvc.cli.command import CmdBase | ||
from dvc.cli.utils import append_doc_link | ||
from dvc.compare import TabularData | ||
|
||
from ..experiments.show import format_time | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class CmdQueueStatus(CmdBase): | ||
"""Kill exp task in queue.""" | ||
|
||
def run(self): | ||
result: List[ | ||
Mapping[str, Optional[str]] | ||
] = self.repo.experiments.celery_queue.status() | ||
all_headers = ["Rev", "Name", "Created", "Status"] | ||
td = TabularData(all_headers) | ||
for exp in result: | ||
created = format_time(exp.get("timestamp")) | ||
td.append( | ||
[exp["rev"], exp.get("name", ""), created, exp["status"]] | ||
) | ||
td.render() | ||
|
||
return 0 | ||
|
||
|
||
def add_parser(queue_subparsers, parent_parser): | ||
QUEUE_STATUS_HELP = "List the status of the queue tasks and workers" | ||
queue_status_parser = queue_subparsers.add_parser( | ||
"status", | ||
parents=[parent_parser], | ||
description=append_doc_link(QUEUE_STATUS_HELP, "queue/status"), | ||
help=QUEUE_STATUS_HELP, | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
) | ||
queue_status_parser.set_defaults(func=CmdQueueStatus) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters