mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-12 07:18:23 +01:00
cloud: parse and store cloud in settings
Cloud is determined from config and stays the same from that moment, so it makes sense to parse it once and store in settings, so whoever needs it, could just use self.settings.cloud. This is going to be more useful in the few next commits, where push/pull/status are introduced. Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
@@ -4,7 +4,6 @@ from multiprocessing.pool import ThreadPool
|
||||
from dvc.command.base import CmdBase, DvcLock
|
||||
from dvc.exceptions import DvcException
|
||||
from dvc.system import System
|
||||
from dvc.data_cloud import DataCloud
|
||||
from dvc.utils import map_progress
|
||||
|
||||
|
||||
@@ -19,7 +18,6 @@ class CmdDataSync(CmdBase):
|
||||
|
||||
def run(self):
|
||||
with DvcLock(self.is_locker, self.git):
|
||||
cloud = DataCloud(self.settings)
|
||||
targets = []
|
||||
|
||||
if len(self.parsed_args.targets) == 0:
|
||||
@@ -35,5 +33,5 @@ class CmdDataSync(CmdBase):
|
||||
else:
|
||||
raise DataSyncError('File "{}" does not exit'.format(target))
|
||||
|
||||
map_progress(cloud.sync, targets, self.parsed_args.jobs)
|
||||
map_progress(self.settings.cloud.sync, targets, self.parsed_args.jobs)
|
||||
pass
|
||||
|
||||
@@ -3,7 +3,6 @@ import os
|
||||
from dvc.command.base import CmdBase, DvcLock
|
||||
from dvc.exceptions import DvcException
|
||||
from dvc.logger import Logger
|
||||
from dvc.data_cloud import DataCloud
|
||||
from dvc.path.data_item import DataItemError
|
||||
|
||||
class TraverseError(DvcException):
|
||||
@@ -15,7 +14,6 @@ class Traverse(CmdBase):
|
||||
def __init__(self, settings, cmd_name, do_not_start_from_root=True):
|
||||
super(Traverse, self).__init__(settings)
|
||||
self._cmd_name = cmd_name
|
||||
self.cloud = DataCloud(self.settings)
|
||||
self._do_not_start_from_root = do_not_start_from_root
|
||||
|
||||
def run(self):
|
||||
@@ -81,7 +79,7 @@ class Traverse(CmdBase):
|
||||
|
||||
def _remove_cloud_cache(self, data_item):
|
||||
if not self.parsed_args.keep_in_cloud:
|
||||
self.cloud.remove_from_cloud(data_item)
|
||||
self.settings.cloud.remove_from_cloud(data_item)
|
||||
|
||||
## API:
|
||||
def is_recursive(self):
|
||||
|
||||
@@ -5,6 +5,7 @@ from dvc.config import ConfigI, Config
|
||||
from dvc.exceptions import DvcException
|
||||
from dvc.path.factory import PathFactory
|
||||
from dvc.cli import parse_args
|
||||
from dvc.data_cloud import DataCloud
|
||||
|
||||
class SettingsError(DvcException):
|
||||
def __init__(self, msg):
|
||||
@@ -33,6 +34,7 @@ class Settings(object):
|
||||
self._config = config
|
||||
self._path_factory = PathFactory(git, config)
|
||||
self._parsed_args = args
|
||||
self._cloud = DataCloud(self)
|
||||
|
||||
@property
|
||||
def args(self):
|
||||
@@ -63,3 +65,7 @@ class Settings(object):
|
||||
@property
|
||||
def path_factory(self):
|
||||
return self._path_factory
|
||||
|
||||
@property
|
||||
def cloud(self):
|
||||
return self._cloud
|
||||
|
||||
Reference in New Issue
Block a user