def create_target_mapping(self, exp_uid, target_blob):
        """
        Update the default target docs in the DB if a user uploads a target set.
        Target_blob should be a list of targets, with each individual target having the following format. All feilds are REQUIRED.
            target_id: a unique target identifier init by the client
            index: the next_backend target object index
            primary_description (possibly image URI, or text)
            primary_type (img/text/audio/etc, tells how to display primary_description in widget)
            alternative_description (text descriptor, perhaps a caption for the image or subtitle for primary_description)
            features (list of floats, this will also be saved in the backend but its best to save this here as well I think. disk space is effectively infinite)

        Inputs: 
            (string) exp_uid, (list) target_blob
        Outputs:
            (boolean) didSucceed

        Usage: ::\n
        didSucceed = targetmapper.create_target_mapping(exp_uid, target_blob)
        {'target_id': superhappy, 'index': 23, 'primary_description': s3.com/superhappy, 'primary_type': img, 'alt_description': a super happy person, 'features': features}
        """
        #Verify that target_blob object has valid target mapping format
        #if not self.verify_target_map_format(exp_uid, target_blob):
        #    print "Invalid TargetMap Format. Please check your target upload CSV file and include all of the required feilds."
        #    return "Invalid TargetMap Format. Please check your target upload CSV file and include all of the required feilds."

        # Delete target doc indicating targetless initialization
        didSucceed,message = db.deleteDocsByPattern(self.database_id,self.bucket_id,{'exp_uid': exp_uid, 'targetless': True})
        if not didSucceed:
            raise DatabaseException("Failed to create_target_mapping: %s"%(message))
        # Recreate target document to denote target mapping has been created
        doc = {'targetless': False, 'exp_uid': exp_uid}
        didSucceed, message = db.setDoc(self.database_id, self.bucket_id, None, doc)
        if not didSucceed:
            raise DatabaseException("Failed to create_target_mapping: %s"%(message))

        # Iteratively initilize target documents and insert into MongoDB
        for ii in range(len(target_blob)):
            # Parse target specific args out of target_blob at index ii
            target_tmp = target_blob[ii]
            target_id = target_tmp['target_id']
            index = ii
            primary_description = target_tmp['primary_description']            
            primary_type = target_tmp['primary_type']
            alt_type = target_tmp['alt_type']
            alt_description = target_tmp['alt_description']
            # Structure target document for MongoDB
            doc = {'index': index,
                   'target_id': target_id,
                   'primary_description': primary_description,
                   'primary_type': primary_type,
                   'alt_description': alt_description,
                   'alt_type': alt_type,
                   'exp_uid': exp_uid}
            didSucceed, message = db.setDoc(self.database_id, self.bucket_id, None, doc)

            # If target not successfully created, throw an error
            if not didSucceed:
                raise DatabaseException("Failed to create_target_mapping: %s"%(message))
             
        # Get all docs related to the specified exp_uid
        mongotized_target_blob,didSucceed,message = db.getDocsByPattern(self.database_id, self.bucket_id, {'exp_uid': exp_uid})
        
        # If the newly initialized DB docs can't be found, throw an error
        if not didSucceed:
            raise DatabaseException("Failed to create_target_mapping: %s"%(message))
        # Pop target_dict out of list
        target_blob_dict = mongotized_target_blob.pop(0)

        # Return target_blob_dict of all targets corresponding to current exp_uid
        return target_blob_dict
dataset/ETHPy150Open nextml/NEXT/next/api/targetmapper.py/TargetMapper.create_target_mapping/original