dvc: move link_state from Cache to Project

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-06-04 22:28:14 +03:00
parent 08dcd8490e
commit f03ea7a915
4 changed files with 34 additions and 8 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ import os
import json
import shutil
from dvc.state import State, LinkState
from dvc.state import State
from dvc.system import System
from dvc.logger import Logger
from dvc.utils import move, remove
@@ -21,7 +21,7 @@ class Cache(object):
'reflink': System.reflink,
}
def __init__(self, root_dir, dvc_dir, cache_dir=None, cache_type=None):
def __init__(self, root_dir, dvc_dir, link_state=None, cache_dir=None, cache_type=None):
self.cache_type = cache_type
cache_dir = cache_dir if cache_dir else self.CACHE_DIR
@@ -34,7 +34,7 @@ class Cache(object):
os.mkdir(self.cache_dir)
self.state = State(self.cache_dir)
self.link_state = LinkState(root_dir, dvc_dir)
self.link_state = link_state
self.lock = Lock(self.cache_dir, name=self.CACHE_DIR_LOCK)
@staticmethod
+7 -5
View File
@@ -11,7 +11,7 @@ from dvc.logger import Logger
from dvc.exceptions import DvcException
from dvc.stage import Stage
from dvc.config import Config
from dvc.state import State
from dvc.state import State, LinkState
from dvc.lock import Lock
from dvc.scm import SCM, Base
from dvc.cache import Cache
@@ -47,8 +47,10 @@ class Project(object):
self.config = Config(self.dvc_dir)
self.scm = SCM(self.root_dir)
self.lock = Lock(self.dvc_dir)
self.cache = Cache(self.root_dir, self.dvc_dir, cache_dir=self.config._config[Config.SECTION_CACHE].get(Config.SECTION_CACHE_DIR, None),
cache_type=self.config._config[Config.SECTION_CACHE].get(Config.SECTION_CACHE_TYPE, None))
self.link_state = LinkState(self.root_dir, self.dvc_dir)
self.cache = Cache(self.root_dir, self.dvc_dir, link_state=self.link_state,
cache_dir=self.config._config[Config.SECTION_CACHE].get(Config.SECTION_CACHE_DIR, None),
cache_type=self.config._config[Config.SECTION_CACHE].get(Config.SECTION_CACHE_TYPE, None))
self.state = State(self.dvc_dir)
self.logger = Logger(self.config._config[Config.SECTION_CORE].get(Config.SECTION_CORE_LOGLEVEL, None))
self.cloud = DataCloud(cache=self.cache, config=self.config._config)
@@ -94,7 +96,7 @@ class Project(object):
return proj
def _ignore(self):
l = [self.cache.link_state.state_file,
l = [self.link_state.state_file,
self.cache.link_state._lock_file.lock_file,
self.state.state_file,
self.state._lock_file.lock_file,
@@ -191,7 +193,7 @@ class Project(object):
raise StageNotFoundError(target)
stages = [Stage.load(self, target)]
else:
self.cache.link_state.remove_all()
self.link_state.remove_all()
stages = self.stages()
for stage in stages:
+3
View File
@@ -0,0 +1,3 @@
class Remote(object):
def __init__(self
pass
+21
View File
@@ -0,0 +1,21 @@
def Transport(path):
pass
def exists(path):
return Transport(path).exists(path)
def copy(inp, outp):
return Transport(inp).copy(inp, outp)
def is_file(path):
return Transport(path).is_file(path)
def is_dir(path):
return Transport(path).is_dir(path)
def is_empty(path):
return Transport(path).is_empty(path)