+ # If we are comparing two different section types, we can use those
+ # as the default labels for setA and setB.
+ if setA_section != setB_section:
+ self._setA_label = setA_label or setA_section
+ self._setB_label = setB_label or setB_section
+ else:
+ self._setA_label = setA_label or 'setA'
+ self._setB_label = setB_label or 'setB'
+
+ tempdir = tempfile.mkdtemp()
+ try:
+ setA_root = os.path.join(tempdir, 'setA')
+ setB_root = os.path.join(tempdir, 'setB')
+ setA_repo_revision = None
+ setB_repo_revision = None
+ for source_dir in setA_dirs:
+ self._copy_dir_contents(source_dir=source_dir, dest_dir=setA_root)
+ # TODO(stephana): There is a potential race condition here... we copy
+ # the contents out of the source_dir, and THEN we get the commithash
+ # of source_dir. If source_dir points at a git checkout, and that
+ # checkout is updated (by a different thread/process) during this
+ # operation, then the contents and commithash will be out of sync.
+ setA_repo_revision = self._get_repo_revision(
+ source_dir=source_dir, assert_if_not=setA_repo_revision)
+ for source_dir in setB_dirs:
+ self._copy_dir_contents(source_dir=source_dir, dest_dir=setB_root)
+ setB_repo_revision = self._get_repo_revision(
+ source_dir=source_dir, assert_if_not=setB_repo_revision)
+
+ self._setA_descriptions = {
+ results.KEY__SET_DESCRIPTIONS__DIR: setA_dirs,
+ results.KEY__SET_DESCRIPTIONS__REPO_REVISION: setA_repo_revision,
+ results.KEY__SET_DESCRIPTIONS__SECTION: setA_section,
+ }
+ self._setB_descriptions = {
+ results.KEY__SET_DESCRIPTIONS__DIR: setB_dirs,
+ results.KEY__SET_DESCRIPTIONS__REPO_REVISION: setB_repo_revision,
+ results.KEY__SET_DESCRIPTIONS__SECTION: setB_section,
+ }
+
+ time_start = int(time.time())
+ self._results = self._load_result_pairs(
+ setA_root=setA_root, setB_root=setB_root,
+ setA_section=setA_section, setB_section=setB_section)
+ if self._results:
+ self._timestamp = int(time.time())
+ logging.info('Number of download file collisions: %s' %
+ imagediffdb.global_file_collisions)
+ logging.info('Results complete; took %d seconds.' %
+ (self._timestamp - time_start))
+ finally:
+ shutil.rmtree(tempdir)
+
+ def _load_result_pairs(self, setA_root, setB_root,
+ setA_section, setB_section):
+ """Loads all JSON image summaries from 2 directory trees and compares them.
+
+ TODO(stephana): This method is only called from within __init__(); it might
+ make more sense to just roll the content of this method into __init__().