コード例 #1
0
def status_modelapi(id_, **kwargs):
    """Get state of modelapi.
    :param id_: The ID of the modelapi resource
    :type id_: str

    :rtype: object
    """

    modelapi = get_modelapi_object(id_)
    check_modelapi_permission(modelapi, kwargs["token_info"])
    stub = get_modelapis_services_stub()
    response = stub.State(job_pb2.ID(id=id_))

    return util.deserialize_protobuf(response)
コード例 #2
0
def create_modelapi(body, **kwargs):
    """Create a modelapi

    :param body: modelapi payload
    :type body: dict | bytes

    :rtype: ModelApiSerializer
    """
    serializer = ModelApiSerializer.from_dict(body)
    check_modelapi_permission(serializer, kwargs["token_info"])

    stub = get_modelapis_services_stub()
    response = stub.Create(job_pb2.ModelApis(**body))

    return ModelApiSerializer.from_dict(util.deserialize_protobuf(response))
コード例 #3
0
def list_modelapis(body=None, **kwargs):
    """List modelapis

    :param body:
    :type body: dict | bytes

    :rtype: PageLimitListSerializer
    """
    payload = body

    if body is None:
        payload = {"query": {}}

    stub = get_modelapis_services_stub()
    response = stub.Search(job_pb2.SearchRequest(**payload))

    return util.deserialize_protobuf(response)
コード例 #4
0
def start_modelapi(id_, **kwargs):
    """Start a job
    :param id_: The ID of the modelapi resource
    :type id_: str

    :rtype: StatusSerializer
    """
    modelapi = get_modelapi_object(id_)
    check_modelapi_permission(modelapi, kwargs["token_info"])
    stub = get_modelapis_services_stub()
    response = stub.Start(job_pb2.ID(id=id_))

    if response.status != 200:
        return ErrorSerializer(status=response.status,
                               title="Api Error",
                               detail=response.message), response.status

    return StatusSerializer.from_dict(util.deserialize_protobuf(response))
コード例 #5
0
def get_modelapi_object(modelapi_id):
    stub = get_modelapis_services_stub()
    return stub.Retrieve(job_pb2.ID(id=modelapi_id))