py-bridge
JSON-RPC 2.0 worker helper for PyBridge Elixir Ports.
Installation
pip install elixir-bridge
Usage
from py_bridge import worker
@worker.register
def predict(features: list[float]) -> dict:
return {"prediction": sum(features) / len(features)}
@worker.register
def add(a: int, b: int) -> dict:
return {"sum": a + b}
if __name__ == "__main__":
worker.run()
This creates a Python script that communicates with an Elixir PyBridge.Worker GenServer over stdin/stdout using JSON-RPC 2.0.
How It Works
@worker.registerexposes a function as a callable JSON-RPC methodworker.run()starts the stdin/stdout event loop- Requests and responses are newline-delimited JSON
- Exceptions are caught and returned as JSON-RPC error objects with tracebacks
Elixir Side
# Add py_bridge to your mix.exs deps, then:
{:ok, _} = PyBridge.Worker.start_link(
name: :my_worker,
python: "python3",
script: "path/to/worker.py"
)
{:ok, %{"prediction" => 0.5}} =
PyBridge.call(:my_worker, "predict", %{features: [1.0, 2.0, 3.0]})
See the full documentation for more details.
License
MIT
Metadata
Release files for elixir-bridge 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| elixir_bridge-0.1.0.tar.gz | 4.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| elixir_bridge-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.1 kB
Release files / elixir_bridge-0.1.0.tar.gz
| Download URL | elixir_bridge-0.1.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f76d5b201699e026d665cdfafb7ab1643a31b22a34d15ea2a33625c6d2188828
|
|
BLAKE2b-256 checksum How to use checksums |
108289ad5c7c23212303e8783d1690bba450209ef9902cda8f136c4fe714615c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.21
|
Release files / elixir_bridge-0.1.0-py3-none-any.whl
| Download URL | elixir_bridge-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1c3ebe7a8630863437a14b046f81ae551bf178534aaea668f5d2b50ccf6cfae6
|
|
BLAKE2b-256 checksum How to use checksums |
92ee7bd1dabf1598ec856eaeb0eea65cd526562f56e87d09ddca99d39445910d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.21
|
Security for elixir-bridge 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.