Exemplo n.º 1
0
def test_yatai_server_with_postgres_and_gcs(postgres_db_container_url):

    gcs_bucket_name = 'gs://bentoml-e2e-tests/'

    with local_yatai_server(db_url=postgres_db_container_url,
                            repo_base_url=gcs_bucket_name):
        logger.info('Saving bento service')
        svc = SampleBentoService()
        svc.save()
        bento_tag = f'{svc.name}:{svc.version}'
        logger.info('BentoService saved')

        logger.info("Display bentoservice info")
        get_svc_result = get_bento_service_info(svc.name, svc.version)
        logger.info(get_svc_result)
        assert (get_svc_result.bento.uri.type == BentoUri.GCS
                ), 'BentoService storage type mismatched, expect GCS'

        logger.info('Validate BentoService prediction result')
        run_result = execute_bentoml_run_command(bento_tag, '[]')
        assert 'cat' in run_result, 'Unexpected BentoService prediction result'

        logger.info(f'Deleting saved bundle {bento_tag}')
        delete_svc_result = delete_bento(bento_tag)
        assert f"{bento_tag} deleted" in delete_svc_result
Exemplo n.º 2
0
def test_yatai_server_with_postgres_and_s3(postgres_db_container_url):
    # Note: Use pre-existing bucket instead of newly created bucket, because the
    # bucket's global DNS needs time to get set up.
    # https://github.com/boto/boto3/issues/1982#issuecomment-511947643

    s3_bucket_name = 's3://bentoml-e2e-test-repo/'

    with local_yatai_server(db_url=postgres_db_container_url,
                            repo_base_url=s3_bucket_name) as yatai_service_url:
        yc = get_yatai_client(yatai_service_url)
        logger.info('Saving bento service')
        svc = SampleBentoService()
        svc.save(yatai_url=yatai_service_url)
        bento_tag = f'{svc.name}:{svc.version}'
        logger.info('BentoService saved')

        logger.info("Display bentoservice info")
        bento = yc.repository.get(bento_tag)
        logger.info(bento)
        assert (bento.uri.type == BentoUri.S3
                ), 'BentoService storage type mismatched, expect S3'

        logger.info('Validate BentoService prediction result')
        run_result = execute_bentoml_run_command(bento_tag=bento_tag,
                                                 data='[]',
                                                 yatai_url=yatai_service_url)
        assert 'cat' in run_result, 'Unexpected BentoService prediction result'

        logger.info(f'Deleting saved bundle {bento_tag}')
        yc.repository.delete(bento_tag=bento_tag)
Exemplo n.º 3
0
def test_yatai_server_with_sqlite_and_gcs():
    gcs_bucket_name = 'gs://bentoml-e2e-tests/'

    with local_yatai_server(repo_base_url=gcs_bucket_name):
        logger.info('Saving bento service')
        svc = SampleBentoService()
        svc.save()
        bento_tag = f'{svc.name}:{svc.version}'
        logger.info('BentoService saved')

        logger.info("Display bentoservice info")
        bento = get_bento_service_info(svc.name, svc.version)
        logger.info(bento)
        assert (bento.uri.type == BentoUri.GCS
                ), 'BentoService storage type mismatched, expect GCS'

        retrieve_svc_result = execute_bentoml_retrieve_command(
            f'{svc.name}:{svc.version}')
        assert retrieve_svc_result.startswith(
            f'Service {svc.name} artifact directory')

        logger.info('Validate BentoService prediction result')
        run_result = execute_bentoml_run_command(bento_tag, '[]')
        logger.info(run_result)
        assert 'cat' in run_result, 'Unexpected BentoService prediction result'

        logger.info(f'Deleting saved bundle {bento_tag}')
        delete_svc_result = delete_bento(bento_tag)
        assert f"{bento_tag} deleted" in delete_svc_result
Exemplo n.º 4
0
def test_yatai_server_with_sqlite_and_gcs():
    gcs_bucket_name = 'gs://bentoml-e2e-tests/'

    with local_yatai_server(
            repo_base_url=gcs_bucket_name) as yatai_service_url:
        yc = get_yatai_client(yatai_service_url)
        logger.info('Saving bento service')
        svc = SampleBentoService()
        svc.save(yatai_url=yatai_service_url)
        bento_tag = f'{svc.name}:{svc.version}'
        logger.info('BentoService saved')

        logger.info("Display bentoservice info")
        bento = yc.repository.get(bento_tag)
        logger.info(bento)
        assert (bento.uri.type == BentoUri.GCS
                ), 'BentoService storage type mismatched, expect GCS'

        logger.info('Validate BentoService prediction result')
        run_result = execute_bentoml_run_command(bento_tag=bento_tag,
                                                 data='[]',
                                                 yatai_url=yatai_service_url)
        logger.info(run_result)
        assert 'cat' in run_result, 'Unexpected BentoService prediction result'

        logger.info(f'Deleting saved bundle {bento_tag}')
        yc.repository.delete(bento_tag=bento_tag)
