Sunday, 28 February 2021

Quick and resilient way to expose a python library API over the network as well as locally

I'm looking for an easy and dependency-light way of wrapping a python library to expose it over:

a) The network, either via HTTP or some other custom protocol, it doesn't matter that much, and encryption isn't required. b) The local machine, the main purpose here is to avoid library import overhead, ideally, this would happen via an efficient mechanism ala pipes or shared memory to minimize the number of data copies and [de]serialization.

It seems like it's an easy enough job to just create a class that runs constantly, with e.g. an HTTP interface mirroring the library functionality and returning e.g. pickled objects corresponding to the answers. But getting it to work efficiently and cover various edge-cases seems tedious and I'm wondering if there's a better way to do this, ideally one that's built into python itself.

Ray seems to have some functionality for this using Actors, but it seems rather heavy-weight and prone to fail when being installed, so I'm curios what alternatives exist.

Also, might be too much of a "library question", if you think it's better suited for another stack exchange website please tell me which and I'll remove it from here.



from Quick and resilient way to expose a python library API over the network as well as locally

No comments:

Post a Comment