mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-26 23:09:35 +01:00
Merge branch 'master' into close-1652
This commit is contained in:
@@ -26,6 +26,10 @@
|
||||
:target: https://www.patreon.com/DVCorg/overview
|
||||
:alt: Donate
|
||||
|
||||
.. image:: https://anaconda.org/conda-forge/dvc/badges/version.svg
|
||||
:target: https://anaconda.org/conda-forge/dvc
|
||||
:alt: Conda-forge
|
||||
|
||||
|
|
||||
|
||||
**Data Version Control** or **DVC** is an **open-source** tool for data science and machine
|
||||
|
||||
@@ -253,6 +253,7 @@ class Config(object): # pylint: disable=too-many-instance-attributes
|
||||
SECTION_REMOTE_TIMEOUT = "timeout"
|
||||
SECTION_REMOTE_PASSWORD = "password"
|
||||
SECTION_REMOTE_ASK_PASSWORD = "ask_password"
|
||||
SECTION_REMOTE_GSS_AUTH = "gss_auth"
|
||||
SECTION_REMOTE_NO_TRAVERSE = "no_traverse"
|
||||
SECTION_REMOTE_SCHEMA = {
|
||||
SECTION_REMOTE_URL: str,
|
||||
@@ -273,6 +274,7 @@ class Config(object): # pylint: disable=too-many-instance-attributes
|
||||
Optional(SECTION_REMOTE_TIMEOUT): Use(int),
|
||||
Optional(SECTION_REMOTE_PASSWORD): str,
|
||||
Optional(SECTION_REMOTE_ASK_PASSWORD): BOOL_SCHEMA,
|
||||
Optional(SECTION_REMOTE_GSS_AUTH): BOOL_SCHEMA,
|
||||
Optional(SECTION_AZURE_CONNECTION_STRING): str,
|
||||
Optional(SECTION_OSS_ACCESS_KEY_ID): str,
|
||||
Optional(SECTION_OSS_ACCESS_KEY_SECRET): str,
|
||||
|
||||
+57
-33
@@ -2,8 +2,10 @@
|
||||
from __future__ import print_function
|
||||
import logging
|
||||
from tqdm import tqdm
|
||||
from copy import deepcopy
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from funcy import merge
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TqdmThreadPoolExecutor(ThreadPoolExecutor):
|
||||
@@ -33,45 +35,67 @@ class Tqdm(tqdm):
|
||||
maximum-compatibility tqdm-based progressbars
|
||||
"""
|
||||
|
||||
BAR_FMT_DEFAULT = (
|
||||
"{percentage:3.0f}%|{bar:10}|"
|
||||
"{desc:{ncols_desc}.{ncols_desc}}{n}/{total}"
|
||||
" [{elapsed}<{remaining}, {rate_fmt:>11}{postfix}]"
|
||||
)
|
||||
BAR_FMT_NOTOTAL = (
|
||||
"{desc:{ncols_desc}.{ncols_desc}}{n}"
|
||||
" [{elapsed}<??:??, {rate_fmt:>11}{postfix}]"
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
iterable=None,
|
||||
disable=None,
|
||||
level=logging.ERROR,
|
||||
desc=None,
|
||||
leave=False,
|
||||
bar_format=None,
|
||||
bytes=False, # pylint: disable=W0622
|
||||
desc_truncate=None,
|
||||
leave=None,
|
||||
**kwargs
|
||||
):
|
||||
"""
|
||||
bytes : shortcut for
|
||||
`unit='B', unit_scale=True, unit_divisor=1024, miniters=1`
|
||||
desc_truncate : like `desc` but will truncate to 10 chars
|
||||
desc : persists after `close()`
|
||||
level : effective logging level for determining `disable`;
|
||||
used only if `disable` is unspecified
|
||||
kwargs : anything accepted by `tqdm.tqdm()`
|
||||
"""
|
||||
kwargs = deepcopy(kwargs)
|
||||
kwargs = kwargs.copy()
|
||||
kwargs.setdefault("unit_scale", True)
|
||||
if bytes:
|
||||
for k, v in dict(
|
||||
bytes_defaults = dict(
|
||||
unit="B", unit_scale=True, unit_divisor=1024, miniters=1
|
||||
).items():
|
||||
kwargs.setdefault(k, v)
|
||||
if desc_truncate is not None:
|
||||
kwargs.setdefault("desc", self.truncate(desc_truncate))
|
||||
if disable is None:
|
||||
disable = (
|
||||
logging.getLogger(__name__).getEffectiveLevel()
|
||||
>= logging.CRITICAL
|
||||
)
|
||||
kwargs = merge(bytes_defaults, kwargs)
|
||||
self.desc_persist = desc
|
||||
if disable is None:
|
||||
disable = logger.getEffectiveLevel() > level
|
||||
super(Tqdm, self).__init__(
|
||||
iterable=iterable, disable=disable, leave=leave, **kwargs
|
||||
iterable=iterable,
|
||||
disable=disable,
|
||||
leave=leave,
|
||||
desc=desc,
|
||||
bar_format="!",
|
||||
**kwargs
|
||||
)
|
||||
if bar_format is None:
|
||||
if self.__len__():
|
||||
self.bar_format = self.BAR_FMT_DEFAULT
|
||||
else:
|
||||
self.bar_format = self.BAR_FMT_NOTOTAL
|
||||
else:
|
||||
self.bar_format = bar_format
|
||||
self.refresh()
|
||||
|
||||
def update_desc(self, desc, n=1, truncate=True):
|
||||
def update_desc(self, desc, n=1):
|
||||
"""
|
||||
Calls `set_description(truncate(desc))` and `update(n)`
|
||||
Calls `set_description_str(desc)` and `update(n)`
|
||||
"""
|
||||
self.set_description(
|
||||
self.truncate(desc) if truncate else desc, refresh=False
|
||||
)
|
||||
self.set_description_str(desc, refresh=False)
|
||||
self.update(n)
|
||||
|
||||
def update_to(self, current, total=None):
|
||||
@@ -79,16 +103,16 @@ class Tqdm(tqdm):
|
||||
self.total = total # pylint: disable=W0613,W0201
|
||||
self.update(current - self.n)
|
||||
|
||||
@classmethod
|
||||
def truncate(cls, s, max_len=25, end=True, fill="..."):
|
||||
"""
|
||||
Guarantee len(output) < max_lenself.
|
||||
>>> truncate("hello", 4)
|
||||
'...o'
|
||||
"""
|
||||
if len(s) <= max_len:
|
||||
return s
|
||||
if len(fill) > max_len:
|
||||
return fill[-max_len:] if end else fill[:max_len]
|
||||
i = max_len - len(fill)
|
||||
return (fill + s[-i:]) if end else (s[:i] + fill)
|
||||
def close(self):
|
||||
if self.desc_persist is not None:
|
||||
self.set_description_str(self.desc_persist, refresh=False)
|
||||
super(Tqdm, self).close()
|
||||
|
||||
@property
|
||||
def format_dict(self):
|
||||
"""inject `ncols_desc` to fill the display width (`ncols`)"""
|
||||
d = super(Tqdm, self).format_dict
|
||||
ncols = d["ncols"] or 80
|
||||
ncols_desc = ncols - len(self.format_meter(ncols_desc=1, **d)) + 1
|
||||
d["ncols_desc"] = max(ncols_desc, 0)
|
||||
return d
|
||||
|
||||
+2
-6
@@ -115,9 +115,7 @@ class RemoteAZURE(RemoteBASE):
|
||||
def _upload(
|
||||
self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs
|
||||
):
|
||||
with Tqdm(
|
||||
desc_truncate=name, disable=no_progress_bar, bytes=True
|
||||
) as pbar:
|
||||
with Tqdm(desc=name, disable=no_progress_bar, bytes=True) as pbar:
|
||||
self.blob_service.create_blob_from_path(
|
||||
to_info.bucket,
|
||||
to_info.path,
|
||||
@@ -128,9 +126,7 @@ class RemoteAZURE(RemoteBASE):
|
||||
def _download(
|
||||
self, from_info, to_file, name=None, no_progress_bar=False, **_kwargs
|
||||
):
|
||||
with Tqdm(
|
||||
desc_truncate=name, disable=no_progress_bar, bytes=True
|
||||
) as pbar:
|
||||
with Tqdm(desc=name, disable=no_progress_bar, bytes=True) as pbar:
|
||||
self.blob_service.get_blob_to_path(
|
||||
from_info.bucket,
|
||||
from_info.path,
|
||||
|
||||
+24
-11
@@ -102,10 +102,10 @@ class RemoteBASE(object):
|
||||
" pip install {}\n"
|
||||
" 2) Install dvc package that includes those missing "
|
||||
"dependencies: \n"
|
||||
" pip install dvc[{}]\n"
|
||||
" pip install 'dvc[{}]'\n"
|
||||
" 3) Install dvc package with all possible "
|
||||
"dependencies included: \n"
|
||||
" pip install dvc[all]\n"
|
||||
" pip install 'dvc[all]'\n"
|
||||
"\n"
|
||||
"If you have installed dvc from a binary package and you "
|
||||
"are still seeing this message, please report it to us "
|
||||
@@ -584,7 +584,12 @@ class RemoteBASE(object):
|
||||
raise NotImplementedError
|
||||
|
||||
def path_to_checksum(self, path):
|
||||
return "".join(self.path_cls(path).parts[-2:])
|
||||
parts = self.path_cls(path).parts[-2:]
|
||||
|
||||
if not (len(parts) == 2 and parts[0] and len(parts[0]) == 2):
|
||||
raise ValueError("Bad cache file path")
|
||||
|
||||
return "".join(parts)
|
||||
|
||||
def checksum_to_path_info(self, checksum):
|
||||
return self.path_info / checksum[0:2] / checksum[2:]
|
||||
@@ -597,9 +602,12 @@ class RemoteBASE(object):
|
||||
# is 32 bytes, so ~3200Mb list) and we don't really need all of it at
|
||||
# the same time, so it makes sense to use a generator to gradually
|
||||
# iterate over it, without keeping all of it in memory.
|
||||
return (
|
||||
self.path_to_checksum(path) for path in self.list_cache_paths()
|
||||
)
|
||||
for path in self.list_cache_paths():
|
||||
try:
|
||||
yield self.path_to_checksum(path)
|
||||
except ValueError:
|
||||
# We ignore all the non-cache looking files
|
||||
pass
|
||||
|
||||
def gc(self, cinfos):
|
||||
used = self.extract_used_local_checksums(cinfos)
|
||||
@@ -672,7 +680,7 @@ class RemoteBASE(object):
|
||||
return self._changed_dir_cache(checksum)
|
||||
return self.changed_cache_file(checksum)
|
||||
|
||||
def cache_exists(self, checksums, jobs=None):
|
||||
def cache_exists(self, checksums, jobs=None, name=None):
|
||||
"""Check if the given checksums are stored in the remote.
|
||||
|
||||
There are two ways of performing this check:
|
||||
@@ -690,7 +698,7 @@ class RemoteBASE(object):
|
||||
take much shorter time to just retrieve everything they have under
|
||||
a certain prefix (e.g. s3, gs, ssh, hdfs). Other remotes that can
|
||||
check if particular file exists much quicker, use their own
|
||||
implementation of cache_exists (see http, local).
|
||||
implementation of cache_exists (see ssh, local).
|
||||
|
||||
Returns:
|
||||
A list with checksums that were found in the remote
|
||||
@@ -698,15 +706,20 @@ class RemoteBASE(object):
|
||||
if not self.no_traverse:
|
||||
return list(set(checksums) & set(self.all()))
|
||||
|
||||
with Tqdm(total=len(checksums), unit="md5") as pbar:
|
||||
with Tqdm(
|
||||
desc="Querying "
|
||||
+ ("cache in " + name if name else "remote cache"),
|
||||
total=len(checksums),
|
||||
unit="file",
|
||||
) as pbar:
|
||||
|
||||
def exists_with_progress(path_info):
|
||||
ret = self.exists(path_info)
|
||||
pbar.update()
|
||||
pbar.update_desc(str(path_info))
|
||||
return ret
|
||||
|
||||
with ThreadPoolExecutor(max_workers=jobs or self.JOBS) as executor:
|
||||
path_infos = [self.checksum_to_path_info(x) for x in checksums]
|
||||
path_infos = map(self.checksum_to_path_info, checksums)
|
||||
in_remote = executor.map(exists_with_progress, path_infos)
|
||||
ret = list(itertools.compress(checksums, in_remote))
|
||||
return ret
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ class RemoteHTTP(RemoteBASE):
|
||||
total=None if no_progress_bar else self._content_length(from_info),
|
||||
leave=False,
|
||||
bytes=True,
|
||||
desc_truncate=from_info.url if name is None else name,
|
||||
desc=from_info.url if name is None else name,
|
||||
disable=no_progress_bar,
|
||||
) as pbar:
|
||||
with open(to_file, "wb") as fd:
|
||||
|
||||
@@ -206,10 +206,15 @@ class RemoteLOCAL(RemoteBASE):
|
||||
def reflink(self, from_info, to_info):
|
||||
System.reflink(from_info.fspath, to_info.fspath)
|
||||
|
||||
def cache_exists(self, checksums, jobs=None):
|
||||
def cache_exists(self, checksums, jobs=None, name=None):
|
||||
return [
|
||||
checksum
|
||||
for checksum in Tqdm(checksums, unit="md5")
|
||||
for checksum in Tqdm(
|
||||
checksums,
|
||||
unit="file",
|
||||
desc="Querying "
|
||||
+ ("cache in " + name if name else "local cache"),
|
||||
)
|
||||
if not self.changed_cache_file(checksum)
|
||||
]
|
||||
|
||||
@@ -267,14 +272,14 @@ class RemoteLOCAL(RemoteBASE):
|
||||
show_checksums=False,
|
||||
download=False,
|
||||
):
|
||||
logger.info(
|
||||
logger.debug(
|
||||
"Preparing to collect status from {}".format(remote.path_info)
|
||||
)
|
||||
ret = self._group(checksum_infos, show_checksums=show_checksums) or {}
|
||||
md5s = list(ret)
|
||||
|
||||
logger.info("Collecting information from local cache...")
|
||||
local_exists = self.cache_exists(md5s, jobs=jobs)
|
||||
logger.debug("Collecting information from local cache...")
|
||||
local_exists = self.cache_exists(md5s, jobs=jobs, name=self.cache_dir)
|
||||
|
||||
# This is a performance optimization. We can safely assume that,
|
||||
# if the resources that we want to fetch are already cached,
|
||||
@@ -283,8 +288,12 @@ class RemoteLOCAL(RemoteBASE):
|
||||
if download and sorted(local_exists) == sorted(md5s):
|
||||
remote_exists = local_exists
|
||||
else:
|
||||
logger.info("Collecting information from remote cache...")
|
||||
remote_exists = list(remote.cache_exists(md5s, jobs=jobs))
|
||||
logger.debug("Collecting information from remote cache...")
|
||||
remote_exists = list(
|
||||
remote.cache_exists(
|
||||
md5s, jobs=jobs, name=str(remote.path_info)
|
||||
)
|
||||
)
|
||||
|
||||
self._fill_statuses(ret, local_exists, remote_exists)
|
||||
|
||||
@@ -331,7 +340,7 @@ class RemoteLOCAL(RemoteBASE):
|
||||
show_checksums=False,
|
||||
download=False,
|
||||
):
|
||||
logger.info(
|
||||
logger.debug(
|
||||
"Preparing to {} '{}'".format(
|
||||
"download data from" if download else "upload data to",
|
||||
remote.path_info,
|
||||
|
||||
+2
-6
@@ -107,9 +107,7 @@ class RemoteOSS(RemoteBASE):
|
||||
def _upload(
|
||||
self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs
|
||||
):
|
||||
with Tqdm(
|
||||
desc_truncate=name, disable=no_progress_bar, bytes=True
|
||||
) as pbar:
|
||||
with Tqdm(desc=name, disable=no_progress_bar, bytes=True) as pbar:
|
||||
self.oss_service.put_object_from_file(
|
||||
to_info.path, from_file, progress_callback=pbar.update_to
|
||||
)
|
||||
@@ -117,9 +115,7 @@ class RemoteOSS(RemoteBASE):
|
||||
def _download(
|
||||
self, from_info, to_file, name=None, no_progress_bar=False, **_kwargs
|
||||
):
|
||||
with Tqdm(
|
||||
desc_truncate=name, disable=no_progress_bar, bytes=True
|
||||
) as pbar:
|
||||
with Tqdm(desc=name, disable=no_progress_bar, bytes=True) as pbar:
|
||||
self.oss_service.get_object_to_file(
|
||||
from_info.path, to_file, progress_callback=pbar.update_to
|
||||
)
|
||||
|
||||
+2
-8
@@ -208,10 +208,7 @@ class RemoteS3(RemoteBASE):
|
||||
def _upload(self, from_file, to_info, name=None, no_progress_bar=False):
|
||||
total = os.path.getsize(from_file)
|
||||
with Tqdm(
|
||||
disable=no_progress_bar,
|
||||
total=total,
|
||||
bytes=True,
|
||||
desc_truncate=name,
|
||||
disable=no_progress_bar, total=total, bytes=True, desc=name
|
||||
) as pbar:
|
||||
self.s3.upload_file(
|
||||
from_file,
|
||||
@@ -229,10 +226,7 @@ class RemoteS3(RemoteBASE):
|
||||
Bucket=from_info.bucket, Key=from_info.path
|
||||
)["ContentLength"]
|
||||
with Tqdm(
|
||||
disable=no_progress_bar,
|
||||
total=total,
|
||||
bytes=True,
|
||||
desc_truncate=name,
|
||||
disable=no_progress_bar, total=total, bytes=True, desc=name
|
||||
) as pbar:
|
||||
self.s3.download_file(
|
||||
from_info.bucket, from_info.path, to_file, Callback=pbar.update
|
||||
|
||||
@@ -88,6 +88,7 @@ class RemoteSSH(RemoteBASE):
|
||||
self.ask_password = config.get(
|
||||
Config.SECTION_REMOTE_ASK_PASSWORD, False
|
||||
)
|
||||
self.gss_auth = config.get(Config.SECTION_REMOTE_GSS_AUTH, False)
|
||||
|
||||
@staticmethod
|
||||
def ssh_config_filename():
|
||||
@@ -146,6 +147,7 @@ class RemoteSSH(RemoteBASE):
|
||||
key_filename=self.keyfile,
|
||||
timeout=self.timeout,
|
||||
password=self.password,
|
||||
gss_auth=self.gss_auth,
|
||||
)
|
||||
|
||||
def exists(self, path_info):
|
||||
@@ -295,7 +297,7 @@ class RemoteSSH(RemoteBASE):
|
||||
|
||||
return results
|
||||
|
||||
def cache_exists(self, checksums, jobs=None):
|
||||
def cache_exists(self, checksums, jobs=None, name=None):
|
||||
"""This is older implementation used in remote/base.py
|
||||
We are reusing it in RemoteSSH, because SSH's batch_exists proved to be
|
||||
faster than current approach (relying on exists(path_info)) applied in
|
||||
@@ -304,7 +306,12 @@ class RemoteSSH(RemoteBASE):
|
||||
if not self.no_traverse:
|
||||
return list(set(checksums) & set(self.all()))
|
||||
|
||||
with Tqdm(total=len(checksums), unit="md5") as pbar:
|
||||
with Tqdm(
|
||||
desc="Querying "
|
||||
+ ("cache in " + name if name else "remote cache"),
|
||||
total=len(checksums),
|
||||
unit="file",
|
||||
) as pbar:
|
||||
|
||||
def exists_with_progress(chunks):
|
||||
return self.batch_exists(chunks, callback=pbar.update_desc)
|
||||
@@ -315,5 +322,4 @@ class RemoteSSH(RemoteBASE):
|
||||
results = executor.map(exists_with_progress, chunks)
|
||||
in_remote = itertools.chain.from_iterable(results)
|
||||
ret = list(itertools.compress(checksums, in_remote))
|
||||
pbar.update_desc("", 0) # clear path name description
|
||||
return ret
|
||||
|
||||
@@ -175,7 +175,7 @@ class SSHConnection:
|
||||
|
||||
def download(self, src, dest, no_progress_bar=False, progress_title=None):
|
||||
with Tqdm(
|
||||
desc_truncate=progress_title or os.path.basename(src),
|
||||
desc=progress_title or os.path.basename(src),
|
||||
disable=no_progress_bar,
|
||||
bytes=True,
|
||||
) as pbar:
|
||||
@@ -192,7 +192,7 @@ class SSHConnection:
|
||||
progress_title = posixpath.basename(dest)
|
||||
|
||||
with Tqdm(
|
||||
desc_truncate=progress_title, disable=no_progress_bar, bytes=True
|
||||
desc=progress_title, disable=no_progress_bar, bytes=True
|
||||
) as pbar:
|
||||
self.sftp.put(src, tmp_file, callback=pbar.update_to)
|
||||
|
||||
|
||||
+1
-20
@@ -164,7 +164,7 @@ class Repo(object):
|
||||
from dvc.stage import Stage
|
||||
|
||||
if not target or (recursive and os.path.isdir(target)):
|
||||
return self.active_stages(target)
|
||||
return self.stages(target)
|
||||
|
||||
stage = Stage.load(self, target)
|
||||
if not with_deps:
|
||||
@@ -183,7 +183,6 @@ class Repo(object):
|
||||
self,
|
||||
targets=None,
|
||||
all_branches=False,
|
||||
active=True,
|
||||
with_deps=False,
|
||||
all_tags=False,
|
||||
remote=None,
|
||||
@@ -225,20 +224,10 @@ class Repo(object):
|
||||
stages.extend(
|
||||
self.collect(target, with_deps=with_deps)
|
||||
)
|
||||
elif active:
|
||||
stages = self.active_stages()
|
||||
else:
|
||||
stages = self.stages()
|
||||
|
||||
for stage in stages:
|
||||
if active and not targets and stage.locked:
|
||||
logger.warning(
|
||||
"DVC-file '{path}' is locked. Its dependencies are"
|
||||
" not going to be pushed/pulled/fetched.".format(
|
||||
path=stage.relpath
|
||||
)
|
||||
)
|
||||
|
||||
for out in stage.outs:
|
||||
scheme = out.path_info.scheme
|
||||
used_cache = out.get_used_cache(
|
||||
@@ -413,14 +402,6 @@ class Repo(object):
|
||||
|
||||
return stages
|
||||
|
||||
def active_stages(self, from_directory=None):
|
||||
import networkx as nx
|
||||
|
||||
stages = []
|
||||
for G in self.pipelines(from_directory):
|
||||
stages.extend(list(nx.get_node_attributes(G, "stage").values()))
|
||||
return stages
|
||||
|
||||
def find_outs_by_path(self, path, outs=None, recursive=False):
|
||||
if not outs:
|
||||
# there is no `from_directory=path` argument because some data
|
||||
|
||||
@@ -38,6 +38,8 @@ def checkout(self, target=None, with_deps=False, force=False, recursive=False):
|
||||
with self.state:
|
||||
_cleanup_unused_links(self, all_stages)
|
||||
total = get_all_files_numbers(stages)
|
||||
if total == 0:
|
||||
logger.info("Nothing to do")
|
||||
with Tqdm(
|
||||
total=total, unit="file", desc="Checkout", disable=total == 0
|
||||
) as pbar:
|
||||
@@ -51,4 +53,3 @@ def checkout(self, target=None, with_deps=False, force=False, recursive=False):
|
||||
)
|
||||
|
||||
stage.checkout(force=force, progress_callback=pbar.update_desc)
|
||||
pbar.update_desc("Checkout", 0) # clear path name description
|
||||
|
||||
@@ -21,9 +21,7 @@ def _merge_cache_lists(clists):
|
||||
|
||||
def _load_all_used_cache(
|
||||
repos,
|
||||
target=None,
|
||||
all_branches=False,
|
||||
active=True,
|
||||
with_deps=False,
|
||||
all_tags=False,
|
||||
remote=None,
|
||||
@@ -37,7 +35,6 @@ def _load_all_used_cache(
|
||||
repo_clist = repo.used_cache(
|
||||
targets=None,
|
||||
all_branches=all_branches,
|
||||
active=False,
|
||||
with_deps=with_deps,
|
||||
all_tags=all_tags,
|
||||
remote=remote,
|
||||
@@ -76,9 +73,7 @@ def gc(
|
||||
|
||||
all_clists = _load_all_used_cache(
|
||||
all_repos,
|
||||
target=None,
|
||||
all_branches=all_branches,
|
||||
active=False,
|
||||
with_deps=with_deps,
|
||||
all_tags=all_tags,
|
||||
remote=remote,
|
||||
|
||||
@@ -4,6 +4,5 @@ def update(self, target):
|
||||
stage = Stage.load(self, target)
|
||||
with self.state:
|
||||
stage.update()
|
||||
stage.save()
|
||||
|
||||
stage.dump()
|
||||
|
||||
+14
-7
@@ -9,6 +9,7 @@ import subprocess
|
||||
import logging
|
||||
import signal
|
||||
import threading
|
||||
from itertools import chain
|
||||
|
||||
from dvc.utils import relpath
|
||||
from dvc.utils.compat import pathlib
|
||||
@@ -326,8 +327,6 @@ class Stage(object):
|
||||
if interactive and not prompt.confirm(msg):
|
||||
raise DvcException("reproduction aborted by the user")
|
||||
|
||||
logger.info("Reproducing '{stage}'".format(stage=self.relpath))
|
||||
|
||||
self.run(**kwargs)
|
||||
|
||||
logger.debug("'{stage}' was reproduced".format(stage=self.relpath))
|
||||
@@ -438,6 +437,7 @@ class Stage(object):
|
||||
wdir = kwargs.get("wdir", None)
|
||||
cwd = kwargs.get("cwd", None)
|
||||
fname = kwargs.get("fname", None)
|
||||
add = kwargs.get("add", False)
|
||||
|
||||
# Backward compatibility for `cwd` option
|
||||
if wdir is None and cwd is not None:
|
||||
@@ -449,8 +449,8 @@ class Stage(object):
|
||||
" directory.".format(fname=fname)
|
||||
)
|
||||
wdir = cwd
|
||||
else:
|
||||
wdir = os.curdir if wdir is None else wdir
|
||||
elif wdir is None:
|
||||
wdir = os.curdir
|
||||
|
||||
stage = Stage(
|
||||
repo=repo,
|
||||
@@ -468,11 +468,18 @@ class Stage(object):
|
||||
stage._check_duplicated_arguments()
|
||||
|
||||
if not fname:
|
||||
fname = Stage._stage_fname(
|
||||
stage.outs, add=kwargs.get("add", False)
|
||||
)
|
||||
fname = Stage._stage_fname(stage.outs, add)
|
||||
stage._check_dvc_filename(fname)
|
||||
|
||||
# Autodetecting wdir for add, we need to create outs first to do that,
|
||||
# so we start with wdir = . and remap out paths later.
|
||||
if add and kwargs.get("wdir") is None and cwd is None:
|
||||
wdir = os.path.dirname(fname)
|
||||
|
||||
for out in chain(stage.outs, stage.deps):
|
||||
if out.is_in_repo:
|
||||
out.def_path = relpath(out.path_info, wdir)
|
||||
|
||||
wdir = os.path.abspath(wdir)
|
||||
|
||||
if cwd is not None:
|
||||
|
||||
@@ -51,16 +51,16 @@ def file_md5(fname):
|
||||
hash_md5 = hashlib.md5()
|
||||
binary = not istextfile(fname)
|
||||
size = os.path.getsize(fname)
|
||||
bar = False
|
||||
no_progress_bar = True
|
||||
if size >= LARGE_FILE_SIZE:
|
||||
bar = True
|
||||
no_progress_bar = False
|
||||
msg = "Computing md5 for a large file {}. This is only done once."
|
||||
logger.info(msg.format(relpath(fname)))
|
||||
name = relpath(fname)
|
||||
|
||||
with Tqdm(
|
||||
desc_truncate=name,
|
||||
disable=not bar,
|
||||
desc=name,
|
||||
disable=no_progress_bar,
|
||||
total=size,
|
||||
bytes=True,
|
||||
leave=False,
|
||||
@@ -132,10 +132,7 @@ def copyfile(src, dest, no_progress_bar=False, name=None):
|
||||
System.reflink(src, dest)
|
||||
except DvcException:
|
||||
with Tqdm(
|
||||
desc_truncate=name,
|
||||
disable=no_progress_bar,
|
||||
total=total,
|
||||
bytes=True,
|
||||
desc=name, disable=no_progress_bar, total=total, bytes=True
|
||||
) as pbar:
|
||||
with open(src, "rb") as fsrc, open(dest, "wb+") as fdest:
|
||||
while True:
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import os
|
||||
import subprocess
|
||||
|
||||
|
||||
_BASE_VERSION = "0.56.0"
|
||||
_BASE_VERSION = "0.57.0"
|
||||
|
||||
|
||||
def _generate_version(base_version):
|
||||
|
||||
@@ -61,7 +61,7 @@ install_requires = [
|
||||
"funcy>=1.12",
|
||||
"pathspec>=0.5.9",
|
||||
"shortuuid>=0.5.0",
|
||||
"tqdm>=4.34.0",
|
||||
"tqdm>=4.35.0",
|
||||
"win-unicode-console>=0.5; sys_platform == 'win32'",
|
||||
]
|
||||
|
||||
@@ -71,11 +71,21 @@ else:
|
||||
install_requires.append("networkx>=2.1")
|
||||
|
||||
# Extra dependencies for remote integrations
|
||||
gs = ["google-cloud-storage==1.13.0"]
|
||||
|
||||
# Restricting google-resumable-media version is due to the fact that
|
||||
# since 0.3.3 our binaries built by pyinstaller started to fail on Linux and
|
||||
# macOS. This restriction will be removed after
|
||||
# https://github.com/iterative/dvc/issues/2441 is resolved.
|
||||
gs = ["google-resumable-media==0.3.2", "google-cloud-storage==1.13.0"]
|
||||
s3 = ["boto3==1.9.115"]
|
||||
azure = ["azure-storage-blob==2.1.0"]
|
||||
oss = ["oss2==2.6.1"]
|
||||
ssh = ["paramiko>=2.5.0"]
|
||||
# gssapi should not be included in all_remotes, because it doesn't have wheels
|
||||
# for linux and mac, so it will fail to compile if user doesn't have all the
|
||||
# requirements, including kerberos itself. Once all the wheels are available,
|
||||
# we can start shipping it by default.
|
||||
ssh_gssapi = ["paramiko[gssapi]>=2.5.0"]
|
||||
hdfs = ["pyarrow==0.14.0"]
|
||||
all_remotes = gs + s3 + azure + ssh + oss
|
||||
|
||||
@@ -131,6 +141,7 @@ setup(
|
||||
"azure": azure,
|
||||
"oss": oss,
|
||||
"ssh": ssh,
|
||||
"ssh_gssapi": ssh_gssapi,
|
||||
"hdfs": hdfs,
|
||||
# NOTE: https://github.com/inveniosoftware/troubleshooting/issues/1
|
||||
":python_version=='2.7'": ["futures", "pathlib2"],
|
||||
|
||||
+11
-9
@@ -169,15 +169,17 @@ class TestAddModifiedDir(TestDvc):
|
||||
self.assertTrue(stages[0] is not None)
|
||||
|
||||
|
||||
class TestAddFileInDir(TestDvc):
|
||||
def test(self):
|
||||
stages = self.dvc.add(self.DATA_SUB)
|
||||
self.assertEqual(len(stages), 1)
|
||||
stage = stages[0]
|
||||
self.assertNotEqual(stage, None)
|
||||
self.assertEqual(len(stage.deps), 0)
|
||||
self.assertEqual(len(stage.outs), 1)
|
||||
self.assertEqual(stage.relpath, self.DATA_SUB + ".dvc")
|
||||
def test_add_file_in_dir(repo_dir, dvc_repo):
|
||||
stage, = dvc_repo.add(repo_dir.DATA_SUB)
|
||||
|
||||
assert stage is not None
|
||||
assert len(stage.deps) == 0
|
||||
assert len(stage.outs) == 1
|
||||
assert stage.relpath == repo_dir.DATA_SUB + ".dvc"
|
||||
|
||||
# Current dir should not be taken into account
|
||||
assert stage.wdir == os.path.dirname(stage.path)
|
||||
assert stage.outs[0].def_path == "data_sub"
|
||||
|
||||
|
||||
class TestAddExternalLocalFile(TestDvc):
|
||||
|
||||
@@ -160,3 +160,25 @@ def test_ssh_keyfile(mock_file, mock_exists, config, expected_keyfile):
|
||||
mock_exists.assert_called_with(RemoteSSH.ssh_config_filename())
|
||||
mock_file.assert_called_with(RemoteSSH.ssh_config_filename())
|
||||
assert remote.keyfile == expected_keyfile
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"config,expected_gss_auth",
|
||||
[
|
||||
({"url": "ssh://example.com", "gss_auth": True}, True),
|
||||
({"url": "ssh://example.com", "gss_auth": False}, False),
|
||||
({"url": "ssh://not_in_ssh_config.com"}, False),
|
||||
],
|
||||
)
|
||||
@patch("os.path.exists", return_value=True)
|
||||
@patch(
|
||||
"{}.open".format(builtin_module_name),
|
||||
new_callable=mock_open,
|
||||
read_data=mock_ssh_config,
|
||||
)
|
||||
def test_ssh_gss_auth(mock_file, mock_exists, config, expected_gss_auth):
|
||||
remote = RemoteSSH(None, config)
|
||||
|
||||
mock_exists.assert_called_with(RemoteSSH.ssh_config_filename())
|
||||
mock_file.assert_called_with(RemoteSSH.ssh_config_filename())
|
||||
assert remote.gss_auth == expected_gss_auth
|
||||
|
||||
Reference in New Issue
Block a user