Is there a way to call experimental APIs
# spicedb
j
Is there a way to call experimental APIs in a python client? The only way I found at the moment is to subclass a new ExperimentalClient with ExperimentalServiceStub. Maybe it could be added to python client lib?
While doing
Copy code
class ExperimentalClient(
    SchemaServiceStub, PermissionsServiceStub, ExperimentalServiceStub
)
works, it feels like they could just be added to normal client interface.
a
Hi Jure. Does it really work for you? Where do you import ExperimentalServiceStub from? Is it
from authzed.api.v1.experimental_service_pb2_grpc import ExperimentalServiceStub
?
ExperimentalServiceStub works for me as well, but WatchServiceStub fails with
Copy code
status = StatusCode.UNIMPLEMENTED
        details = "unknown service authzed.api.v1.WatchService"
while it is registered in the same way as ExperimentalServiceStub
j
Copy code
from authzed.api.v1.experimental_service_pb2_grpc import ExperimentalServiceStub
from authzed.api.v1.permission_service_pb2_grpc import PermissionsServiceStub
from authzed.api.v1.schema_service_pb2_grpc import SchemaServiceStub
class ExperimentalClient(
    SchemaServiceStub, PermissionsServiceStub, ExperimentalServiceStub
):
    def __init__(self, target, credentials, options=None, compression=None):
        try:
            asyncio.get_running_loop()
            channelfn = grpc.aio.secure_channel
        except RuntimeError:
            channelfn = grpc.secure_channel

        channel = channelfn(target, credentials, options, compression)
        SchemaServiceStub.__init__(self, channel)
        PermissionsServiceStub.__init__(self, channel)
        ExperimentalServiceStub.__init__(self, channel)
I haven't tested WatchServiceStub at the moment
v
Hey! It seems like there is a bit of manual plumbing that didn't take place in the python client in order to have the experimental service exposed. We'll look into it, thanks for bringing it up!
j
I've created a PR https://github.com/authzed/authzed-py/issues/101 so it doesn't get lost and that people can subscribe to it.
v
Thank you! PR should be ready at https://github.com/authzed/authzed-py/pull/100
@jure0888 0.13.0 should be out, addressing 2 of the issues you opened https://pypi.org/project/authzed/0.13.0/
j
Thank you! 🙂