def _create_comparison_in_webapp(self, left_seg, right_seg): """Creates a comparison DB object. Returns the db_id of the comparison""" from human_feedback_api import Comparison comparison_uuid = str(uuid.uuid4()) comparison = Comparison(experiment_name=self.experiment_name, media_url_1=self.convert_segment_to_media_url( comparison_uuid, 'left', left_seg), media_url_2=self.convert_segment_to_media_url( comparison_uuid, 'right', right_seg), response_kind='left_or_right', priority=1.) comparison.full_clean() comparison.save() return comparison.id
def generate_test(): # TEST_MEDIA = ['test707470989.png', 'test559628392.png', 'test736369680.png', 'test836374824.png', # 'test593516009.png', 'test836986396.png', 'test996736825.png', 'test746178624.png', 'test58579485.png', ] TEST_MEDIA = [ 'https://storage.googleapis.com/rl-teacher-tom/test_obs_75.mp4' ] * 5 for media_1 in TEST_MEDIA: for media_2 in TEST_MEDIA: test_comparison = Comparison(experiment_name='test_experiment', media_url_1=media_1, media_url_2=media_2, response_kind='left_or_right', priority=1.) print('Creating test comparison: {}'.format(test_comparison)) test_comparison.full_clean() test_comparison.save() import ipdb ipdb.set_trace() print('We now have a total of {} comparisons in the database'.format( Comparison.objects.count()))