def retrieve_raw_files_metadata_by_metadata(cls,
                                                search_criteria_list: List[
                                                    Tuple],
                                                zone=None):
        search_criteria_objs = []
        for k, v in search_criteria_list:
            search_criterion = SearchCriterion(k, v)
            search_criteria_objs.append(search_criterion)

        # Getting metadata from iRODS:
        try:
            connection = connect_to_irods_with_baton(
                config.BATON_BIN
            )  # skip_baton_binaries_validation=True) # type: Connection
            list_of_data_objs_and_metadata = connection.data_object.get_by_metadata(
                search_criteria_objs, zone=zone)
        except RuntimeError as e:
            if str(e).find('KRB_ERROR_ACQUIRING_CREDS') != -1:
                raise OSError(
                    "ERROR: you need to log into iRODS and aquire the KERBEROS credentials."
                ) from None
            else:
                raise e from None
        raw_meta_objects = [
            IrodsRawFileMetadata.from_baton_wrapper(data_obj)
            for data_obj in list_of_data_objs_and_metadata
        ]
        return raw_meta_objects
Esempio n. 2
0
 def test_from_baton_wrapper_file_replicas(self):
     replicas = [
         baton_models.DataObjectReplica(number=1, checksum="123abc"),
         baton_models.DataObjectReplica(number=2, checksum="abc"),]
     data_obj = baton_models.DataObject(path='/humgen/projects/helic/123.bam', replicas=replicas)
     raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj)
     self.assertEqual(len(raw_meta.file_replicas), 2)
Esempio n. 3
0
 def test_from_baton_wrapper_missing_bits(self):
     replicas = [
         baton_models.DataObjectReplica(number=1, checksum="123abc", host='hgi-dev', resource_name='irods-s1', up_to_date=True)]
     metadata = baton_coll.IrodsMetadata({'study': set(['BLUEPRINT'])})
     data_obj = baton_models.DataObject(path='/somepath/file.txt', metadata=metadata, replicas=replicas)
     raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj)
     self.assertEqual(len(raw_meta.file_replicas), 1)
     self.assertEqual(len(raw_meta.acls), 0)
Esempio n. 4
0
 def test_from_baton_wrapper_acls(self):
     user = "******"
     acl = [baton_models.AccessControl(user, level=baton_models.AccessControl.Level.WRITE)]
     data_obj = baton_models.DataObject(path='/somepath/file.txt', access_controls=acl)
     raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj)
     self.assertEqual(len(raw_meta.acls), 1)
     self.assertEqual(raw_meta.acls[0].access_group, 'hgi')
     self.assertEqual(raw_meta.acls[0].permission, IrodsPermission.WRITE)
     self.assertEqual(raw_meta.acls[0].zone, 'Sanger1')
Esempio n. 5
0
 def test_from_baton_wrapper_all_ok(self):
     user = "******"
     acl = [baton_models.AccessControl(user, level=baton_models.AccessControl.Level.OWN)]
     replicas = [
         baton_models.DataObjectReplica(number=1, checksum="123abc", host='hgi-dev', resource_name='irods-s1', up_to_date=True)]
     data_obj = baton_models.DataObject(path='/somepath/file.txt', access_controls=acl, replicas=replicas)
     raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj)
     self.assertEqual(raw_meta.fpath, '/somepath/file.txt')
     self.assertEqual(len(raw_meta.file_replicas), 1)
     self.assertEqual(len(raw_meta.acls), 1)
     self.assertEqual(raw_meta.acls[0].zone, 'humgen')
     self.assertEqual(raw_meta.acls[0].access_group, 'serapis')
