mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 15:28:34 +01:00
* repro: accept multiple targets (#5111)
Currently, we iterate over targets manually in CLI, which results in a
complicated code and a DAG collection/check overhead. With this PR we
collect the DAG once, figure out all the needed targets within it and
just reproduce them in one pass.
(cherry picked from commit aec8d65791)
# Conflicts:
# dvc/command/base.py
# dvc/command/experiments.py
# dvc/command/repro.py
# tests/func/test_repro_multistage.py
* resolve conflicts
* resolve test conflicts
Co-authored-by: Ruslan Kuprieiev <[email protected]>
Co-authored-by: Ruslan Kuprieiev <[email protected]>
58 lines
1.4 KiB
Python
58 lines
1.4 KiB
Python
import logging
|
|
import os
|
|
from abc import ABC, abstractmethod
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def fix_subparsers(subparsers):
|
|
"""Workaround for bug in Python 3. See more info at:
|
|
https://bugs.python.org/issue16308
|
|
https://github.com/iterative/dvc/issues/769
|
|
|
|
Args:
|
|
subparsers: subparsers to fix.
|
|
"""
|
|
subparsers.required = True
|
|
subparsers.dest = "cmd"
|
|
|
|
|
|
def append_doc_link(help_message, path):
|
|
from dvc.utils import format_link
|
|
|
|
if not path:
|
|
return help_message
|
|
doc_base = "https://man.dvc.org/"
|
|
return "{message}\nDocumentation: {link}".format(
|
|
message=help_message, link=format_link(doc_base + path)
|
|
)
|
|
|
|
|
|
class CmdBase(ABC):
|
|
UNINITIALIZED = False
|
|
|
|
def __init__(self, args):
|
|
from dvc.repo import Repo
|
|
from dvc.updater import Updater
|
|
|
|
os.chdir(args.cd)
|
|
|
|
self.repo = Repo(uninitialized=self.UNINITIALIZED)
|
|
self.config = self.repo.config
|
|
self.args = args
|
|
if self.repo.tmp_dir:
|
|
hardlink_lock = self.config["core"].get("hardlink_lock", False)
|
|
updater = Updater(self.repo.tmp_dir, hardlink_lock=hardlink_lock)
|
|
updater.check()
|
|
|
|
@abstractmethod
|
|
def run(self):
|
|
pass
|
|
|
|
|
|
class CmdBaseNoRepo(CmdBase):
|
|
def __init__(self, args): # pylint: disable=super-init-not-called
|
|
self.args = args
|
|
|
|
os.chdir(args.cd)
|