Ejemplo n.º 1
0
def test_deploy_yaml():
    rt = SeldonDeployRuntime()

    config = EnterpriseRuntimeOptions(
        host="https://34.78.44.92/seldon-deploy/api/v1alpha1",
        user="******",
        password="******",
        oidc_server="https://34.78.44.92/auth/realms/deploy-realm",
        oidc_client_id="sd-api",
        verify_ssl=False,
        auth_type=EnterpriseRuntimeAuthType.oidc,
    )

    rt.authenticate(settings=config)

    options = KubernetesRuntimeOptions(
        namespace="seldon",
        ingress_options=IngressOptions(ssl=True, verify_ssl=False),
    )

    sklearn_model = Model(
        name="test-iris-sklearn",
        platform=ModelFramework.SKLearn,
        uri="gs://seldon-models/sklearn/iris",
        protocol=SeldonProtocol(),
        runtime_options=options,
    )

    spec = rt.manifest(sklearn_model)
    rtk = SeldonKubernetesRuntime()
    expected = rtk.manifest(sklearn_model)
    assert spec == expected
Ejemplo n.º 2
0
def test_deploy_yaml():
    rt = SeldonDeployRuntime(
        host="http://34.78.44.92/seldon-deploy/api/v1alpha1",
        user="******",
        oidc_server="https://34.78.44.92/auth/realms/deploy-realm",
        password="******",
        oidc_client_id="sd-api",
        verify_ssl=False,
    )

    options = RuntimeOptions(
        runtime="tempo.seldon.SeldonKubernetesRuntime",
        k8s_options=KubernetesOptions(namespace="seldon"),
        ingress_options=IngressOptions(ssl=True, verify_ssl=False),
    )

    sklearn_model = Model(
        name="test-iris-sklearn",
        platform=ModelFramework.SKLearn,
        uri="gs://seldon-models/sklearn/iris",
        protocol=SeldonProtocol(),
        runtime_options=options,
    )

    spec = rt.to_k8s_yaml(sklearn_model)
    rtk = SeldonKubernetesRuntime()
    expected = rtk.to_k8s_yaml(sklearn_model)
    assert spec == expected
Ejemplo n.º 3
0
def test_seldon_sklearn_model_yaml(expected):
    m = Model(
        name="test-iris-sklearn",
        platform=ModelFramework.SKLearn,
        uri="gs://seldon-models/sklearn/iris",
        local_folder="/tmp/model",
        protocol=SeldonProtocol(),
    )
    runtime = SeldonKubernetesRuntime()
    assert runtime.to_k8s_yaml(m) == expected
Ejemplo n.º 4
0
def test_seldon_xgboost_model_yaml(expected):
    m = Model(
        name="test-iris-xgboost",
        protocol=SeldonProtocol(),
        platform=ModelFramework.XGBoost,
        uri="gs://seldon-models/xgboost/iris",
        local_folder="/tmp/model",
    )
    runtime = SeldonKubernetesRuntime()
    print(runtime.to_k8s_yaml(m))
    assert runtime.to_k8s_yaml(m) == expected
Ejemplo n.º 5
0
def test_seldon_model_yaml_auth():
    m = Model(
        name="test-iris-xgboost",
        protocol=SeldonProtocol(),
        platform=ModelFramework.XGBoost,
        uri="gs://seldon-models/xgboost/iris",
        local_folder="/tmp/model",
    )
    runtime = SeldonKubernetesRuntime(
        runtime_options=RuntimeOptions(k8s_options=KubernetesOptions(authSecretName="auth"))
    )
    print(runtime.to_k8s_yaml(m))
Ejemplo n.º 6
0
def test_seldon_xgboost_model_yaml(expected):
    m = Model(
        name="test-iris-xgboost",
        protocol=SeldonProtocol(),
        platform=ModelFramework.XGBoost,
        uri="gs://seldon-models/xgboost/iris",
        local_folder="/tmp/model",
    )
    runtime = SeldonKubernetesRuntime()
    yaml_str = runtime.manifest(m)
    yaml_obj = yaml.safe_load(yaml_str)
    yaml_obj_expected = yaml.safe_load(expected)
    del yaml_obj["metadata"]["annotations"]["seldon.io/tempo-model"]
    assert yaml_obj == yaml_obj_expected
