mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
import-url: only unpartial imports in workspace
This commit is contained in:
committed by
Ruslan Kuprieiev
parent
3478a7e6a9
commit
7fe316b8e8
+1
-1
@@ -108,7 +108,7 @@ def fetch(
|
|||||||
imported = save_imports(
|
imported = save_imports(
|
||||||
self,
|
self,
|
||||||
targets,
|
targets,
|
||||||
unpartial=rev == "workspace",
|
unpartial=not rev or rev == "workspace",
|
||||||
recursive=recursive,
|
recursive=recursive,
|
||||||
)
|
)
|
||||||
result.transferred.update(imported)
|
result.transferred.update(imported)
|
||||||
|
|||||||
+31
-7
@@ -14,7 +14,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def unfetched_view(
|
def unfetched_view(
|
||||||
index: "Index", targets: "TargetType", **kwargs
|
index: "Index", targets: "TargetType", unpartial: bool = False, **kwargs
|
||||||
) -> Tuple["IndexView", List["Dependency"]]:
|
) -> Tuple["IndexView", List["Dependency"]]:
|
||||||
"""Return index view of imports which have not been fetched.
|
"""Return index view of imports which have not been fetched.
|
||||||
|
|
||||||
@@ -26,6 +26,13 @@ def unfetched_view(
|
|||||||
changed_deps: List["Dependency"] = []
|
changed_deps: List["Dependency"] = []
|
||||||
|
|
||||||
def need_fetch(stage: "Stage") -> bool:
|
def need_fetch(stage: "Stage") -> bool:
|
||||||
|
if (
|
||||||
|
not stage.is_import
|
||||||
|
or stage.is_repo_import
|
||||||
|
or (stage.is_partial_import and not unpartial)
|
||||||
|
):
|
||||||
|
return False
|
||||||
|
|
||||||
out = stage.outs[0]
|
out = stage.outs[0]
|
||||||
if not out.changed_cache():
|
if not out.changed_cache():
|
||||||
return False
|
return False
|
||||||
@@ -41,6 +48,16 @@ def unfetched_view(
|
|||||||
return unfetched, changed_deps
|
return unfetched, changed_deps
|
||||||
|
|
||||||
|
|
||||||
|
def partial_view(
|
||||||
|
index: "Index", targets: "TargetType", **kwargs
|
||||||
|
) -> "IndexView":
|
||||||
|
return index.targets_view(
|
||||||
|
targets,
|
||||||
|
filter_fn=lambda s: s.is_partial_import,
|
||||||
|
**kwargs,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def unpartial_imports(index: Union["Index", "IndexView"]) -> int:
|
def unpartial_imports(index: Union["Index", "IndexView"]) -> int:
|
||||||
"""Update any outs in the index which are no longer partial imports.
|
"""Update any outs in the index which are no longer partial imports.
|
||||||
|
|
||||||
@@ -54,8 +71,13 @@ def unpartial_imports(index: Union["Index", "IndexView"]) -> int:
|
|||||||
workspace, key = out.index_key
|
workspace, key = out.index_key
|
||||||
entry = index.data[workspace][key]
|
entry = index.data[workspace][key]
|
||||||
if out.stage.is_partial_import:
|
if out.stage.is_partial_import:
|
||||||
out.hash_info = entry.hash_info
|
if out.stage.is_repo_import:
|
||||||
out.meta = entry.meta
|
dep = out.stage.deps[0]
|
||||||
|
out.hash_info = dep.get_obj().hash_info
|
||||||
|
out.meta = dep.get_meta()
|
||||||
|
else:
|
||||||
|
out.hash_info = entry.hash_info
|
||||||
|
out.meta = entry.meta
|
||||||
out.stage.dump()
|
out.stage.dump()
|
||||||
updated += out.meta.nfiles if out.meta.nfiles is not None else 1
|
updated += out.meta.nfiles if out.meta.nfiles is not None else 1
|
||||||
return updated
|
return updated
|
||||||
@@ -78,7 +100,9 @@ def save_imports(
|
|||||||
|
|
||||||
downloaded: Set["HashInfo"] = set()
|
downloaded: Set["HashInfo"] = set()
|
||||||
|
|
||||||
unfetched, changed = unfetched_view(repo.index, targets, **kwargs)
|
unfetched, changed = unfetched_view(
|
||||||
|
repo.index, targets, unpartial=unpartial, **kwargs
|
||||||
|
)
|
||||||
for dep in changed:
|
for dep in changed:
|
||||||
logger.warning(str(DataSourceChanged(f"{dep.stage} ({dep})")))
|
logger.warning(str(DataSourceChanged(f"{dep.stage} ({dep})")))
|
||||||
|
|
||||||
@@ -96,13 +120,13 @@ def save_imports(
|
|||||||
md5(data_view)
|
md5(data_view)
|
||||||
save(data_view, odb=cache, hardlink=True)
|
save(data_view, odb=cache, hardlink=True)
|
||||||
|
|
||||||
if unpartial:
|
|
||||||
unpartial_imports(unfetched)
|
|
||||||
|
|
||||||
downloaded.update(
|
downloaded.update(
|
||||||
entry.hash_info
|
entry.hash_info
|
||||||
for _, entry in data_view.iteritems()
|
for _, entry in data_view.iteritems()
|
||||||
if not entry.meta.isdir and entry.hash_info is not None
|
if not entry.meta.isdir and entry.hash_info is not None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if unpartial:
|
||||||
|
unpartial_imports(partial_view(repo.index, targets, **kwargs))
|
||||||
|
|
||||||
return downloaded
|
return downloaded
|
||||||
|
|||||||
Reference in New Issue
Block a user