Skip to content

Provide a mechanism of testing the SDK locally without need for the snet platform #11

Open
@raamb

Description

Ok, after porting one of my grpc clients to this sdk (or the simple alternative) there is one major design thing I'm concerned about.

It looks like I need different code paths for singularitynet and for calling the service without the singularitynet layer. e.g. if I have a local service, and I'm testing it (without any blockchain stuff), I want to use almost the exact same code as when I'm calling the production service.

Ideally I'd be able to fetch the model from either a local directory (yet to be published), or from snet. Then it'd be compiled and I could create a stub and request, but it'd only add the MPE stuff if I'm actually calling the service via MPE.

Any idea if you've already allowed for this @vforvalerio87 - or if it'd be easy to support something like this?

snet = Snet(private_key=pk)
if snet_enabled:
    client = snet.client("snet", "face-detect")
else:
    client = snet.client(directory="service/service_spec", endpoint="http://localhost:50015")

### snet-sdk-python with full grpc specification
stub = client.grpc.face_detect_pb2_grpc.FaceDetectStub(client.grpc_channel)
request = client.grpc.face_detect_pb2.Request(image=client.grpc.face_detect_pb2.ImageRGB(content=...))
faces = stub.FindFace(request)

### simple-sdk version
stub = client.get_stub()
request_cls = client.get_request(method='FindFace')
request = request_cls(image={content=...}))
rez = stub.FindFace(request)

If a directory and endpoint is provided, then no MPE work is done, nothing is looked up on the registry etc.

Edit: updated to include what @astroseger's simple-sdk would have to look like.

Originally posted by @ferrouswheel in #5 (comment)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions