Пример #1
0
def EndpointSpec(framework, storage_uri, service_account):
    if framework == "tensorflow":
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            tensorflow=V1alpha2TensorflowSpec(storage_uri=storage_uri),
            service_account_name=service_account,
        ))
    elif framework == "pytorch":
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            pytorch=V1alpha2PyTorchSpec(storage_uri=storage_uri),
            service_account_name=service_account,
        ))
    elif framework == "sklearn":
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            sklearn=V1alpha2SKLearnSpec(storage_uri=storage_uri),
            service_account_name=service_account,
        ))
    elif framework == "xgboost":
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            xgboost=V1alpha2XGBoostSpec(storage_uri=storage_uri),
            service_account_name=service_account,
        ))
    elif framework == "onnx":
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            onnx=V1alpha2ONNXSpec(storage_uri=storage_uri),
            service_account_name=service_account,
        ))
    elif framework == "tensorrt":
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            tensorrt=V1alpha2TensorRTSpec(storage_uri=storage_uri),
            service_account_name=service_account,
        ))
    else:
        raise ("Error: No matching framework: " + framework)
Пример #2
0
def EndpointSpec(framework,
                 storage_uri,
                 service_account_name="k8s-sa",
                 transformer_custom_image=""):
    if framework == 'tensorflow':
        return V1alpha2EndpointSpec(
            predictor=V1alpha2PredictorSpec(
                service_account_name=service_account_name,
                tensorflow=V1alpha2TensorflowSpec(storage_uri=storage_uri)),
            transformer=V1alpha2TransformerSpec(
                min_replicas=1,
                custom=V1alpha2CustomSpec(container=client.V1Container(
                    image=transformer_custom_image,
                    name="kfserving-container"))))
    elif framework == 'pytorch':
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            pytorch=V1alpha2PyTorchSpec(storage_uri=storage_uri)))
    elif framework == 'sklearn':
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            sklearn=V1alpha2SKLearnSpec(storage_uri=storage_uri)))
    elif framework == 'xgboost':
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            xgboost=V1alpha2XGBoostSpec(storage_uri=storage_uri)))
    elif framework == 'onnx':
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            onnx=V1alpha2ONNXSpec(storage_uri=storage_uri)))
    elif framework == 'tensorrt':
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            tensorrt=V1alpha2TensorRTSpec(storage_uri=storage_uri)))
    else:
        raise ("Error: No matching framework: " + framework)
Пример #3
0
def EndpointSpec(framework, storage_uri):
    if framework == 'tensorflow':
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            tensorflow=V1alpha2TensorflowSpec(storage_uri=storage_uri)))
    elif framework == 'pytorch':
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            pytorch=V1alpha2PyTorchSpec(storage_uri=storage_uri)))
    elif framework == 'sklearn':
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            sklearn=V1alpha2SKLearnSpec(storage_uri=storage_uri)))
    elif framework == 'xgboost':
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            xgboost=V1alpha2XGBoostSpec(storage_uri=storage_uri)))
    elif framework == 'onnx':
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            onnx=V1alpha2ONNXSpec(storage_uri=storage_uri)))
    elif framework == 'tensorrt':
        return V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
            tensorrt=V1alpha2TensorRTSpec(storage_uri=storage_uri)))
    else:
        raise ("Error: No matching framework: " + framework)
def EndpointSpec(framework, storage_uri, service_account, min_replicas,
                 max_replicas):

    endpointSpec = V1alpha2EndpointSpec(predictor=V1alpha2PredictorSpec(
        service_account_name=service_account,
        min_replicas=(min_replicas if min_replicas >= 0 else None),
        max_replicas=(max_replicas if max_replicas > 0
                      and max_replicas >= min_replicas else None)))
    if framework == "tensorflow":
        endpointSpec.predictor.tensorflow = V1alpha2TensorflowSpec(
            storage_uri=storage_uri)
        return endpointSpec

    elif framework == "pytorch":
        endpointSpec.predictor.pytorch = V1alpha2PyTorchSpec(
            storage_uri=storage_uri)
        return endpointSpec

    elif framework == "sklearn":
        endpointSpec.predictor.sklearn = V1alpha2SKLearnSpec(
            storage_uri=storage_uri)
        return endpointSpec

    elif framework == "xgboost":
        endpointSpec.predictor.xgboost = V1alpha2XGBoostSpec(
            storage_uri=storage_uri)
        return endpointSpec

    elif framework == "onnx":
        endpointSpec.predictor.onnx = V1alpha2ONNXSpec(storage_uri=storage_uri)
        return endpointSpec

    elif framework == "tensorrt":
        endpointSpec.predictor.tensorrt = V1alpha2TensorRTSpec(
            storage_uri=storage_uri)
        return endpointSpec

    else:
        raise ("Error: No matching framework: " + framework)