dvc: use DirInfo instead of dicts/lists (#4851)

Currently we are converting dir_info to/from lists all the time.
The reason is that dir_info is stored as list of dicts in *.dir files,
but that makes it hard to work with. In addition to that, we will likely
be changing .dir file format in the near future #829, so we need to
abstract away dir_info into something that we won't care how it will be
stored on disk.

Related #3256
Related #4847
This commit is contained in:
Ruslan Kuprieiev
2020-11-07 02:55:05 +02:00
committed by GitHub
parent 80e181f2fc
commit 4531aa34ca
14 changed files with 468 additions and 183 deletions
+5 -2
View File
@@ -6,6 +6,7 @@ import pytest
from dvc.cache import Cache
from dvc.cache.base import DirCacheError
from dvc.dir_info import DirInfo
from dvc.hash_info import HashInfo
from dvc.main import main
from dvc.utils import relpath
@@ -60,9 +61,11 @@ class TestCacheLoadBadDirCache(TestDvc):
self.dvc.cache.local.tree.hash_to_path_info(dir_hash)
)
self.create(fname, '{"a": "b"}')
self._do_test(
self.dvc.cache.local.load_dir_cache(HashInfo("md5", dir_hash))
dir_info = self.dvc.cache.local.load_dir_cache(
HashInfo("md5", dir_hash)
)
self.assertTrue(isinstance(dir_info, DirInfo))
self.assertEqual(dir_info.nfiles, 0)
class TestExternalCacheDir(TestDvc):