コード例 #1
0
ファイル: test_s3.py プロジェクト: Nikunj3masarani/bentoml
def test_s3(minio_address):
    yatai_server_command = [
        'bentoml',
        'yatai-service-start',
        '--no-ui',
        '--grpc-port',
        '50051',
        '--repo-base-url',
        f's3://{bucket_name}/',
        '--s3-endpoint-url',
        'localhost:9000',
    ]
    proc = subprocess.Popen(yatai_server_command,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    yatai_server_url = "localhost:50051"
    svc = ExampleBentoService()
    svc.pack('model', {'model': 'abc'})
    bento_tag = f'{svc.name}:{svc.version}'
    saved_path = svc.save(yatai_url=yatai_server_url)
    yc = get_yatai_client(yatai_server_url)

    assert saved_path.startswith('s3://')

    bento_pb = yc.repository.get(bento_tag)
    with TempDirectory() as temp_dir:
        yc.repository.download_to_directory(bento_pb, f'{temp_dir}/bundle')
        assert os.path.exists(f'{temp_dir}/bundle/bentoml.yml')
    proc.kill()
コード例 #2
0
def test_push_and_pull():
    with yatai_service_container() as yatai_server_url:
        svc = ExampleBentoService()
        bento_tag = f'{svc.name}:{svc.version}'
        saved_path = svc.save()
        yc = get_yatai_client(yatai_server_url)

        pushed_path = yc.repository.push(bento_tag)
        assert pushed_path != saved_path

        local_yc = get_yatai_client()
        delete_result = local_yc.repository.delete(bento_tag)
        assert delete_result is None
        assert os.path.exists(saved_path) is False

        pull_result = yc.repository.pull(bento_tag)
        assert pull_result == saved_path
コード例 #3
0
def test_yatai_server_containerize_without_push():
    svc = ExampleBentoService()
    svc.pack('model', [1, 2, 3])
    logger.info('Saving bento service to local yatai server')
    svc.save()

    yc = get_yatai_client()
    tag = 'mytag'
    built_tag = yc.repository.containerize(bento=f'{svc.name}:{svc.version}',
                                           tag=tag)
    assert built_tag == f'{tag}:{svc.version}'
コード例 #4
0
def test_sqlite_and_local_fs():
    with local_yatai_server() as yatai_server_url:
        yc = get_yatai_client(yatai_server_url)
        svc = ExampleBentoService()
        svc.pack('model', [1, 2, 3])
        bento_tag = f'{svc.name}:{svc.version}'
        logger.info(f'Saving BentoML saved bundle {bento_tag}')
        svc.save(yatai_url=yatai_server_url)

        bento_pb = yc.repository.get(bento_tag)
        assert (bento_pb.uri.type == BentoUri.LOCAL
                ), 'BentoService storage type mismatched, expect LOCAL'

        logger.info(f'Deleting saved bundle {bento_tag}')
        delete_svc_result = yc.repository.delete(bento_tag)
        assert delete_svc_result is None
コード例 #5
0
def test_yatai_server_with_postgres_and_local_storage():
    postgres_db_url = 'postgresql://*****:*****@localhost/bentoml:5432'

    from sqlalchemy_utils import create_database

    create_database(postgres_db_url)

    with local_yatai_service_from_cli(
            db_url=postgres_db_url) as yatai_server_url:
        logger.info('Saving bento service')
        logger.info(f'yatai url is {yatai_server_url}')
        svc = ExampleBentoService()
        svc.pack('model', [1, 2, 3])
        bento_tag = f'{svc.name}:{svc.version}'
        logger.info(f'Saving BentoML saved bundle {bento_tag}')
        svc.save(yatai_url=yatai_server_url)

        yc = get_yatai_client(yatai_server_url)
        bento_pb = yc.repository.get(bento_tag)
        assert (bento_pb.uri.type == BentoUri.LOCAL
                ), 'BentoService storage type mismatched, expect LOCAL'
コード例 #6
0
def test_yatai_server_containerize_from_cli():
    svc = ExampleBentoService()
    svc.pack('model', [1, 2, 3])
    logger.info('Saving bento service to local yatai server')
    svc.save()
    bento_tag = f'{svc.name}:{svc.version}'
    tag = 'mytagfoo'

    command = [
        'bentoml',
        'containerize',
        bento_tag,
        '--build-arg',
        'EXTRA_PIP_INSTALL_ARGS=--extra-index-url=https://pypi.org',
        '-t',
        tag,
    ]
    docker_proc = subprocess.Popen(command,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
    stdout = docker_proc.stdout.read().decode('utf-8')
    assert f'{tag}:{svc.version}' in stdout, 'Failed to build container'
コード例 #7
0
ファイル: test_locking.py プロジェクト: subhayuroy/BentoML
def packed_svc():
    svc = ExampleBentoService()
    svc.pack('model', [1, 2, 3])
    svc.save()
    return svc