Exemplo n.º 5
0
def test_yatai_server_with_sqlite_and_s3():
    # Note: Use pre-existing bucket instead of newly created bucket, because the
    # bucket's global DNS needs time to get set up.
    # https://github.com/boto/boto3/issues/1982#issuecomment-511947643

    s3_bucket_name = 's3://bentoml-e2e-test-repo/'

    with local_yatai_server(repo_base_url=s3_bucket_name):
        logger.info('Saving bento service')
        svc = SampleBentoService()
        svc.save()
        bento_tag = f'{svc.name}:{svc.version}'
        logger.info('BentoService saved')

        logger.info("Display bentoservice info")
        bento = get_bento_service_info(svc.name, svc.version)
        logger.info(bento)
        assert (
            bento.uri.type == BentoUri.S3
        ), 'BentoService storage type mismatched, expect S3'
        retrieve_svc_result = execute_bentoml_retrieve_command(
            f'{svc.name}:{svc.version}'
        )
        assert retrieve_svc_result.startswith(f'Service {svc.name} artifact directory')

        logger.info('Validate BentoService prediction result')
        run_result = execute_bentoml_run_command(bento_tag, '[]')
        logger.info(run_result)
        assert 'cat' in run_result, 'Unexpected BentoService prediction result'

        logger.info(f'Deleting saved bundle {bento_tag}')
        delete_svc_result = delete_bento(bento_tag)
        assert f"{bento_tag} deleted" in delete_svc_result
Exemplo n.º 6
0
def basic_bentoservice_v1():
    logger.debug('Creating basic_bentoservice_v1 saved bundle..')
    bento_svc = SampleBentoService()
    bento_svc.save()

    bento_name = f'{bento_svc.name}:{bento_svc.version}'
    yield bento_name
    delete_bento(bento_name)
Exemplo n.º 7
0
def test_docker_yatai_server_with_postgres():
    with yatai_server_container():
        svc = SampleBentoService()
        bento_tag = f'{svc.name}:{svc.version}'
        logger.info(f'Saving BentoML saved bundle {bento_tag}')
        svc.save()

        get_svc_result = get_bento_service_info(svc.name, svc.version)
        logger.info(f'Retrived BentoML saved bundle {bento_tag} info: {get_svc_result}')
        assert (
            get_svc_result.bento.uri.type == BentoUri.LOCAL
        ), 'BentoService storage type mismatched, expect LOCAL'

        # Loading from LocalRepository based remote YataiService is not yet supported
        # logger.info('Validate BentoService CLI prediction result')
        # run_result = run_bento_service_prediction(bento_tag, '[]')
        # assert 'cat' in run_result, f'Unexpected prediction result: {run_result}'

        logger.info(f'Deleting saved bundle {bento_tag}')
        delete_svc_result = delete_bento(bento_tag)
        assert f"{bento_tag} deleted" in delete_svc_result
Exemplo n.º 8
0
def test_yatai_server_with_sqlite_and_local_storage():
    with local_yatai_server():

        logger.info('Saving bento service')
        svc = SampleBentoService()
        svc.save()
        bento_tag = f'{svc.name}:{svc.version}'
        logger.info('BentoService saved')

        logger.info("Display bentoservice info")
        get_svc_result = get_bento_service_info(svc.name, svc.version)
        logger.info(get_svc_result)
        assert (get_svc_result.bento.uri.type == BentoUri.LOCAL
                ), 'BentoService storage type mismatched, expect LOCAL'

        logger.info('Validate BentoService prediction result')
        run_result = execute_bentoml_run_command(bento_tag, '[]')
        assert 'cat' in run_result, 'Unexpected BentoService prediction result'

        logger.info(f'Deleting saved bundle {bento_tag}')
        delete_svc_result = delete_bento(bento_tag)
        assert f"{bento_tag} deleted" in delete_svc_result