Exemplo n.º 1
0
    def _get_spec_content(self, spec, sha):
        entity_dir = get_entity_dir(self.__repo_type,
                                    spec,
                                    root_path=self.__path)
        spec_path = '/'.join([posix_path(entity_dir), spec + SPEC_EXTENSION])

        return yaml_load_str(self._get_spec_content_from_ref(sha, spec_path))
Exemplo n.º 2
0
 def _full_metadata_path(self, spec_file):
     try:
         entity_dir = get_entity_dir(self.__repo_type, self._spec)
     except Exception as e:
         log.error(e, class_name=METADATA_CLASS_NAME)
         return None, None, None
     metadata = yaml_load(spec_file, raise_exception=True)
     full_metadata_path = os.path.join(self.__path, entity_dir)
     return full_metadata_path, entity_dir, metadata
Exemplo n.º 3
0
 def test_get_entity_dir(self):
     spec_name = 'dataset-ex'
     dir_folders = os.path.join('folderA', 'folderB', spec_name)
     entity_path = os.path.join(self.tmp_dir, DATASETS, dir_folders)
     os.makedirs(entity_path)
     spec_file = spec_name + '.spec'
     f = open(os.path.join(entity_path, spec_file), 'w')
     f.close()
     entity_dir = get_entity_dir(DATASETS, spec_name,
                                 os.path.join(self.tmp_dir, DATASETS))
     self.assertEquals(dir_folders, entity_dir)
Exemplo n.º 4
0
    def get_specs_to_compare(self, spec):
        entity = self.__repo_type
        spec_manifest_key = 'manifest'
        tags = self.list_tags(spec, True)

        entity_dir = get_entity_dir(entity, spec, root_path=self.__path)
        spec_path = '/'.join([posix_path(entity_dir), spec + SPEC_EXTENSION])
        for tag in tags:
            current_ref = tag.commit
            parents = current_ref.parents
            base_spec = {entity: {spec_manifest_key: {}}}

            if parents:
                base_ref = parents[0]
                base_spec = yaml_load_str(
                    self._get_spec_content_from_ref(base_ref, spec_path))

            current_spec = yaml_load_str(
                self._get_spec_content_from_ref(current_ref, spec_path))
            yield current_spec[entity][spec_manifest_key], base_spec[entity][
                spec_manifest_key]
Exemplo n.º 5
0
 def get_metadata_path(self, tag):
     _, specname, _ = spec_parse(tag)
     entity_dir = get_entity_dir(self.__repo_type, specname)
     return os.path.join(self.__path, entity_dir)