1313
1414from shortuuid import uuid
1515
16+ from funcy import cached_property
17+
1618import dvc .prompt as prompt
1719from dvc .config import Config
1820from dvc .exceptions import (
@@ -75,7 +77,6 @@ class RemoteBASE(object):
7577 scheme = "base"
7678 path_cls = URLInfo
7779 REQUIRES = {}
78- JOBS = 4 * cpu_count ()
7980
8081 PARAM_RELPATH = "relpath"
8182 CHECKSUM_DIR_SUFFIX = ".dir"
@@ -84,6 +85,10 @@ class RemoteBASE(object):
8485
8586 state = StateNoop ()
8687
88+ @cached_property
89+ def jobs (self ):
90+ return cpu_count () * 4
91+
8792 def __init__ (self , repo , config ):
8893 self .repo = repo
8994
@@ -746,6 +751,11 @@ def changed_cache(self, checksum):
746751 return self ._changed_dir_cache (checksum )
747752 return self .changed_cache_file (checksum )
748753
754+ def _adjust_jobs (self , jobs = None ):
755+ if not jobs :
756+ jobs = self .jobs
757+ return jobs
758+
749759 def cache_exists (self , checksums , jobs = None , name = None ):
750760 """Check if the given checksums are stored in the remote.
751761
@@ -784,7 +794,9 @@ def exists_with_progress(path_info):
784794 pbar .update_desc (str (path_info ))
785795 return ret
786796
787- with ThreadPoolExecutor (max_workers = jobs or self .JOBS ) as executor :
797+ with ThreadPoolExecutor (
798+ max_workers = self ._adjust_jobs (jobs )
799+ ) as executor :
788800 path_infos = map (self .checksum_to_path_info , checksums )
789801 in_remote = executor .map (exists_with_progress , path_infos )
790802 ret = list (itertools .compress (checksums , in_remote ))
0 commit comments