Ejemplo n.º 7
0
def test_seldon_sklearn_model_yaml(expected):
    m = Model(
        name="test-iris-sklearn",
        platform=ModelFramework.SKLearn,
        uri="gs://seldon-models/sklearn/iris",
        local_folder="/tmp/model",
        protocol=SeldonProtocol(),
    )
    runtime = SeldonKubernetesRuntime()
    yaml_str = runtime.manifest(m)
    yaml_obj = yaml.safe_load(yaml_str)
    yaml_obj_expected = yaml.safe_load(expected)
    del yaml_obj["metadata"]["annotations"]["seldon.io/tempo-model"]
    print("\n\n" + str(yaml_obj))
    print("\n\n" + str(yaml_obj_expected))
    assert yaml_obj == yaml_obj_expected
Ejemplo n.º 8
0
def test_seldon_model_yaml_auth(expected):
    m = Model(
        name="test-iris-xgboost",
        protocol=SeldonProtocol(),
        platform=ModelFramework.XGBoost,
        uri="gs://seldon-models/xgboost/iris",
        local_folder="/tmp/model",
    )
    runtime = SeldonKubernetesRuntime(runtime_options=KubernetesRuntimeOptions(
        authSecretName="auth"))
    yaml_str = runtime.manifest(m)
    yaml_obj = yaml.safe_load(yaml_str)
    yaml_obj_expected = yaml.safe_load(expected)
    del yaml_obj["metadata"]["annotations"]["seldon.io/tempo-model"]
    print("\n\n" + str(yaml_obj))
    print("\n\n" + str(yaml_obj_expected))
    assert yaml_obj == yaml_obj_expected
Ejemplo n.º 9
0
def test_seldon_xgboost_model_yaml(expected):
    m = Model(
        name="test-iris-xgboost",
        runtime=SeldonKubernetesRuntime(),
        platform=ModelFramework.XGBoost,
        uri="gs://seldon-models/xgboost/iris",
        local_folder="",
    )
    assert m.to_k8s_yaml() == expected
Ejemplo n.º 10
0
def test_seldon_sklearn_model_yaml(expected):
    m = Model(
        name="test-iris-sklearn",
        runtime=SeldonKubernetesRuntime(),
        platform=ModelFramework.SKLearn,
        uri="gs://seldon-models/sklearn/iris",
        local_folder="",
    )
    assert m.to_k8s_yaml() == expected
Ejemplo n.º 11
0
def test_deploy_yaml():
    rt = SeldonDeployRuntime(
        host="http://34.105.136.157/seldon-deploy/api/v1alpha1",
        user="******",
        password="******",
        k8s_options=KubernetesOptions(namespace="seldon"),
    )

    sklearn_model = Model(
        name="test-iris-sklearn",
        runtime=rt,
        platform=ModelFramework.SKLearn,
        uri="gs://seldon-models/sklearn/iris",
        local_folder=os.getcwd() + "/sklearn",
    )

    srt = SeldonKubernetesRuntime(k8s_options=KubernetesOptions(namespace="seldon"))
    sklearn_model.set_runtime(srt)
    expected = sklearn_model.to_k8s_yaml()
    sklearn_model.set_runtime(rt)
    assert sklearn_model.to_k8s_yaml() == expected
Ejemplo n.º 12
0
def test_create_k8s_runtime():
    rto = RuntimeOptions()
    rt = SeldonKubernetesRuntime(rto)
    assert rt.runtime_options.runtime == "tempo.seldon.SeldonKubernetesRuntime"
Ejemplo n.º 13
0
def k8s_runtime_v2(k8s_namespace: str) -> SeldonKubernetesRuntime:
    return SeldonKubernetesRuntime(
        k8s_options=KubernetesOptions(namespace=k8s_namespace),
        protocol=KFServingV2Protocol(),
    )
Ejemplo n.º 14
0
def k8s_runtime(k8s_namespace: str) -> SeldonKubernetesRuntime:
    return SeldonKubernetesRuntime(k8s_options=KubernetesOptions(
        namespace=k8s_namespace))
Ejemplo n.º 15
0
def k8s_runtime(k8s_namespace: str) -> SeldonKubernetesRuntime:
    return SeldonKubernetesRuntime(k8s_namespace)
Ejemplo n.º 16
0
 def to_k8s_yaml_spec(self, model_spec: ModelSpec) -> str:
     srt = SeldonKubernetesRuntime()
     return srt.to_k8s_yaml_spec(model_spec)
Ejemplo n.º 17
0
 def remote(self, model_spec: ModelSpec, *args, **kwargs) -> Any:
     self._create_api_client()
     srt = SeldonKubernetesRuntime()
     srt.remote(model_spec, *args, **kwargs)
Ejemplo n.º 18
0
 def to_k8s_yaml(self, model_details: ModelDetails) -> str:
     srt = SeldonKubernetesRuntime(k8s_options=self._k8s_options,
                                   protocol=self.protocol)
     return srt.to_k8s_yaml(model_details)