question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gRPC List API error

See original GitHub issue

hi I have a problem when trying to get a list of registerd model from torchserve I’m using both of REST API and gRPC API but only gRPC API don’t work when using ListModelsRequest

in REST API

requests.get("http://0.0.0.0:18091/models")

returns model list successfully

‘models’: [{‘modelName’: ‘aaa’, ‘modelUrl’: ‘aaa.mar’}, {‘modelName’: ‘bbb’, ‘modelUrl’: ‘bbb.mar’}]}

but in gRPC API

def list_models(stub, t):
    params = {'next_page_token':int(t)}
    try:
        response = stub.ListModels(management_pb2.ListModelsRequest(**params))
        return response.msg
    except grpc.RpcError as e:
        logger.error("Failed to gRPC list models.")
        logger.info(str(e.details()))
        exit(1)

grpc_func.list_models(grpc_func.get_management_stub(), 0)

returns empty list { “nextPageToken”: “0”, “models”: [] }

I’m using exactly same proto file in https://github.com/pytorch/serve/tree/master/frontend/server/src/main/resources/proto

please help

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
vdogmcgeecommented, Dec 6, 2022

yes , its comments do not match the code , i also try many times

1reaction
somizghcommented, Oct 13, 2022

@msaroufim I followed this guide https://github.com/pytorch/serve/blob/master/docs/getting_started.md

I use mac OS and run it using cpu

and changed some codes in torchserve_grpc_client.py to use listmodels

def list_models(stub):
    params = {}
    try:
        response = stub.ListModels(management_pb2.ListModelsRequest(**params))
        return response.msg
    except grpc.RpcError as e:
        exit(1)


if __name__ == '__main__':
    # args:
    # 1-> api name [infer, register, unregister]
    # 2-> model name
    # 3-> model input for prediction
    args = sys.argv[1:]
    if args[0] == "infer":
        infer(get_inference_stub(), args[1], args[2])
    elif args[0] =="list":
        print(list_models(get_management_stub()))
        import requests
        print(requests.get("http://localhost:8081/models").content)
    else:
        api = globals()[args[0]]
        if args[0] == "register":
            api(get_management_stub(), args[1], args[2])
        else:
            api(get_management_stub(), args[1])

and typed

python ts_scripts/torchserve_grpc_client.py list

prints { “nextPageToken”: “0”, “models”: [] } b’{\n “models”: [\n {\n “modelName”: “densenet161”,\n “modelUrl”: “densenet161.mar”\n }\n ]\n}\n’

the result of gRPC above returns empty and result of rest below returns “densenet161” successfully

Read more comments on GitHub >

github_iconTop Results From Across the Web

GRPC Core: Status codes and their use in gRPC
Code Number Description OK 0 Not an error; returned on success. FAILED_PRECONDITION 9 OUT_OF_RANGE 11
Read more >
Errors | Cloud APIs - Google Cloud
The following table lists each error code and an example of a good error message. HTTP, gRPC, Example Error Message. 400, INVALID_ARGUMENT, Request...
Read more >
Status Response Codes | Google Maps Booking API
Code Status Notes 0 OK Return on Success 3 INVALID_ARGUMENT The client specified an invalid argument. 5 NOT_FOUND Some requested entity wasn't found.
Read more >
Handling errors | Yandex Cloud - Documentation
gRPC code gRPC status HTTP code 1 CANCELLED 499 2 UNKNOWN 500 3 INVALID_ARGUMENT 400
Read more >
Advanced gRPC Error Usage - Johan Brandhorst
The Go gRPC implementation has a status package which exposes a nice simple interface for creating rich gRPC errors. For example, lets say...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found