Phloem SDK for Python
Send readings from Python to Phloem. Each reading becomes a named channel you can watch live, replay, chart and check, the same as one from a connector.
import phloem
with phloem.connect("hil-runner") as ph:
ph.log_now("/rig/psi", 3.2)
Install
pip install phloem # or: uv add phloem
Python 3.9 or later. Wheels for Linux (x64, Arm64; including Alpine), macOS (Apple silicon, Intel) and Windows (x64). Nothing else to install. Fully typed: editors and type checkers see every call.
Two ways to send
connect picks the way by whether it is given an API key.
| Through Phloem on this machine | Straight to the cloud | |
|---|---|---|
| When | no API key | an API key is set |
| Needs | Phloem Computer, or the Phloem service on a server; the program allowed once on Inputs | a workspace API key and your workspace's URL, both on the account page |
| If the network drops | nothing is lost: Phloem keeps the data on disk and uploads it later | data waits in memory (64 MiB by default) |
| For | test stands, anything with hardware | CI jobs, simulations, notebooks |
To send straight to the cloud, set the two values the account page shows beside a new key, then run the same program:
export PHLOEM_URL=https://api.<your-environment>.phloem.ai
export PHLOEM_API_KEY=phla_…
or pass them: phloem.connect("ci", url=..., api_key=...). ph.route says
which way the data is going.
Sending
import time
import phloem
with phloem.connect("bench-pc") as ph:
# one reading, stamped now
ph.log_now("/rig/psi", 3.2)
# readings at their own time
t0 = time.time_ns()
ph.log("/rig/mode", t0, "source", "fire")
ph.log_many("/rig/psi", "source", [t0, t0 + 1_000_000], [3.1, 3.2])
# a fixed-rate signal: each block starts where the last one ended
s = ph.stream(["/daq/ch0", "/daq/ch1"], "host", step_hz=1000)
s.push({"/daq/ch0": ch0_block, "/daq/ch1": ch1_block})
# say that data is missing from a point
ph.gap(["/daq/ch0"], t0, "overrun")
| Call | What it does |
|---|---|
log_now(path, value) |
one reading, stamped with this machine's clock |
log(path, t_ns, basis, value) |
one reading at its own time |
log_many(path, basis, times_ns, values) |
many readings of one channel |
stream(paths, basis, step_hz=…) then push({path: block, …}) |
a fixed-rate sender |
gap(paths, frontier_ns, detail) |
state that data is missing |
flush() |
send what is held now |
close() |
end the stream; raises if anything was not delivered |
Values: float, int, bool or str. Paths name channels:
/rig/psi.
Timestamps always say which clock they are on: "host" (this machine's),
"source" (your device's or recording's own) or "backdated:<anchor_us>" (a
recording replayed now). There is no default.
Knowing nothing was lost
Leaving the with block (or ph.close()) waits for everything to be
delivered. If anything was not, it raises phloem.UnsentError with the exact
count of readings, so a CI job fails instead of passing silently.
| Exception | When |
|---|---|
phloem.UnsentError |
at close: something was not delivered |
PermissionError |
the key was refused or revoked, or the program is not allowed on this machine yet (the message says how to allow it) |
ConnectionError |
Phloem or the cloud could not be reached |
ValueError |
a call was wrong, for example an API key with no URL |
Good to know
- One program per name. The name you pass is the program. A second program started under the same name takes over and the first one stops. Give parallel jobs their own names.
- After a crash, readings still in memory are lost. Do not send again what was already sent: it would be stored twice. Send through Phloem on the machine where that matters.
- Version:
phloem.__version__. Every language's SDK is released at the same version.
Documentation
https://phloem.ai/docs/sdk/ · runnable examples: examples/ · what changed in each version: CHANGELOG.md.
Support
Found a bug or need something? Open an issue.
Licence
Apache License 2.0.
Metadata
Release files for phloem 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 43.3 MB
Release files / phloem-0.1.0-cp39-abi3-win_amd64.whl
| Download URL | phloem-0.1.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2176b6ac9b25cc0ea3bcd6767c37676292c5bb0832d16bb8756e76ab6c221d61
|
|
BLAKE2b-256 checksum How to use checksums |
fb134cb8f77c93d402e1bc59f053baed3c90d9d1e6e6bed7d5fff1d4822e4d53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / phloem-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
| Download URL | phloem-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 6.4 MB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
8c7fd0859a2e887a626e7b72f6c52d7dbdf3e6940cd715e160326fdbb81145bc
|
|
BLAKE2b-256 checksum How to use checksums |
654fc973bc4e1493e446cb1c4fb32e795344fdd24d737f6e25426f1cf8ec0ae1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / phloem-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl
| Download URL | phloem-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.9 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
a282a6878e322f881741de352260fcfad42b5c9b11f4ca6842826c5989f67974
|
|
BLAKE2b-256 checksum How to use checksums |
cc722f00546402c7e59971f14f39d663dea43bd6acc3e7bf915fbe4ad801ac28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / phloem-0.1.0-cp39-abi3-manylinux_2_28_x86_64.whl
| Download URL | phloem-0.1.0-cp39-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 6.4 MB |
| Tags | CPython 3.9 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2f3354f8eded6be4769979d8d56cf585e47b83aea0abf26f97475d63f0f398bd
|
|
BLAKE2b-256 checksum How to use checksums |
1715895e73e8c545f43c4ac8a699a61f44f9ca928b6567e5bbbb6541163f516b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / phloem-0.1.0-cp39-abi3-manylinux_2_28_aarch64.whl
| Download URL | phloem-0.1.0-cp39-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.9 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
0f88b5a687a4bee163482f2dbe425db23f5ca5aeeeb13f24d22fbbe5cffd548b
|
|
BLAKE2b-256 checksum How to use checksums |
8fefed85367995aaff548d3892cde2c80ffe3bc16e5f0b462e7986a638ccfc1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / phloem-0.1.0-cp39-abi3-macosx_11_0_x86_64.whl
| Download URL | phloem-0.1.0-cp39-abi3-macosx_11_0_x86_64.whl |
|---|---|
| Size | 6.5 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
9d5f9e95154f91beda09a06de61bb8afacf24cece2a6e6aef5fe2f11739ffc4a
|
|
BLAKE2b-256 checksum How to use checksums |
6453f0782b7b8d89be8843493a496f9379288a674abd2dbe573a069627f1d5c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / phloem-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | phloem-0.1.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 6.2 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
48a75341dff946871f7f0a36eb056fc05d06c1bb2f344c8af1ba83ac4011ecd3
|
|
BLAKE2b-256 checksum How to use checksums |
1e21fc3d73c8be012d522f39e3dbde60aa08c85ab786818180d2507eaa8309be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for phloem 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.