コード例 #1
0
ファイル: test_deploy.py プロジェクト: michaelcheah/tempo
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
コード例 #2
0
def test_kubernetes_spec(sklearn_model: Model):
    options = KubernetesOptions(namespace="production", replicas=1)
    k8s_object = KubernetesSpec(sklearn_model.details, SeldonProtocol(),
                                options)

    expected = {
        "apiVersion": "machinelearning.seldon.io/v1",
        "kind": "SeldonDeployment",
        "metadata": {
            "name": sklearn_model.details.name,
            "namespace": options.namespace,
        },
        "spec": {
            "protocol":
            "seldon",
            "predictors": [{
                "graph": {
                    "modelUri":
                    sklearn_model.details.uri,
                    "name":
                    "classifier",
                    "type":
                    "MODEL",
                    "implementation":
                    KubernetesSpec.Implementations[
                        sklearn_model.details.platform],
                },
                "name": "default",
                "replicas": options.replicas,
            }],
        },
    }

    assert k8s_object.spec == expected
コード例 #3
0
ファイル: test_deploy.py プロジェクト: michaelcheah/tempo
def test_deploy():
    rt = SeldonDeployRuntime()

    config = SeldonDeployConfig(
        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=SeldonDeployAuthType.oidc,
    )

    rt.authenticate(settings=config)

    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,
    )

    rt.deploy(sklearn_model)
    rt.wait_ready(sklearn_model)
    print(sklearn_model(np.array([[4.9, 3.1, 1.5, 0.2]])))
    rt.undeploy(sklearn_model)
コード例 #4
0
ファイル: k8s.py プロジェクト: M46F/tempo
 def __init__(self, k8s_options: KubernetesOptions = None, protocol=None):
     if k8s_options is None:
         k8s_options = KubernetesOptions()
     self.k8s_options = k8s_options
     self.create_k8s_client()
     if protocol is None:
         self.protocol = SeldonProtocol()
     else:
         self.protocol = protocol
コード例 #5
0
ファイル: test_yaml.py プロジェクト: michaelcheah/tempo
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
コード例 #6
0
ファイル: test_yaml.py プロジェクト: michaelcheah/tempo
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
コード例 #7
0
ファイル: test_yaml.py プロジェクト: michaelcheah/tempo
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))
コード例 #8
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
コード例 #9
0
ファイル: test_specs.py プロジェクト: RafalSkolasinski/tempo
def test_tensorflow_spec():
    md = ModelDetails(
        name="test",
        local_folder="",
        uri="",
        platform=ModelFramework.Tensorflow,
        inputs=ModelDataArgs(args=[]),
        outputs=ModelDataArgs(args=[]),
    )
    protocol = SeldonProtocol()
    options = KubernetesOptions(namespace="production", replicas=1)
    runtime_options = RuntimeOptions(k8s_options=options)
    model_spec = ModelSpec(model_details=md,
                           protocol=protocol,
                           runtime_options=runtime_options)
    spec = get_container_spec(model_spec)
    assert "image" in spec
    assert "command" in spec
コード例 #10
0
ファイル: deploy.py プロジェクト: adriangonz/tempo
 def __init__(
     self,
     host: str,
     user: str,
     password: str,
     auth_type: SeldonDeployAuthType = SeldonDeployAuthType.session_cookie,
     k8s_options: KubernetesOptions = None,
     _protocol=None,
 ):
     if k8s_options is None:
         k8s_options = KubernetesOptions()
     self._k8s_options = k8s_options
     self._host = host
     self._user = user
     self._password = password
     self._auth_type = auth_type
     if _protocol is None:
         self.protocol = SeldonProtocol()
     else:
         self.protocol = _protocol
コード例 #11
0
 def __init__(self, protocol=None):
     if protocol is None:
         self.protocol = SeldonProtocol()
     else:
         self.protocol = protocol