Example #1
0
def basic_bentoservice_v2():
    logger.debug('Creating iris classifier BentoService bundle..')
    bento_svc = UpdatedBasicBentoService()
    bento_svc.save()

    bento_name = f'{bento_svc.name}:{bento_svc.version}'
    yield bento_name
    delete_bento(bento_name)
Example #2
0
def basic_bentoservice_v2():
    logger.debug('Creating basic_bentoservice_v2 saved bundle..')
    bento_svc = UpdatedSampleBentoService()
    bento_svc.save()

    bento_name = f'{bento_svc.name}:{bento_svc.version}'
    yield bento_name
    delete_bento(bento_name)
Example #3
0
def iris_clf_service():
    logger.debug('Training iris classifier with sklearn..')
    clf = svm.SVC(gamma='scale')
    iris = datasets.load_iris()
    X, y = iris.data, iris.target
    clf.fit(X, y)

    logger.debug('Creating iris classifier BentoService bundle..')
    iris_clf_service_ = IrisClassifier()
    iris_clf_service_.pack('clf', clf)
    iris_clf_service_.save()

    bento_name = f'{iris_clf_service_.name}:{iris_clf_service_.version}'
    yield bento_name
    delete_bento(bento_name)
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
Example #5
0
def test_yatai_server_with_postgres_and_local_storage(temporary_docker_postgres_url):
    with start_yatai_server(temporary_docker_postgres_url) as yatai_service_url:
        logger.info(f'Setting config yatai_service.url to: {yatai_service_url}')
        with modified_environ(BENTOML__YATAI_SERVICE__URL=yatai_service_url):
            logger.info('Saving bento service')
            svc = BentoServiceForYataiTest()
            svc.save()
            bento_tag = f'{svc.name}:{svc.version}'
            logger.info('BentoService saved')

            logger.info("Display bentoservice info")
            get_svc_result = get_bento_service(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 = run_bento_service_prediction(bento_tag, '[]')
            logger.info(run_result)
            assert 'cat' in run_result, 'Unexpected BentoService prediction result'

            logger.info('Delete BentoService for testing')
            delete_svc_result = delete_bento(bento_tag)
            logger.info(delete_svc_result)
            assert delete_svc_result is None, 'Unexpected delete BentoService message.'
Example #6
0
def test_yatai_server_with_postgres_and_s3(temporary_docker_postgres_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 start_yatai_server(
        db_url=temporary_docker_postgres_url, repo_base_url=s3_bucket_name
    ) as yatai_service_url:
        logger.info(f'Setting config yatai_service.url to: {yatai_service_url}')
        with modified_environ(BENTOML__YATAI_SERVICE__URL=yatai_service_url):
            logger.info('Saving bento service')
            svc = BentoServiceForYataiTest()
            svc.save()
            bento_tag = f'{svc.name}:{svc.version}'
            logger.info('BentoService saved')

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

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

            logger.info('Delete BentoService for testing')
            delete_svc_result = delete_bento(bento_tag)
            logger.info(delete_svc_result)
            assert delete_svc_result is None, 'Unexpected delete BentoService message.'
Example #7
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
Example #8
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
Example #9
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
Example #10
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