mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
fetch: add basic onerror
Related https://github.com/iterative/studio/pull/6541
This commit is contained in:
+14
-4
@@ -9,6 +9,14 @@ from . import locked
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _make_index_onerror(onerror, rev):
|
||||
def _onerror(entry, exc):
|
||||
if onerror:
|
||||
return onerror(rev, entry, exc)
|
||||
|
||||
return _onerror
|
||||
|
||||
|
||||
def _collect_indexes( # noqa: PLR0913
|
||||
repo,
|
||||
targets=None,
|
||||
@@ -22,6 +30,7 @@ def _collect_indexes( # noqa: PLR0913
|
||||
max_size=None,
|
||||
types=None,
|
||||
config=None,
|
||||
onerror=None,
|
||||
):
|
||||
indexes = {}
|
||||
collection_exc = None
|
||||
@@ -49,14 +58,13 @@ def _collect_indexes( # noqa: PLR0913
|
||||
types=types,
|
||||
)
|
||||
|
||||
def onerror(_entry, _exc):
|
||||
pass
|
||||
|
||||
data = idx.data["repo"]
|
||||
data.onerror = onerror
|
||||
data.onerror = _make_index_onerror(onerror, rev)
|
||||
|
||||
indexes[idx.data_tree.hash_info.value] = data
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
if onerror:
|
||||
onerror(rev, None, exc)
|
||||
collection_exc = exc
|
||||
logger.exception("failed to collect '%s'", rev or "workspace")
|
||||
|
||||
@@ -82,6 +90,7 @@ def fetch( # noqa: C901, PLR0913
|
||||
max_size=None,
|
||||
types=None,
|
||||
config=None,
|
||||
onerror=None,
|
||||
) -> int:
|
||||
"""Download data items from a cloud and imported repositories
|
||||
|
||||
@@ -126,6 +135,7 @@ def fetch( # noqa: C901, PLR0913
|
||||
max_size=max_size,
|
||||
types=types,
|
||||
config=config,
|
||||
onerror=onerror,
|
||||
)
|
||||
|
||||
cache_key = ("fetch", tokenize(sorted(indexes.keys())))
|
||||
|
||||
Reference in New Issue
Block a user