Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danijar/portal
Fast and reliable distributed systems in Python
https://github.com/danijar/portal
arrays client concurrency distributed numpy parallel parallelism performance python rpc server sockets throughput
Last synced: about 2 months ago
JSON representation
Fast and reliable distributed systems in Python
- Host: GitHub
- URL: https://github.com/danijar/portal
- Owner: danijar
- License: mit
- Created: 2023-08-27T20:01:09.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-21T19:48:09.000Z (3 months ago)
- Last Synced: 2024-10-09T13:13:56.475Z (3 months ago)
- Topics: arrays, client, concurrency, distributed, numpy, parallel, parallelism, performance, python, rpc, server, sockets, throughput
- Language: Python
- Homepage: https://pypi.org/project/portal
- Size: 222 KB
- Stars: 19
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![PyPI](https://img.shields.io/pypi/v/portal.svg)](https://pypi.python.org/pypi/portal/#history)
# 🌀 Portal
Fast and reliable distributed systems in Python.
## Features
- 📡 **Communication:** Portal lets you bind functions to a `Server` and call
them from one or more `Client`s. Wait on results via `Future` objects.
Clients can automatically restore broken connections.
- 🚀 **Performance:** Optimized for throughput and latency. Array data is
zero-copy serialized and deserialized for throughput near the hardware limit.
- 🤸 **Flexibility:** Function inputs and outputs can be nested dicts and lists
of numbers, strings, bytes, None values, and Numpy arrays. Bytes allow
applications to chose their own serialization, such as `pickle`.
- 🚨 **Error handlings:** Provides `Process` and `Thread` objects that can
reliably be killed by the parent. Unhandled exceptions in threads stop
the program. Error files can be used to stop distributed systems.
- 📦 **Request batching:** Use `BatchServer` to collect multiple incoming
requests and process them at once, for example for AI inference servers.
Batching and dispatching happens in a separate process to free the GIL.
- ✅ **Correctness:** Covered by over 100 unit tests for common usage and edge
cases and used for large scale distributed AI systems.## Installation
```sh
pip install portal
```## Example
This example runs the server and client in the same Python program using
subprocesses, but they could also be separate Python scripts running on
different machines.```python
def server():
import portal
server = portal.Server(2222)
server.bind('add', lambda x, y: x + y)
server.bind('greet', lambda msg: print('Message from client:', msg))
server.start()def client():
import portal
client = portal.Client('localhost', 2222)
future = client.add(12, 42)
result = future.result()
print(result) # 54
client.greet('Hello World')if __name__ == '__main__':
import portal
server_proc = portal.Process(server, start=True)
client_proc = portal.Process(client, start=True)
client_proc.join()
server_proc.kill()
print('Done')
```## Questions
Please open a separate [GitHub issue](https://github.com/danijar/portal/issues)
for each question.