示例#1
0
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
示例#2
0
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
示例#3
0
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
示例#4
0
文件: api.py 项目: 1234-/gym
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