Esempio n. 6
0
 def test_from_baton_wrapper_full_obj(self):
     user = "******"
     acl = [baton_models.AccessControl(user, level=baton_models.AccessControl.Level.OWN)]
     replicas = [
         baton_models.DataObjectReplica(number=1, checksum="123abc", host='hgi-dev', resource_name='irods-s1', up_to_date=True),
         baton_models.DataObjectReplica(number=2, checksum="abc", host='hgi-dev-wow', resource_name='irods-s2', up_to_date=True),]
     metadata = baton_coll.IrodsMetadata({'study': set(['BLUEPRINT'])})
     data_obj = baton_models.DataObject(path='/somepath/file.txt', access_controls=acl, metadata=metadata, replicas=replicas)
     raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj)
     self.assertEqual(raw_meta.fpath, '/somepath/file.txt')
     self.assertEqual(len(raw_meta.file_replicas), 2)
     self.assertEqual(len(raw_meta.acls), 1)
     self.assertEqual(raw_meta.acls[0].zone, 'humgen')
     self.assertEqual(raw_meta.acls[0].access_group, 'hgi')
 def fetch_raw_file_metadata_by_path(cls, fpath):
     try:
         connection = connect_to_irods_with_baton(config.BATON_BIN)#, skip_baton_binaries_validation=True)
         data_object = connection.data_object.get_by_path(fpath)
     except Exception as e:
         if str(e).find('KRB_ERROR_ACQUIRING_CREDS') != -1:
             raise OSError("ERROR: you need to log into iRODS and aquire the KERBEROS credentials.") from None
         else:
             raise e from None
     else:
         if data_object:
             raw_metadata = IrodsRawFileMetadata.from_baton_wrapper(data_object)
             return raw_metadata
         return None
    def retrieve_raw_files_metadata_by_metadata(cls, search_criteria_list: List[Tuple], zone=None):
        search_criteria_objs = []
        for k, v in search_criteria_list:
            search_criterion = SearchCriterion(k, v)
            search_criteria_objs.append(search_criterion)

        # Getting metadata from iRODS:
        try:
            connection = connect_to_irods_with_baton(config.BATON_BIN)  # skip_baton_binaries_validation=True) # type: Connection
            list_of_data_objs_and_metadata = connection.data_object.get_by_metadata(search_criteria_objs, zone=zone)
        except RuntimeError as e:
            if str(e).find('KRB_ERROR_ACQUIRING_CREDS') != -1:
                raise OSError("ERROR: you need to log into iRODS and aquire the KERBEROS credentials.") from None
            else:
                raise e from None
        raw_meta_objects = [IrodsRawFileMetadata.from_baton_wrapper(data_obj) for data_obj in list_of_data_objs_and_metadata]
        return raw_meta_objects
 def fetch_raw_file_metadata_by_path(cls, fpath):
     try:
         connection = connect_to_irods_with_baton(
             config.BATON_BIN)  #, skip_baton_binaries_validation=True)
         data_object = connection.data_object.get_by_path(fpath)
     except Exception as e:
         if str(e).find('KRB_ERROR_ACQUIRING_CREDS') != -1:
             raise OSError(
                 "ERROR: you need to log into iRODS and aquire the KERBEROS credentials."
             ) from None
         else:
             raise e from None
     else:
         if data_object:
             raw_metadata = IrodsRawFileMetadata.from_baton_wrapper(
                 data_object)
             return raw_metadata
         return None
Esempio n. 10
0
 def test_from_baton_wrapper_fpath_2(self):
     data_obj = baton_models.DataObject(path='/humgen/projects/helic/123.bam')
     raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj)
     self.assertEqual(raw_meta.fpath, '/humgen/projects/helic/123.bam')
Esempio n. 11
0
 def test_from_baton_wrapper_fpath_1(self):
     data_obj = baton_models.DataObject(path='/seq/123/123.bam.bai')
     raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj)
     self.assertEqual(raw_meta.fpath, '/seq/123/123.bam.bai')
Esempio n. 12
0
    def test_from_baton_wrapper_metadata(self):
        metadata = baton_coll.IrodsMetadata({'study': set(['BLUEPRINT']), 'sample': set(['123sam'])})
        data_obj = baton_models.DataObject(path='/somepath/file.txt', metadata=metadata)
        raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj)

        self.assertEqual(raw_meta.get_values_for_attribute('study'), set(['BLUEPRINT']))