mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-26 15:28:28 +01:00
dvc: introduce --jobs option and use map_progress
It replaces POOL_SIZE constant and by default equals to the number of cpus available. map_progress is a helper for 'sync' and 'import' commands to run in a multi-threaded mode. Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
@@ -6,9 +6,7 @@ from dvc.exceptions import DvcException
|
||||
from dvc.runtime import Runtime
|
||||
from dvc.system import System
|
||||
from dvc.data_cloud import DataCloud
|
||||
from dvc.progress import progress
|
||||
|
||||
POOL_SIZE = 4
|
||||
from dvc.utils import map_progress
|
||||
|
||||
|
||||
class DataSyncError(DvcException):
|
||||
@@ -29,7 +27,6 @@ class CmdDataSync(CmdBase):
|
||||
def run(self):
|
||||
with DvcLock(self.is_locker, self.git):
|
||||
cloud = DataCloud(self.settings)
|
||||
pool = ThreadPool(processes=POOL_SIZE)
|
||||
targets = []
|
||||
|
||||
if len(self.parsed_args.targets) == 0:
|
||||
@@ -45,9 +42,7 @@ class CmdDataSync(CmdBase):
|
||||
else:
|
||||
raise DataSyncError('File "{}" does not exit'.format(target))
|
||||
|
||||
progress.set_n_total(len(targets))
|
||||
pool.map(cloud.sync, targets)
|
||||
progress.finish()
|
||||
map_progress(cloud.sync, targets, self.parsed_args.jobs)
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user