def render_post_data(post_data): if hasattr(post_data, 'fileno'): # todo: is this the right way of checking if it's a file? return '%r (%d bytes)' % (post_data, util.file_size(post_data)) elif isinstance(post_data, (six.string_types, six.binary_type)): return '%r (%d bytes)' % (post_data, len(post_data)) else: return None
def upload_training_video(videos, api_key=None, env_id=None): """videos: should be list of (video_path, metadata_path) tuples""" with tempfile.TemporaryFile() as archive_file: write_archive(videos, archive_file, env_id=env_id) archive_file.seek(0) logger.info('[%s] Uploading videos of %d training episodes (%d bytes)', env_id, len(videos), util.file_size(archive_file)) file_upload = resource.FileUpload.create( purpose='video', content_type='application/vnd.openai.video+x-compressed', api_key=api_key) file_upload.put(archive_file, encode=None) return file_upload
def upload_training_video(videos, api_key=None, env_id=None): """videos: should be list of (video_path, metadata_path) tuples""" with tempfile.TemporaryFile() as archive_file: write_archive(videos, archive_file, env_id=env_id) archive_file.seek(0) logger.info('[%s] Uploading videos of %d training episodes (%d bytes)', env_id, len(videos), util.file_size(archive_file)) file_upload = resource.FileUpload.create(purpose='video', content_type='application/vnd.openai.video+x-compressed', api_key=api_key) file_upload.put(archive_file, encode=None) return file_upload