pre-commit: update black to 21.5b1 (#6032)

* pre-commit: update black to 21.5b1

also updated others, but black is more noticeable

* remove magic trailing comma
This commit is contained in:
Saugat Pachhai
2021-05-18 15:51:15 +00:00
committed by GitHub
parent 58c465ef13
commit b9000ed926
154 changed files with 346 additions and 570 deletions
+3 -3
View File
@@ -3,7 +3,7 @@ repos:
- id: black
language_version: python3
repo: https://github.com/ambv/black
rev: 19.10b0
rev: 21.5b1
- hooks:
- id: isort
language_version: python3
@@ -18,7 +18,7 @@ repos:
- flake8-debugger
- flake8-string-format
repo: https://gitlab.com/pycqa/flake8
rev: 3.9.0
rev: 3.9.2
- hooks:
- id: mypy
language_version: python3
@@ -39,7 +39,7 @@ repos:
id: beautysh
language_version: python3
repo: https://github.com/lovesegfault/beautysh
rev: 6.0.1
rev: v6.1.0
- hooks:
- args:
- git-hook
+4 -4
View File
@@ -77,15 +77,15 @@ def add_debugging_flags(parser):
from argparse import SUPPRESS
parser.add_argument(
"--cprofile", action="store_true", default=False, help=SUPPRESS,
"--cprofile", action="store_true", default=False, help=SUPPRESS
)
parser.add_argument("--cprofile-dump", help=SUPPRESS)
parser.add_argument(
"--pdb", action="store_true", default=False, help=SUPPRESS,
"--pdb", action="store_true", default=False, help=SUPPRESS
)
parser.add_argument(
"--instrument", action="store_true", default=False, help=SUPPRESS,
"--instrument", action="store_true", default=False, help=SUPPRESS
)
parser.add_argument(
"--instrument-open", action="store_true", default=False, help=SUPPRESS,
"--instrument-open", action="store_true", default=False, help=SUPPRESS
)
+4 -6
View File
@@ -97,7 +97,7 @@ def _do_link(cache, from_info, to_info, link_method):
link_method(from_info, to_info)
logger.debug(
"Created '%s': %s -> %s", cache.cache_types[0], from_info, to_info,
"Created '%s': %s -> %s", cache.cache_types[0], from_info, to_info
)
@@ -187,7 +187,7 @@ def _checkout_file(
def _remove_redundant_files(
path_info, fs, obj, cache, force, dvcignore: Optional[DvcIgnoreFilter],
path_info, fs, obj, cache, force, dvcignore: Optional[DvcIgnoreFilter]
):
if dvcignore:
existing_files = set(dvcignore.walk_files(fs, path_info))
@@ -263,7 +263,7 @@ def _checkout(
):
if not obj.hash_info.isdir:
ret = _checkout_file(
path_info, fs, obj, cache, force, progress_callback, relink, state,
path_info, fs, obj, cache, force, progress_callback, relink, state
)
else:
ret = _checkout_dir(
@@ -328,9 +328,7 @@ def checkout(
if failed or skip:
if progress_callback and obj:
progress_callback(
str(path_info), len(obj),
)
progress_callback(str(path_info), len(obj))
if failed:
raise CheckoutError([failed])
return
+1 -1
View File
@@ -117,6 +117,6 @@ def add_parser(subparsers, parent_parser):
),
)
parser.add_argument(
"targets", nargs="+", help="Input files/directories to add.",
"targets", nargs="+", help="Input files/directories to add."
).complete = completion.FILE
parser.set_defaults(func=CmdAdd)
+4 -4
View File
@@ -7,11 +7,11 @@ 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
https://bugs.python.org/issue16308
https://github.com/iterative/dvc/issues/769
Args:
subparsers: subparsers to fix.
Args:
subparsers: subparsers to fix.
"""
subparsers.required = True
subparsers.dest = "cmd"
+1 -1
View File
@@ -120,6 +120,6 @@ def add_parser(subparsers, parent_parser):
help="Read paths from standard input instead of providing `targets`.",
)
parser.add_argument(
"targets", nargs="*", help="File or directory paths to check",
"targets", nargs="*", help="File or directory paths to check"
).complete = completion.FILE
parser.set_defaults(func=CmdCheckIgnore)
+2 -2
View File
@@ -11,9 +11,9 @@ from dvc.ui import ui
def log_changes(stats):
colors = [
("modified", colorama.Fore.YELLOW,),
("modified", colorama.Fore.YELLOW),
("added", colorama.Fore.GREEN),
("deleted", colorama.Fore.RED,),
("deleted", colorama.Fore.RED),
]
for state, color in colors:
+3 -12
View File
@@ -68,25 +68,16 @@ _dvc_compadd_exps() {
""",
}
DVC_FILE = {
"bash": "_dvc_compgen_DVCFiles",
"zsh": "_dvc_compadd_DVCFiles",
}
DVC_FILE = {"bash": "_dvc_compgen_DVCFiles", "zsh": "_dvc_compadd_DVCFiles"}
STAGE = {
"bash": "_dvc_compgen_stages",
"zsh": "_dvc_compadd_stages",
}
STAGE = {"bash": "_dvc_compgen_stages", "zsh": "_dvc_compadd_stages"}
DVCFILES_AND_STAGE = {
"bash": "_dvc_compgen_stages_and_files",
"zsh": "_dvc_compadd_stages_and_files",
}
EXPERIMENT = {
"bash": "_dvc_compgen_exps",
"zsh": "_dvc_compadd_exps",
}
EXPERIMENT = {"bash": "_dvc_compgen_exps", "zsh": "_dvc_compadd_exps"}
class CmdCompletion(CmdBaseNoRepo):
+1 -1
View File
@@ -67,6 +67,6 @@ def add_parser(subparsers, parent_parser):
help=DAEMON_ANALYTICS_HELP,
)
daemon_analytics_parser.add_argument(
"target", help="Analytics file.",
"target", help="Analytics file."
).complete = completion.FILE
daemon_analytics_parser.set_defaults(func=CmdDaemonAnalytics)
+3 -6
View File
@@ -139,7 +139,7 @@ def add_parser(subparsers, _parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
pull_parser.add_argument(
"-r", "--remote", help="Remote storage to pull from", metavar="<name>",
"-r", "--remote", help="Remote storage to pull from", metavar="<name>"
)
pull_parser.add_argument(
"-a",
@@ -208,7 +208,7 @@ def add_parser(subparsers, _parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
push_parser.add_argument(
"-r", "--remote", help="Remote storage to push to", metavar="<name>",
"-r", "--remote", help="Remote storage to push to", metavar="<name>"
)
push_parser.add_argument(
"-a",
@@ -272,10 +272,7 @@ def add_parser(subparsers, _parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
fetch_parser.add_argument(
"-r",
"--remote",
help="Remote storage to fetch from",
metavar="<name>",
"-r", "--remote", help="Remote storage to fetch from", metavar="<name>"
)
fetch_parser.add_argument(
"-a",
+9 -16
View File
@@ -304,14 +304,7 @@ def experiments_table(
from dvc.compare import TabularData
headers = [
"Experiment",
"rev",
"queued",
"typ",
"Created",
"parent",
]
headers = ["Experiment", "rev", "queued", "typ", "Created", "parent"]
td = TabularData(
lconcat(headers, metric_headers, param_headers), fill_value=FILL_VALUE
)
@@ -714,7 +707,7 @@ class CmdExperimentsRemove(CmdBase):
def run(self):
self.repo.experiments.remove(
exp_names=self.args.experiment, queue=self.args.queue,
exp_names=self.args.experiment, queue=self.args.queue
)
return 0
@@ -875,7 +868,7 @@ def add_parser(subparsers, parent_parser):
help="Fail if this command would overwrite conflicting changes.",
)
experiments_apply_parser.add_argument(
"experiment", help="Experiment to be applied.",
"experiment", help="Experiment to be applied."
).complete = completion.EXPERIMENT
experiments_apply_parser.set_defaults(func=CmdExperimentsApply)
@@ -1040,10 +1033,10 @@ def add_parser(subparsers, parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
experiments_branch_parser.add_argument(
"experiment", help="Experiment to be promoted.",
"experiment", help="Experiment to be promoted."
)
experiments_branch_parser.add_argument(
"branch", help="Git branch name to use.",
"branch", help="Git branch name to use."
)
experiments_branch_parser.set_defaults(func=CmdExperimentsBranch)
@@ -1066,7 +1059,7 @@ def add_parser(subparsers, parent_parser):
metavar="<rev>",
)
experiments_list_parser.add_argument(
"--all", action="store_true", help="List all experiments.",
"--all", action="store_true", help="List all experiments."
)
experiments_list_parser.add_argument(
"--names-only",
@@ -1138,7 +1131,7 @@ def add_parser(subparsers, parent_parser):
metavar="<git_remote>",
)
experiments_push_parser.add_argument(
"experiment", help="Experiment to push.", metavar="<experiment>",
"experiment", help="Experiment to push.", metavar="<experiment>"
).complete = completion.EXPERIMENT
experiments_push_parser.set_defaults(func=CmdExperimentsPush)
@@ -1194,7 +1187,7 @@ def add_parser(subparsers, parent_parser):
metavar="<git_remote>",
)
experiments_pull_parser.add_argument(
"experiment", help="Experiment to pull.", metavar="<experiment>",
"experiment", help="Experiment to pull.", metavar="<experiment>"
)
experiments_pull_parser.set_defaults(func=CmdExperimentsPull)
@@ -1207,7 +1200,7 @@ def add_parser(subparsers, parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
experiments_remove_parser.add_argument(
"--queue", action="store_true", help="Remove all queued experiments.",
"--queue", action="store_true", help="Remove all queued experiments."
)
experiments_remove_parser.add_argument(
"experiment",
+2 -2
View File
@@ -40,7 +40,7 @@ def add_parser(subparsers, parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
freeze_parser.add_argument(
"targets", nargs="+", help="Stages or .dvc files to freeze",
"targets", nargs="+", help="Stages or .dvc files to freeze"
).complete = completion.DVC_FILE
freeze_parser.set_defaults(func=CmdFreeze)
@@ -53,6 +53,6 @@ def add_parser(subparsers, parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
unfreeze_parser.add_argument(
"targets", nargs="+", help="Stages or .dvc files to unfreeze",
"targets", nargs="+", help="Stages or .dvc files to unfreeze"
).complete = completion.DVC_FILE
unfreeze_parser.set_defaults(func=CmdUnfreeze)
+1 -1
View File
@@ -64,7 +64,7 @@ def add_parser(subparsers, parent_parser):
"url", help="Location of DVC or Git repository to download from"
)
get_parser.add_argument(
"path", help="Path to a file or directory within the repository",
"path", help="Path to a file or directory within the repository"
).complete = completion.FILE
get_parser.add_argument(
"-o",
+1 -1
View File
@@ -34,7 +34,7 @@ def add_parser(subparsers, parent_parser):
"url", help="See `dvc import-url -h` for full list of supported URLs."
)
get_parser.add_argument(
"out", nargs="?", help="Destination path to put data to.",
"out", nargs="?", help="Destination path to put data to."
).complete = completion.DIR
get_parser.add_argument(
"-j",
+4 -6
View File
@@ -105,7 +105,7 @@ def add_parser(subparsers, parent_parser):
help=PRE_COMMIT_HELP,
)
pre_commit_parser.add_argument(
"args", nargs="*", help="Arguments passed by GIT or pre-commit tool.",
"args", nargs="*", help="Arguments passed by GIT or pre-commit tool."
)
pre_commit_parser.set_defaults(func=CmdPreCommit)
@@ -117,7 +117,7 @@ def add_parser(subparsers, parent_parser):
help=POST_CHECKOUT_HELP,
)
post_checkout_parser.add_argument(
"args", nargs="*", help="Arguments passed by GIT or pre-commit tool.",
"args", nargs="*", help="Arguments passed by GIT or pre-commit tool."
)
post_checkout_parser.set_defaults(func=CmdPostCheckout)
@@ -129,7 +129,7 @@ def add_parser(subparsers, parent_parser):
help=PRE_PUSH_HELP,
)
pre_push_parser.add_argument(
"args", nargs="*", help="Arguments passed by GIT or pre-commit tool.",
"args", nargs="*", help="Arguments passed by GIT or pre-commit tool."
)
pre_push_parser.set_defaults(func=CmdPrePush)
@@ -146,9 +146,7 @@ def add_parser(subparsers, parent_parser):
help="Ancestor's version of the conflicting file.",
)
merge_driver_parser.add_argument(
"--our",
required=True,
help="Current version of the conflicting file.",
"--our", required=True, help="Current version of the conflicting file."
)
merge_driver_parser.add_argument(
"--their",
+1 -1
View File
@@ -48,7 +48,7 @@ def add_parser(subparsers, parent_parser):
"url", help="Location of DVC or Git repository to download from"
)
import_parser.add_argument(
"path", help="Path to a file or directory within the repository",
"path", help="Path to a file or directory within the repository"
).complete = completion.FILE
import_parser.add_argument(
"-o",
+1 -1
View File
@@ -58,7 +58,7 @@ def add_parser(subparsers, parent_parser):
"remote://remote_name/path/to/file/or/dir (see `dvc remote`)",
)
import_parser.add_argument(
"out", nargs="?", help="Destination path to put files to.",
"out", nargs="?", help="Destination path to put files to."
).complete = completion.DIR
import_parser.add_argument(
"--file",
+1 -1
View File
@@ -35,7 +35,7 @@ class CmdLiveDiff(CmdLive):
def shared_parent_parser():
parent_parser = argparse.ArgumentParser(add_help=False)
parent_parser.add_argument(
"target", help="Logs dir to produce summary from",
"target", help="Logs dir to produce summary from"
).complete = completion.DIR
parent_parser.add_argument(
"-o",
+2 -2
View File
@@ -37,9 +37,9 @@ def add_parser(subparsers, parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
move_parser.add_argument(
"src", help="Source path to a data file or directory.",
"src", help="Source path to a data file or directory."
).complete = completion.FILE
move_parser.add_argument(
"dst", help="Destination path.",
"dst", help="Destination path."
).complete = completion.FILE
move_parser.set_defaults(func=CmdMove)
+3 -3
View File
@@ -87,7 +87,7 @@ class CmdPlotsDiff(CmdPlots):
class CmdPlotsModify(CmdPlots):
def run(self):
self.repo.plots.modify(
self.args.target, props=self._props(), unset=self.args.unset,
self.args.target, props=self._props(), unset=self.args.unset
)
return 0
@@ -160,7 +160,7 @@ def add_parser(subparsers, parent_parser):
help=argparse.SUPPRESS,
)
plots_diff_parser.add_argument(
"revisions", nargs="*", default=None, help="Git commits to plot from",
"revisions", nargs="*", default=None, help="Git commits to plot from"
)
_add_props_arguments(plots_diff_parser)
_add_output_arguments(plots_diff_parser)
@@ -175,7 +175,7 @@ def add_parser(subparsers, parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
plots_modify_parser.add_argument(
"target", help="Metric file to set properties to",
"target", help="Metric file to set properties to"
).complete = completion.FILE
_add_props_arguments(plots_modify_parser)
plots_modify_parser.add_argument(
+2 -4
View File
@@ -83,11 +83,9 @@ def add_parser(subparsers, parent_parser):
help=RUN_HELP,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
run_parser.add_argument("-n", "--name", help="Stage name.")
run_parser.add_argument(
"-n", "--name", help="Stage name.",
)
run_parser.add_argument(
"--file", metavar="<filename>", help=argparse.SUPPRESS,
"--file", metavar="<filename>", help=argparse.SUPPRESS
)
run_parser.add_argument(
"--no-exec",
+2 -4
View File
@@ -75,9 +75,7 @@ class CmdStageList(CmdBase):
# removing duplicates while maintaining order
collected = chain.from_iterable(
self.repo.stage.collect(
target=target,
recursive=self.args.recursive,
accept_group=True,
target=target, recursive=self.args.recursive, accept_group=True
)
for target in self.args.targets
)
@@ -201,7 +199,7 @@ def _add_common_args(parser):
metavar="<path>",
)
parser.add_argument(
"--live", help="Declare output as dvclive.", metavar="<path>",
"--live", help="Declare output as dvclive.", metavar="<path>"
)
parser.add_argument(
"--live-no-cache",
+1 -1
View File
@@ -33,6 +33,6 @@ def add_parser(subparsers, parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
unprotect_parser.add_argument(
"targets", nargs="+", help="Data files/directories to unprotect.",
"targets", nargs="+", help="Data files/directories to unprotect."
).complete = completion.FILE
unprotect_parser.set_defaults(func=CmdUnprotect)
+1 -1
View File
@@ -36,7 +36,7 @@ def add_parser(subparsers, parent_parser):
formatter_class=argparse.RawDescriptionHelpFormatter,
)
update_parser.add_argument(
"targets", nargs="+", help=".dvc files to update.",
"targets", nargs="+", help=".dvc files to update."
).complete = completion.DVC_FILE
update_parser.add_argument(
"--rev",
+1 -4
View File
@@ -275,10 +275,7 @@ def metrics_table(
for branch, val in metrics.items():
for fname, metric in val.items():
row_data: Dict[str, str] = {
"Revision": branch,
"Path": fname,
}
row_data: Dict[str, str] = {"Revision": branch, "Path": fname}
flattened = (
flatten(format_dict(metric))
if isinstance(metric, dict)
+1 -1
View File
@@ -63,7 +63,7 @@ class Config(dict):
CONFIG_LOCAL = "config.local"
def __init__(
self, dvc_dir=None, validate=True, fs=None, config=None,
self, dvc_dir=None, validate=True, fs=None, config=None
): # pylint: disable=super-init-not-called
from dvc.fs.local import LocalFileSystem
+1 -1
View File
@@ -33,7 +33,7 @@ def _spawn_windows(cmd, env):
startupinfo.dwFlags |= STARTF_USESHOWWINDOW
_popen(
cmd, env=env, creationflags=creationflags, startupinfo=startupinfo,
cmd, env=env, creationflags=creationflags, startupinfo=startupinfo
).communicate()
+2 -6
View File
@@ -48,9 +48,7 @@ class DataCloud:
return get_remote(self.repo, name=name)
def push(
self, cache, jobs=None, remote=None, show_checksums=False,
):
def push(self, cache, jobs=None, remote=None, show_checksums=False):
"""Push data items in a cloud-agnostic way.
Args:
@@ -70,9 +68,7 @@ class DataCloud:
show_checksums=show_checksums,
)
def pull(
self, cache, jobs=None, remote=None, show_checksums=False,
):
def pull(self, cache, jobs=None, remote=None, show_checksums=False):
"""Pull data items in a cloud-agnostic way.
Args:
+1 -1
View File
@@ -128,7 +128,7 @@ class ParamsDependency(LocalDependency):
if missing_params:
raise MissingParamsError(
"Parameters '{}' are missing from '{}'.".format(
", ".join(missing_params), self,
", ".join(missing_params), self
)
)
+1 -1
View File
@@ -94,7 +94,7 @@ class RepoDependency(LocalDependency):
except (NoOutputOrStageError, NoRemoteError):
pass
obj = stage(
odb, path_info, repo.repo_fs, odb.fs.PARAM_CHECKSUM, jobs=jobs,
odb, path_info, repo.repo_fs, odb.fs.PARAM_CHECKSUM, jobs=jobs
)
save(odb, obj, jobs=jobs)
+1 -1
View File
@@ -40,7 +40,7 @@ class FileIsGitIgnored(DvcException):
def __init__(self, path, pipeline_file=False):
super().__init__(
"{}'{}' is git-ignored.".format(
"bad DVC file name " if pipeline_file else "", path,
"bad DVC file name " if pipeline_file else "", path
)
)
+3 -3
View File
@@ -35,7 +35,7 @@ class OutputDuplicationError(DvcException):
)
else:
msg = "output '{}' is already specified in stages:\n{}".format(
output, "\n".join(f"\t- {s.addressing}" for s in stages),
output, "\n".join(f"\t- {s.addressing}" for s in stages)
)
super().__init__(msg)
self.stages = stages
@@ -283,7 +283,7 @@ class CheckoutError(DvcException):
m = (
"Checkout failed for following targets:\n{}\nIs your "
"cache up to date?\n{}".format(
"\n".join(targets), error_link("missing-files"),
"\n".join(targets), error_link("missing-files")
)
)
super().__init__(m)
@@ -380,7 +380,7 @@ class CacheLinkError(DvcException):
def __init__(self, path_infos):
msg = "No possible cache link types for '{}'. {}".format(
", ".join([str(path) for path in path_infos]), self.SUPPORT_LINK,
", ".join([str(path) for path in path_infos]), self.SUPPORT_LINK
)
super().__init__(msg)
self.path_infos = path_infos
+1 -4
View File
@@ -36,10 +36,7 @@ def external_repo(
rev = rev or "refs/remotes/origin/HEAD"
cache_config = {
"cache": {
"dir": cache_dir or _get_cache_dir(url),
"type": cache_types,
}
"cache": {"dir": cache_dir or _get_cache_dir(url), "type": cache_types}
}
config = _get_remote_config(url) if os.path.isdir(url) else {}
+7 -12
View File
@@ -149,8 +149,7 @@ class BaseFileSystem:
return False # We can't be sure by default
def walk(self, top, topdown=True, onerror=None, **kwargs):
"""Return a generator with (root, dirs, files).
"""
"""Return a generator with (root, dirs, files)."""
raise NotImplementedError
def walk_files(self, path_info, **kwargs):
@@ -209,9 +208,7 @@ class BaseFileSystem:
return False
return hash_.endswith(cls.CHECKSUM_DIR_SUFFIX)
def upload(
self, from_info, to_info, name=None, no_progress_bar=False,
):
def upload(self, from_info, to_info, name=None, no_progress_bar=False):
if not hasattr(self, "_upload"):
raise RemoteActionNotImplemented("upload", self.scheme)
@@ -266,14 +263,14 @@ class BaseFileSystem:
if not _only_file and self.isdir(from_info):
return self._download_dir(
from_info, to_info, name, no_progress_bar, jobs, **kwargs,
from_info, to_info, name, no_progress_bar, jobs, **kwargs
)
return self._download_file(from_info, to_info, name, no_progress_bar,)
return self._download_file(from_info, to_info, name, no_progress_bar)
download_file = partialmethod(download, _only_file=True)
def _download_dir(
self, from_info, to_info, name, no_progress_bar, jobs, **kwargs,
self, from_info, to_info, name, no_progress_bar, jobs, **kwargs
):
from_infos = list(self.walk_files(from_info, **kwargs))
if not from_infos:
@@ -290,7 +287,7 @@ class BaseFileSystem:
disable=no_progress_bar,
) as pbar:
download_files = pbar.wrap_fn(
partial(self._download_file, name=name, no_progress_bar=True,)
partial(self._download_file, name=name, no_progress_bar=True)
)
max_workers = jobs or self.jobs
with ThreadPoolExecutor(max_workers=max_workers) as executor:
@@ -314,9 +311,7 @@ class BaseFileSystem:
entry.cancel()
raise exc
def _download_file(
self, from_info, to_info, name, no_progress_bar,
):
def _download_file(self, from_info, to_info, name, no_progress_bar):
makedirs(to_info.parent, exist_ok=True)
logger.debug("Downloading '%s' to '%s'", from_info, to_info)
+1 -1
View File
@@ -138,7 +138,7 @@ class GDriveFileSystem(BaseFileSystem): # pylint:disable=abstract-method
if os.getenv(GDriveFileSystem.GDRIVE_CREDENTIALS_DATA)
else config.get(
"gdrive_user_credentials_file",
os.path.join(tmp_dir, self.DEFAULT_USER_CREDENTIALS_FILE,),
os.path.join(tmp_dir, self.DEFAULT_USER_CREDENTIALS_FILE),
)
)
+1 -1
View File
@@ -161,7 +161,7 @@ class LocalFileSystem(BaseFileSystem):
}
def _upload(
self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs,
self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs
):
makedirs(to_info.parent, exist_ok=True)
+4 -4
View File
@@ -35,7 +35,7 @@ class RepoFileSystem(BaseFileSystem): # pylint:disable=abstract-method
PARAM_CHECKSUM = "md5"
def __init__(
self, repo=None, subrepos=False, repo_factory: RepoFactory = None,
self, repo=None, subrepos=False, repo_factory: RepoFactory = None
):
super().__init__()
@@ -245,8 +245,8 @@ class RepoFileSystem(BaseFileSystem): # pylint:disable=abstract-method
def _subrepo_walk(self, dir_path, **kwargs):
"""Walk into a new repo.
NOTE: subrepo will only be discovered when walking if
ignore_subrepos is set to False.
NOTE: subrepo will only be discovered when walking if
ignore_subrepos is set to False.
"""
fs, dvc_fs = self._get_fs_pair(dir_path)
fs_walk = fs.walk(dir_path, topdown=True)
@@ -378,7 +378,7 @@ class RepoFileSystem(BaseFileSystem): # pylint:disable=abstract-method
with open(to_file, "wb+") as to_fobj:
with Tqdm.wrapattr(
to_fobj, "write", desc=name, disable=no_progress_bar,
to_fobj, "write", desc=name, disable=no_progress_bar
) as wrapped:
with self.open(from_info, "rb", **kwargs) as from_fobj:
shutil.copyfileobj(from_fobj, wrapped)
+1 -1
View File
@@ -24,7 +24,7 @@ logger = logging.getLogger(__name__)
def sizeof_fmt(num, suffix="B"):
""" Convert number of bytes to human-readable string """
"""Convert number of bytes to human-readable string"""
for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]:
if abs(num) < 1024.0:
return f"{num:3.1f}{unit}{suffix}"
+2 -5
View File
@@ -241,7 +241,7 @@ class WebDAVFileSystem(BaseFileSystem): # pylint:disable=abstract-method
# Uploads file to remote
def _upload(
self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs,
self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs
):
# First try to create parent directories
self.makedirs(to_info.parent)
@@ -267,7 +267,4 @@ class WebDAVFileSystem(BaseFileSystem): # pylint:disable=abstract-method
def info(self, path_info):
info = self._client.info(path_info.path)
return {
"size": int(info["size"]),
"etag": info["etag"],
}
return {"size": int(info["size"]), "etag": info["etag"]}
+2 -2
View File
@@ -57,7 +57,7 @@ class DvcIgnorePatterns(DvcIgnore):
dirname = os.path.normpath(os.path.dirname(path))
with fs.open(path, encoding="utf-8") as fobj:
path_spec_lines = [
PatternInfo(line, "{}:{}:{}".format(name, line_no + 1, line),)
PatternInfo(line, "{}:{}:{}".format(name, line_no + 1, line))
for line_no, line in enumerate(
map(str.strip, fobj.readlines())
)
@@ -366,7 +366,7 @@ class DvcIgnoreFilter:
pattern = self._get_trie_pattern(dirname)
if pattern:
matches = pattern.matches(
dirname, basename, os.path.isdir(full_target), True,
dirname, basename, os.path.isdir(full_target), True
)
if matches:
+4 -4
View File
@@ -23,10 +23,10 @@ def istextblock(block):
def istextfile(fname, fs, blocksize=512):
""" Uses heuristics to guess whether the given file is text or binary,
by reading a single block of bytes from the file.
If more than 30% of the chars in the block are non-text, or there
are NUL ('\x00') bytes in the block, assume this is a binary file.
"""Uses heuristics to guess whether the given file is text or binary,
by reading a single block of bytes from the file.
If more than 30% of the chars in the block are non-text, or there
are NUL ('\x00') bytes in the block, assume this is a binary file.
"""
with fs.open(fname, "rb") as fobj:
block = fobj.read(blocksize)
+1 -1
View File
@@ -256,7 +256,7 @@ def setup(level=logging.INFO):
"console_trace",
"console_errors",
],
},
}
},
"disable_existing_loggers": False,
}
+2 -2
View File
@@ -35,7 +35,7 @@ class ObjectDB:
self.fs.makedirs(path_info)
def get(self, hash_info):
""" get raw object """
"""get raw object"""
return HashFile(
# Prefer string path over PathInfo when possible due to performance
self.hash_to_path(hash_info.value),
@@ -289,7 +289,7 @@ class ObjectDB:
with ThreadPoolExecutor(
max_workers=jobs or self.fs.jobs
) as executor:
in_remote = executor.map(list_with_update, traverse_prefixes,)
in_remote = executor.map(list_with_update, traverse_prefixes)
yield from itertools.chain.from_iterable(in_remote)
def all(self, jobs=None, name=None):
+2 -4
View File
@@ -47,7 +47,7 @@ def _get_file_hash(path_info, fs, name):
def get_file_hash(path_info, fs, name, state=None):
if state:
hash_info = state.get( # pylint: disable=assignment-from-none
path_info, fs,
path_info, fs
)
if hash_info:
return hash_info
@@ -109,9 +109,7 @@ def _iter_objects(path_info, fs, name, odb, state, upload, **kwargs):
if not upload and name in fs.DETAIL_FIELDS:
for details in fs.find(path_info, detail=True):
file_info = path_info.replace(path=details["name"])
hash_info = HashInfo(
name, details[name], size=details.get("size"),
)
hash_info = HashInfo(name, details[name], size=details.get("size"))
yield file_info, HashFile(file_info, fs, hash_info)
return None
+1 -1
View File
@@ -198,7 +198,7 @@ def merge(odb, ancestor_info, our_info, their_info):
our = load(odb, our_info)
their = load(odb, their_info)
merged_dict = _merge(ancestor.as_dict(), our.as_dict(), their.as_dict(),)
merged_dict = _merge(ancestor.as_dict(), our.as_dict(), their.as_dict())
merged = Tree(None, None, None)
for key, hi in merged_dict.items():
+2 -2
View File
@@ -503,7 +503,7 @@ class BaseOutput:
self.repo.scm.ignore(self.fspath)
def transfer(
self, source, odb=None, jobs=None, update=False, no_progress_bar=False,
self, source, odb=None, jobs=None, update=False, no_progress_bar=False
):
from dvc.fs import get_cloud_fs
@@ -677,7 +677,7 @@ class BaseOutput:
return ret
ret.add_child_cache(
self.hash_info.value, self.collect_used_dir_cache(**kwargs),
self.hash_info.value, self.collect_used_dir_cache(**kwargs)
)
return ret
+1 -3
View File
@@ -447,9 +447,7 @@ class ForeachDefinition:
# generated stages. We do it once when accessing do_definition.
return entry.resolve_stage(skip_checks=True)
except ContextError as exc:
format_and_raise(
exc, f"stage '{generated}'", self.relpath,
)
format_and_raise(exc, f"stage '{generated}'", self.relpath)
# let mypy know that this state is unreachable as format_and_raise
# does not return at all (it's not able to understand it for some
+1 -3
View File
@@ -396,9 +396,7 @@ class Context(CtxDict):
raise ReservedKeyError(matches)
return super().merge_update(other, overwrite=overwrite)
def merge_from(
self, fs, item: str, wdir: PathInfo, overwrite=False,
):
def merge_from(self, fs, item: str, wdir: PathInfo, overwrite=False):
path, _, keys_str = item.partition(":")
select_keys = lfilter(bool, keys_str.split(",")) if keys_str else None
+1 -1
View File
@@ -134,7 +134,7 @@ class RemoteIndex:
logger.error(
"Index file version '{}' will be reformatted "
"to the current version '{}'.".format(
version, self.VERSION,
version, self.VERSION
)
)
cmd = "DROP TABLE IF EXISTS {};"
+4 -9
View File
@@ -147,9 +147,7 @@ class Repo:
from dvc.state import State, StateNoop
self.url = url
self._fs_conf = {
"repo_factory": repo_factory,
}
self._fs_conf = {"repo_factory": repo_factory}
if rev and not scm:
scm = SCM(root_dir or os.curdir)
@@ -317,10 +315,7 @@ class Repo:
return self.odb.local.unprotect(PathInfo(target))
def _ignore(self):
flist = [
self.config.files["local"],
self.tmp_dir,
]
flist = [self.config.files["local"], self.tmp_dir]
if path_isin(self.odb.local.cache_dir, self.root_dir):
flist += [self.odb.local.cache_dir]
@@ -407,7 +402,7 @@ class Repo:
if used_run_cache:
used_cache = self.stage_cache.get_used_cache(
used_run_cache, remote=remote, force=force, jobs=jobs,
used_run_cache, remote=remote, force=force, jobs=jobs
)
cache.update(used_cache)
@@ -491,7 +486,7 @@ class Repo:
path = PathInfo(self.root_dir) / path
try:
with fs.open(
path, mode=mode, encoding=encoding, remote=remote,
path, mode=mode, encoding=encoding, remote=remote
) as fobj:
yield fobj
except FileNotFoundError as exc:
+1 -6
View File
@@ -87,12 +87,7 @@ def checkout(
**kwargs,
):
stats = {
"added": [],
"deleted": [],
"modified": [],
"failed": [],
}
stats = {"added": [], "deleted": [], "modified": [], "failed": []}
if not targets:
targets = [None]
stats["deleted"] = _remove_unused_links(self)
+3 -3
View File
@@ -18,7 +18,7 @@ DvcPaths = List[DvcPath]
def _collect_outs(
repo: "Repo", output_filter: FilterFn = None, deps: bool = False,
repo: "Repo", output_filter: FilterFn = None, deps: bool = False
) -> Outputs:
outs = [
out
@@ -49,11 +49,11 @@ def _collect_paths(
if not recursive:
if rev == "workspace" or rev == "":
logger.warning(
"'%s' was not found in current workspace.", path_info,
"'%s' was not found in current workspace.", path_info
)
else:
logger.warning(
"'%s' was not found at: '%s'.", path_info, rev,
"'%s' was not found at: '%s'.", path_info, rev
)
continue
target_infos.append(path_info)
+1 -1
View File
@@ -134,7 +134,7 @@ def _output_paths(repo, repo_fs, targets):
def _to_checksum(output):
if on_working_fs:
return ostage(
repo.odb.local, output.path_info, repo.odb.local.fs, "md5",
repo.odb.local, output.path_info, repo.odb.local.fs, "md5"
).hash_info.value
return output.hash_info.value
+5 -7
View File
@@ -412,7 +412,7 @@ class Experiments:
)
if queue:
logger.info(
"Queued experiment '%s' for future execution.", stash_rev[:7],
"Queued experiment '%s' for future execution.", stash_rev[:7]
)
return [stash_rev]
if tmp_dir or queue:
@@ -459,9 +459,7 @@ class Experiments:
)
@scm_locked
def new(
self, *args, checkpoint_resume: Optional[str] = None, **kwargs,
):
def new(self, *args, checkpoint_resume: Optional[str] = None, **kwargs):
"""Create a new experiment.
Experiment will be reproduced and checked out into the user's
@@ -475,7 +473,7 @@ class Experiments:
return self._stash_exp(*args, **kwargs)
def _resume_checkpoint(
self, *args, resume_rev: Optional[str] = None, **kwargs,
self, *args, resume_rev: Optional[str] = None, **kwargs
):
"""Resume an existing (checkpoint) experiment.
@@ -707,7 +705,7 @@ class Experiments:
)
elif not isinstance(exc, CheckpointKilledError):
logger.error(
"Failed to reproduce experiment '%s'", rev[:7],
"Failed to reproduce experiment '%s'", rev[:7]
)
except CancelledError:
logger.error(
@@ -737,7 +735,7 @@ class Experiments:
raise ExperimentExistsError(ref_info.name)
for ref in executor.fetch_exps(
self.scm, force=exec_result.force, on_diverged=on_diverged,
self.scm, force=exec_result.force, on_diverged=on_diverged
):
exp_rev = self.scm.get_ref(ref)
if exp_rev:
+1 -1
View File
@@ -100,7 +100,7 @@ class ExpRefInfo:
namespace = EXPS_NAMESPACE
def __init__(
self, baseline_sha: Optional[str] = None, name: Optional[str] = None,
self, baseline_sha: Optional[str] = None, name: Optional[str] = None
):
self.baseline_sha = baseline_sha
self.name: str = name if name else ""
+1 -3
View File
@@ -182,9 +182,7 @@ class BaseExecutor(ABC):
def on_diverged_ref(orig_ref: str, new_rev: str):
if force:
logger.debug(
"Replacing existing experiment '%s'", orig_ref,
)
logger.debug("Replacing existing experiment '%s'", orig_ref)
return True
checkpoint = self.scm.get_ref(EXEC_CHECKPOINT) is not None
+1 -3
View File
@@ -58,9 +58,7 @@ class TempDirExecutor(BaseLocalExecutor):
super().__init__(*args, **kwargs)
if cache_dir:
self._config(cache_dir)
logger.debug(
"Init temp dir executor in dir '%s'", self._tmp_dir,
)
logger.debug("Init temp dir executor in dir '%s'", self._tmp_dir)
def _config(self, cache_dir):
local_config = os.path.join(self.dvc_dir, "config.local")
+2 -6
View File
@@ -62,11 +62,7 @@ def _get_exp_ref(repo, git_remote, exp_name):
return exp_refs[0]
def _pull_cache(
repo, exp_ref, dvc_remote=None, jobs=None, run_cache=False,
):
def _pull_cache(repo, exp_ref, dvc_remote=None, jobs=None, run_cache=False):
revs = list(exp_commits(repo.scm, [exp_ref]))
logger.debug("dvc fetch experiment '%s'", exp_ref)
repo.fetch(
jobs=jobs, remote=dvc_remote, run_cache=run_cache, revs=revs,
)
repo.fetch(jobs=jobs, remote=dvc_remote, run_cache=run_cache, revs=revs)
+3 -7
View File
@@ -12,7 +12,7 @@ logger = logging.getLogger(__name__)
@locked
@scm_context
def push(
repo, git_remote, exp_name, *args, force=False, push_cache=False, **kwargs,
repo, git_remote, exp_name, *args, force=False, push_cache=False, **kwargs
):
exp_ref = _get_exp_ref(repo, exp_name)
@@ -62,11 +62,7 @@ def _get_exp_ref(repo, exp_name):
return exp_refs[0]
def _push_cache(
repo, exp_ref, dvc_remote=None, jobs=None, run_cache=False,
):
def _push_cache(repo, exp_ref, dvc_remote=None, jobs=None, run_cache=False):
revs = list(exp_commits(repo.scm, [exp_ref]))
logger.debug("dvc push experiment '%s'", exp_ref)
repo.push(
jobs=jobs, remote=dvc_remote, run_cache=run_cache, revs=revs,
)
repo.push(jobs=jobs, remote=dvc_remote, run_cache=run_cache, revs=revs)
+1 -1
View File
@@ -56,7 +56,7 @@ def _get_ref(ref_infos, name, cur_rev):
f"Ambiguous name '{name}' refers to multiple "
"experiments. Use full refname to remove one of "
"the following:"
),
)
]
msg.extend([f"\t{info}" for info in ref_infos])
raise InvalidArgumentError("\n".join(msg))
+1 -1
View File
@@ -131,7 +131,7 @@ def show(
for ref in repo.scm.iter_refs(base=str(ref_info))
]
for exp_ref, _ in sorted(
commits, key=lambda x: x[1].commit_time, reverse=True,
commits, key=lambda x: x[1].commit_time, reverse=True
):
ref_info = ExpRefInfo.from_ref(exp_ref)
assert ref_info.baseline_sha == rev
+3 -5
View File
@@ -60,7 +60,7 @@ def fetch(
if run_cache:
self.stage_cache.pull(remote)
downloaded += self.cloud.pull(
used, jobs, remote=remote, show_checksums=show_checksums,
used, jobs, remote=remote, show_checksums=show_checksums
)
except NoRemoteError:
if not used.external and used["local"]:
@@ -111,10 +111,8 @@ def _fetch_external(self, repo_url, repo_rev, files, jobs):
cb(repo.cloud.pull(used, jobs))
except (NoOutputOrStageError, NoRemoteError):
pass
obj = stage(odb, path_info, repo.repo_fs, "md5", jobs=jobs,)
save(
odb, obj, jobs=jobs, download_callback=cb,
)
obj = stage(odb, path_info, repo.repo_fs, "md5", jobs=jobs)
save(odb, obj, jobs=jobs, download_callback=cb)
except CloneError:
failed += 1
logger.exception(
+1 -3
View File
@@ -4,9 +4,7 @@ from dvc.exceptions import PathMissingError
from dvc.path_info import PathInfo
def ls(
url, path=None, rev=None, recursive=None, dvc_only=False,
):
def ls(url, path=None, rev=None, recursive=None, dvc_only=False):
"""Methods for getting files and outputs for the repo.
Args:
+1 -1
View File
@@ -62,7 +62,7 @@ def move(self, from_path, to_path):
)
to_path = os.path.relpath(to_path, new_wdir)
new_stage = self.stage.create(
single_stage=True, fname=new_fname, wdir=new_wdir, outs=[to_path],
single_stage=True, fname=new_fname, wdir=new_wdir, outs=[to_path]
)
os.unlink(stage.path)
+1 -1
View File
@@ -189,7 +189,7 @@ class CSVPlotData(PlotData):
if header:
reader = csv.DictReader(
io.StringIO(self.content), delimiter=self.delimiter,
io.StringIO(self.content), delimiter=self.delimiter
)
else:
reader = csv.DictReader(
+1 -1
View File
@@ -386,7 +386,7 @@ class ScatterTemplate(Template):
},
}
],
},
}
],
},
],
+4 -4
View File
@@ -57,7 +57,7 @@ def _collect_with_deps(stages: StageList, graph: "DiGraph") -> StageSet:
def _maybe_collect_from_dvc_yaml(
loader: "StageLoad", target, with_deps: bool, **load_kwargs,
loader: "StageLoad", target, with_deps: bool, **load_kwargs
) -> StageIter:
from dvc.stage.exceptions import StageNotFound
@@ -90,7 +90,7 @@ def _collect_specific_target(
logger.debug(msg, target, PIPELINE_FILE)
if not (recursive and loader.fs.isdir(target)):
stages = _maybe_collect_from_dvc_yaml(
loader, target, with_deps, accept_group=accept_group,
loader, target, with_deps, accept_group=accept_group
)
if stages:
return stages, file, name
@@ -190,7 +190,7 @@ class StageLoad:
return stage
def from_target(
self, target: str, accept_group: bool = False, glob: bool = False,
self, target: str, accept_group: bool = False, glob: bool = False
) -> StageList:
"""
Returns a list of stage from the provided target.
@@ -198,7 +198,7 @@ class StageLoad:
"""
path, name = parse_target(target, isa_glob=glob)
return self.load_all(
path=path, name=name, accept_group=accept_group, glob=glob,
path=path, name=name, accept_group=accept_group, glob=glob
)
def get_target(self, target: str) -> "Stage":
+1 -4
View File
@@ -61,10 +61,7 @@ PLOT_PROPS = {
BaseOutput.PARAM_PLOT_TITLE: str,
BaseOutput.PARAM_PLOT_HEADER: bool,
}
PLOT_PROPS_SCHEMA = {
**OUT_PSTAGE_DETAILED_SCHEMA[str],
**PLOT_PROPS,
}
PLOT_PROPS_SCHEMA = {**OUT_PSTAGE_DETAILED_SCHEMA[str], **PLOT_PROPS}
PLOT_PSTAGE_SCHEMA = {str: Any(PLOT_PROPS_SCHEMA, [PLOT_PROPS_SCHEMA])}
LIVE_PROPS = {
+2 -3
View File
@@ -92,8 +92,7 @@ class Base:
return [self.ignore(path) for path in p_list]
def add(self, paths):
"""Makes SCM start tracking every path from a specified list of paths.
"""
"""Makes SCM track every path from a specified list of paths."""
def commit(self, msg):
"""Makes SCM create a commit."""
@@ -197,7 +196,7 @@ class Base:
"""Return boolean whether file belongs to scm"""
def close(self):
""" Method to close the files """
"""Method to close the files"""
def _reset(self) -> None:
pass
+1 -1
View File
@@ -405,7 +405,7 @@ class DulwichBackend(BaseGitBackend): # pylint:disable=abstract-method
overwrite = False
if on_diverged:
overwrite = on_diverged(
os.fsdecode(ref), os.fsdecode(remote_sha),
os.fsdecode(ref), os.fsdecode(remote_sha)
)
if not overwrite:
continue
+1 -1
View File
@@ -274,7 +274,7 @@ class GitPythonBackend(BaseGitBackend): # pylint:disable=abstract-method
return [
c.hexsha
for c in self.repo.iter_commits(
rev=head, branches=True, tags=True, remotes=True,
rev=head, branches=True, tags=True, remotes=True
)
]
+1 -1
View File
@@ -475,7 +475,7 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
with self.release_odb_handles():
self.repo.checkout_index(
index=index, paths=path_list, strategy=strategy,
index=index, paths=path_list, strategy=strategy
)
if index.conflicts and (ours or theirs):
+1 -1
View File
@@ -30,7 +30,7 @@ class Stash:
return list(iter(self))
def push(
self, message: Optional[str] = None, include_untracked: bool = False,
self, message: Optional[str] = None, include_untracked: bool = False
) -> Optional[str]:
if not self.scm.is_dirty(untracked_files=include_untracked):
logger.debug("No changes to stash")
+1 -1
View File
@@ -127,7 +127,7 @@ class StageLoader(Mapping):
if self.lockfile_data and name not in self.lockfile_data:
self.lockfile_needs_update()
logger.trace( # type: ignore[attr-defined]
"No lock entry found for '%s:%s'", self.dvcfile.relpath, name,
"No lock entry found for '%s:%s'", self.dvcfile.relpath, name
)
resolved_stage = resolved_data[name]
+1 -1
View File
@@ -101,7 +101,7 @@ class Monitor:
self.done = threading.Event()
self.tasks = tasks
self.monitor_thread = threading.Thread(
target=Monitor._loop, args=(self.tasks, self.done,),
target=Monitor._loop, args=(self.tasks, self.done)
)
def __enter__(self):
+2 -3
View File
@@ -28,8 +28,7 @@ def check_stage_path(repo, path, is_wdir=False):
assert repo is not None
error_msg = "{wdir_or_path} '{path}' {{}}".format(
wdir_or_path="stage working dir" if is_wdir else "file path",
path=path,
wdir_or_path="stage working dir" if is_wdir else "file path", path=path
)
real_path = os.path.realpath(path)
@@ -304,7 +303,7 @@ def _check_stage_exists(
def validate_state(
repo: "Repo", new: Union["Stage", "PipelineStage"], force: bool = False,
repo: "Repo", new: Union["Stage", "PipelineStage"], force: bool = False
) -> None:
"""Validates that the new stage:
+2 -2
View File
@@ -35,7 +35,7 @@ class Formatter:
class Console:
def __init__(
self, formatter: Formatter = None, enable: bool = False,
self, formatter: Formatter = None, enable: bool = False
) -> None:
self.formatter: Formatter = formatter or Formatter()
self._enabled: bool = enable
@@ -164,7 +164,7 @@ class Console:
return
return t.plain_table(
self, data, headers, markdown=markdown, pager=pager, force=force,
self, data, headers, markdown=markdown, pager=pager, force=force
)
+4 -10
View File
@@ -42,7 +42,7 @@ def _fobj_md5(fobj, hash_md5, binary, progress_func=None):
def file_md5(fname, fs):
""" get the (md5 hexdigest, md5 digest) of a file """
"""get the (md5 hexdigest, md5 digest) of a file"""
from dvc.istextfile import istextfile
from dvc.progress import Tqdm
@@ -215,7 +215,7 @@ def fix_env(env=None):
def tmp_fname(fname=""):
""" Temporary name for a partial download """
"""Temporary name for a partial download"""
from shortuuid import uuid
return os.fspath(fname) + "." + uuid() + ".tmp"
@@ -232,10 +232,7 @@ def colorize(message, color=None, style=None):
if not color:
return message
styles = {
"dim": colorama.Style.DIM,
"bold": colorama.Style.BRIGHT,
}
styles = {"dim": colorama.Style.DIM, "bold": colorama.Style.BRIGHT}
colors = {
"green": colorama.Fore.GREEN,
@@ -435,10 +432,7 @@ def parse_target(
if not match:
return target, None
path, name = (
match.group("path"),
match.group("name"),
)
path, name = (match.group("path"), match.group("name"))
if name and key:
name += f"{JOIN}{key}"
+1 -1
View File
@@ -8,7 +8,7 @@ def join(words):
return (
"{before} and {after}".format(
before=", ".join(words[:-1]), after=words[-1],
before=", ".join(words[:-1]), after=words[-1]
)
if len(words) > 1
else words[0]
+1 -1
View File
@@ -91,7 +91,7 @@ class Table(RichTable):
return widths
def _collapse_widths( # type: ignore[override]
self, widths: List[int], wrapable: List[bool], max_width: int,
self, widths: List[int], wrapable: List[bool], max_width: int
) -> List[int]:
"""Collapse columns right-to-left if possible to fit table into
max_width.
+9 -3
View File
@@ -43,7 +43,9 @@ version = dvc_version.__version__
)
check_call(
["python", "build.py"], cwd=pyinstaller, stderr=STDOUT,
["python", "build.py"],
cwd=pyinstaller,
stderr=STDOUT,
)
if args.sign_application:
@@ -60,11 +62,15 @@ if args.sign_application:
if args.pkg == "exe":
check_call(
["python", "build.py"], cwd=innosetup, stderr=STDOUT,
["python", "build.py"],
cwd=innosetup,
stderr=STDOUT,
)
else:
check_call(
["python", "build.py", args.pkg], cwd=fpm, stderr=STDOUT,
["python", "build.py", args.pkg],
cwd=fpm,
stderr=STDOUT,
)
if args.sign_installer:
+3 -1
View File
@@ -60,5 +60,7 @@ config = {
(path / "config.json").write_text(json.dumps(config))
check_call(
["gon", "config.json"], cwd=path, stderr=STDOUT,
["gon", "config.json"],
cwd=path,
stderr=STDOUT,
)
+2 -1
View File
@@ -50,5 +50,6 @@ check_call(
)
check_call(
["pkgutil", "--check-signature", os.fspath(pkg)], stderr=STDOUT,
["pkgutil", "--check-signature", os.fspath(pkg)],
stderr=STDOUT,
)
+3 -1
View File
@@ -38,5 +38,7 @@ with (path / "config.ini").open("w") as fobj:
cfg.write(fobj)
check_call(
["iscc", "setup.iss"], cwd=path, stderr=STDOUT,
["iscc", "setup.iss"],
cwd=path,
stderr=STDOUT,
)
+1 -1
View File
@@ -85,7 +85,7 @@ def test_reset_checkpoint(
tmp_dir, scm, dvc, checkpoint_stage, caplog, workspace
):
dvc.experiments.run(
checkpoint_stage.addressing, name="foo", tmp_dir=not workspace,
checkpoint_stage.addressing, name="foo", tmp_dir=not workspace
)
results = dvc.experiments.run(
+1 -4
View File
@@ -2,10 +2,7 @@ from funcy import first
def test_diff_empty(tmp_dir, scm, dvc, exp_stage):
assert dvc.experiments.diff() == {
"params": {},
"metrics": {},
}
assert dvc.experiments.diff() == {"params": {}, "metrics": {}}
def test_diff_head(tmp_dir, scm, dvc, exp_stage):
+1 -3
View File
@@ -449,9 +449,7 @@ def test_list(tmp_dir, scm, dvc, exp_stage):
exp_c = first(results)
ref_info_c = first(exp_refs_by_rev(scm, exp_c))
assert dvc.experiments.ls() == {
baseline_c: [ref_info_c.name],
}
assert dvc.experiments.ls() == {baseline_c: [ref_info_c.name]}
exp_list = dvc.experiments.ls(rev=ref_info_a.baseline_sha)
assert {key: set(val) for key, val in exp_list.items()} == {
+4 -4
View File
@@ -17,7 +17,7 @@ from dvc.utils.serialize import dump_yaml, modify_yaml
def test_show_simple(tmp_dir, dvc, run_copy_metrics):
tmp_dir.gen("metrics_t.yaml", "1.1")
run_copy_metrics(
"metrics_t.yaml", "metrics.yaml", metrics=["metrics.yaml"],
"metrics_t.yaml", "metrics.yaml", metrics=["metrics.yaml"]
)
assert dvc.metrics.show() == {"": {"metrics.yaml": 1.1}}
@@ -25,7 +25,7 @@ def test_show_simple(tmp_dir, dvc, run_copy_metrics):
def test_show(tmp_dir, dvc, run_copy_metrics):
tmp_dir.gen("metrics_t.yaml", "foo: 1.1")
run_copy_metrics(
"metrics_t.yaml", "metrics.yaml", metrics=["metrics.yaml"],
"metrics_t.yaml", "metrics.yaml", metrics=["metrics.yaml"]
)
assert dvc.metrics.show() == {"": {"metrics.yaml": {"foo": 1.1}}}
@@ -92,12 +92,12 @@ def test_show_subrepo_with_preexisting_tags(tmp_dir, scm):
def test_missing_cache(tmp_dir, dvc, run_copy_metrics):
tmp_dir.gen("metrics_t.yaml", "1.1")
run_copy_metrics(
"metrics_t.yaml", "metrics.yaml", metrics=["metrics.yaml"],
"metrics_t.yaml", "metrics.yaml", metrics=["metrics.yaml"]
)
# This one should be skipped
stage = run_copy_metrics(
"metrics_t.yaml", "metrics2.yaml", metrics=["metrics2.yaml"],
"metrics_t.yaml", "metrics2.yaml", metrics=["metrics2.yaml"]
)
remove(stage.outs[0].fspath)
remove(stage.outs[0].cache_path)
+3 -3
View File
@@ -164,7 +164,7 @@ def test_vars_shows_on_params_diff(tmp_dir, scm, dvc):
dump_yaml(params_file, param_data)
assert dvc.params.diff() == {
"test_params.yaml": {
"vars.model1.epoch": {"new": 20, "old": 15, "diff": 5},
"vars.model1.epoch": {"new": 20, "old": 15, "diff": 5}
}
}
@@ -173,7 +173,7 @@ def test_vars_shows_on_params_diff(tmp_dir, scm, dvc):
with data_dir.chdir():
assert dvc.params.diff() == {
relpath(params_file): {
"vars.model1.epoch": {"new": 20, "old": 15, "diff": 5},
"vars.model1.epoch": {"new": 20, "old": 15, "diff": 5}
}
}
@@ -217,5 +217,5 @@ def test_diff_targeted(tmp_dir, scm, dvc, run_copy):
}
assert dvc.params.diff(a_rev="HEAD~2", targets=["other_params.yaml"]) == {
"other_params.yaml": {"xyz": {"old": "val", "new": "val3"}},
"other_params.yaml": {"xyz": {"old": "val", "new": "val3"}}
}
+3 -3
View File
@@ -180,7 +180,7 @@ def test_foreach_data_key_does_not_exists(tmp_dir, dvc, key):
@pytest.mark.parametrize(
"foreach_data", ["${foo}", "${dct.model1}", "${lst.0}", "foobar"],
"foreach_data", ["${foo}", "${dct.model1}", "${lst.0}", "foobar"]
)
def test_foreach_data_expects_list_or_dict(tmp_dir, dvc, foreach_data):
context = Context(
@@ -208,7 +208,7 @@ def test_foreach_overwriting_item_in_list(
):
context = Context(global_data)
definition = make_foreach_def(
tmp_dir, "build", {"model1": 10, "model2": 5}, {}, context,
tmp_dir, "build", {"model1": 10, "model2": 5}, {}, context
)
with caplog.at_level(logging.WARNING, logger="dvc.parsing"):
definition.resolve_all()
@@ -221,7 +221,7 @@ def test_foreach_overwriting_item_in_list(
def test_foreach_do_syntax_errors(tmp_dir, dvc):
definition = make_foreach_def(
tmp_dir, "build", ["foo", "bar"], {"cmd": "echo ${syntax.[error}"},
tmp_dir, "build", ["foo", "bar"], {"cmd": "echo ${syntax.[error}"}
)
with pytest.raises(ResolveError) as exc_info:
+1 -4
View File
@@ -130,10 +130,7 @@ def test_params_file_with_dict_tracked(tmp_dir, dvc):
def test_params_file_tracked_for_composite_list(tmp_dir, dvc):
foreach_data = [
{"thresh": "foo"},
{"thresh": "bar"},
]
foreach_data = [{"thresh": "foo"}, {"thresh": "bar"}]
params = {"models": foreach_data}
dump_yaml("params.yaml", params)
@@ -90,8 +90,8 @@ def test_stage_with_wdir(tmp_dir, dvc):
"params": ["value1"],
"wdir": "data",
"vars": [DEFAULT_PARAMS_FILE],
},
},
}
}
}
data_dir = tmp_dir / "data"
@@ -132,8 +132,8 @@ def test_with_templated_wdir(tmp_dir, dvc):
"params": ["value1"],
"wdir": "${dict.ws}",
"vars": [DEFAULT_PARAMS_FILE],
},
},
}
}
}
dump_yaml(
tmp_dir / DEFAULT_PARAMS_FILE, {"dict": {"bar": "bar", "ws": "data"}}
@@ -176,7 +176,7 @@ def test_resolve_local_tries_to_load_globally_used_files(tmp_dir, dvc):
"cmd": "command --value ${bar}",
"params": [{"params.json": ["foo"]}],
"vars": ["params.json"],
},
}
},
}
resolver = DataResolver(dvc, PathInfo(str(tmp_dir)), d)
@@ -187,7 +187,7 @@ def test_resolve_local_tries_to_load_globally_used_files(tmp_dir, dvc):
"build": {
"cmd": "command --value bar",
"params": [{"params.json": ["foo"]}],
},
}
}
},
)
@@ -204,8 +204,8 @@ def test_resolve_local_tries_to_load_globally_used_params_yaml(tmp_dir, dvc):
"cmd": "command --value ${bar}",
"params": [{"params.yaml": ["foo"]}],
"vars": ["params.yaml"],
},
},
}
}
}
resolver = DataResolver(dvc, PathInfo(str(tmp_dir)), d)
assert_stage_equal(
@@ -215,7 +215,7 @@ def test_resolve_local_tries_to_load_globally_used_params_yaml(tmp_dir, dvc):
"build": {
"cmd": "command --value bar",
"params": [{"params.yaml": ["foo"]}],
},
}
}
},
)
+1 -1
View File
@@ -172,7 +172,7 @@ def test_vars_already_loaded_message(tmp_dir, dvc, local, vars_):
@pytest.mark.parametrize(
"vars_, loc", [(DATA, "build.vars[0]"), ("params.json", "params.json")],
"vars_, loc", [(DATA, "build.vars[0]"), ("params.json", "params.json")]
)
def test_local_overwrite_error(tmp_dir, dvc, vars_, loc):
dump_yaml(DEFAULT_PARAMS_FILE, DATA)
+1 -3
View File
@@ -6,7 +6,5 @@ import pytest
@pytest.fixture()
def custom_template(tmp_dir, dvc):
template = tmp_dir / "custom_template.json"
shutil.copy(
tmp_dir / ".dvc" / "plots" / "default.json", template,
)
shutil.copy(tmp_dir / ".dvc" / "plots" / "default.json", template)
return template
+2 -7
View File
@@ -67,19 +67,14 @@ def test_unset_nonexistent(tmp_dir, dvc, run_copy_metrics, custom_template):
)
with pytest.raises(PropsNotFoundError):
dvc.plots.modify(
"metric.json", unset=["nonexistent"],
)
dvc.plots.modify("metric.json", unset=["nonexistent"])
def test_dir_plots(tmp_dir, dvc, run_copy_metrics):
subdir = tmp_dir / "subdir"
subdir.mkdir()
metric = [
{"first_val": 100, "val": 2},
{"first_val": 200, "val": 3},
]
metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}]
fname = "file.json"
_write_json(tmp_dir, metric, fname)
+7 -28
View File
@@ -146,10 +146,7 @@ def test_plot_json_single_val(tmp_dir, scm, dvc, run_copy_metrics):
def test_plot_json_multiple_val(tmp_dir, scm, dvc, run_copy_metrics):
metric = [
{"first_val": 100, "val": 2},
{"first_val": 200, "val": 3},
]
metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}]
_write_json(tmp_dir, metric, "metric_t.json")
run_copy_metrics(
"metric_t.json",
@@ -622,10 +619,7 @@ def test_multiple_plots(tmp_dir, scm, dvc, run_copy_metrics):
@pytest.mark.parametrize("use_dvc", [True, False])
def test_show_non_plot(tmp_dir, scm, use_dvc):
metric = [
{"first_val": 100, "val": 2},
{"first_val": 200, "val": 3},
]
metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}]
_write_json(tmp_dir, metric, "metric.json")
if use_dvc:
@@ -660,10 +654,7 @@ def test_show_non_plot(tmp_dir, scm, use_dvc):
def test_show_non_plot_and_plot_with_params(
tmp_dir, scm, dvc, run_copy_metrics
):
metric = [
{"first_val": 100, "val": 2},
{"first_val": 200, "val": 3},
]
metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}]
_write_json(tmp_dir, metric, "metric.json")
run_copy_metrics(
"metric.json", "metric2.json", plots_no_cache=["metric2.json"]
@@ -684,10 +675,7 @@ def test_show_non_plot_and_plot_with_params(
def test_show_no_repo(tmp_dir):
metric = [
{"first_val": 100, "val": 2},
{"first_val": 200, "val": 3},
]
metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}]
_write_json(tmp_dir, metric, "metric.json")
dvc = Repo(uninitialized=True)
@@ -699,10 +687,7 @@ def test_show_from_subdir(tmp_dir, dvc, caplog):
subdir = tmp_dir / "subdir"
subdir.mkdir()
metric = [
{"first_val": 100, "val": 2},
{"first_val": 200, "val": 3},
]
metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}]
_write_json(subdir, metric, "metric.json")
with subdir.chdir(), caplog.at_level(logging.INFO, "dvc"):
@@ -766,10 +751,7 @@ def test_dir_plots(tmp_dir, dvc, run_copy_metrics):
subdir = tmp_dir / "subdir"
subdir.mkdir()
metric = [
{"first_val": 100, "val": 2},
{"first_val": 200, "val": 3},
]
metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}]
fname = "file.json"
_write_json(tmp_dir, metric, fname)
@@ -798,10 +780,7 @@ def test_dir_plots(tmp_dir, dvc, run_copy_metrics):
def test_show_dir_plots(tmp_dir, dvc, run_copy_metrics):
subdir = tmp_dir / "subdir"
subdir.mkdir()
metric = [
{"first_val": 100, "val": 2},
{"first_val": 200, "val": 3},
]
metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}]
fname = "file.json"
_write_json(tmp_dir, metric, fname)
+4 -4
View File
@@ -59,7 +59,7 @@ def test_add(tmp_dir, dvc):
"path": "foo",
"size": 3,
}
],
]
}
@@ -78,7 +78,7 @@ def test_add_executable(tmp_dir, dvc):
"size": 3,
"isexec": True,
}
],
]
}
assert os.stat("foo").st_mode & stat.S_IEXEC
@@ -1052,7 +1052,7 @@ def test_add_to_remote_absolute(tmp_dir, make_tmp_dir, dvc, local_remote):
[
("multiple targets", {"targets": ["foo", "bar", "baz"]}),
("--no-commit", {"targets": ["foo"], "no_commit": True}),
("--recursive", {"targets": ["foo"], "recursive": True},),
("--recursive", {"targets": ["foo"], "recursive": True}),
("--external", {"targets": ["foo"], "external": True}),
],
)
@@ -1132,7 +1132,7 @@ def test_add_to_cache_not_exists(tmp_dir, dvc, local_cloud):
[
("multiple targets", {"targets": ["foo", "bar", "baz"]}),
("--no-commit", {"targets": ["foo"], "no_commit": True}),
("--recursive", {"targets": ["foo"], "recursive": True},),
("--recursive", {"targets": ["foo"], "recursive": True}),
],
)
def test_add_to_cache_invalid_combinations(dvc, invalid_opt, kwargs):
+1 -1
View File
@@ -206,7 +206,7 @@ def test_open_rev(tmp_dir, scm, dvc):
ids=["file", "inside-dir"],
)
def test_api_missing_local_cache_exists_on_remote(
tmp_dir, scm, dvc, as_external, remote, files, to_read,
tmp_dir, scm, dvc, as_external, remote, files, to_read
):
tmp_dir.dvc_gen(files, commit="DVC track files")
dvc.push()
+1 -1
View File
@@ -94,7 +94,7 @@ def test_check_ignore_sub_repo(tmp_dir, dvc, capsys):
assert main(["check-ignore", "-d", os.path.join("dir", "foo")]) == 0
out, _ = capsys.readouterr()
assert (
"in sub_repo:{}\t{}".format("dir", os.path.join("dir", "foo"),) in out
"in sub_repo:{}\t{}".format("dir", os.path.join("dir", "foo")) in out
)
+1 -1
View File
@@ -388,7 +388,7 @@ class TestCheckoutHook(TestDvc):
@patch("sys.stdout.isatty", return_value=True)
@patch("dvc.prompt.input", side_effect=EOFError)
def test(self, _mock_input, _mock_isatty):
""" Test that dvc checkout handles EOFError gracefully, which is what
"""Test that dvc checkout handles EOFError gracefully, which is what
it will experience when running in a git hook.
"""
stages = self.dvc.add(self.DATA_DIR)

Some files were not shown because too many files have changed in this diff Show More