Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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), macOS (Apple silicon, Intel) and Windows (x64). Nothing else to install.

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/

Licence

Apache License 2.0.

Metadata

Release files for phloem 0.1.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for phloem 0.1.0rc1
File Interpreter ABI Platform Actions
phloem-0.1.0rc1-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details for phloem-0.1.0rc1-cp39-abi3-manylinux_2_28_x86_64.whl
phloem-0.1.0rc1-cp39-abi3-macosx_11_0_x86_64.whl CPython 3.9 abi3 macOS 11.0+ x86-64 Details for phloem-0.1.0rc1-cp39-abi3-macosx_11_0_x86_64.whl
phloem-0.1.0rc1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for phloem-0.1.0rc1-cp39-abi3-macosx_11_0_arm64.whl

Total release size: 19.2 MB

Release files / phloem-0.1.0rc1-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL phloem-0.1.0rc1-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
158024e28c6e881665d2cd91dd58f4c148d833c263741c646f90eb53b4e78604
BLAKE2b-256 checksum
How to use checksums
da0f24b4ce4fb72ee405d4e002cce0d8e41982793c6fc513caf1ae2e68db5317
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.0rc1-cp39-abi3-macosx_11_0_x86_64.whl

Download URL phloem-0.1.0rc1-cp39-abi3-macosx_11_0_x86_64.whl
Size 6.6 MB
Tags CPython 3.9 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
7dc7cb15085adba93950503269ec9a7e6f297983c44de040fb9750a261dd6bb3
BLAKE2b-256 checksum
How to use checksums
ac91cbc2bbe95aa83c8d55d98de3c50a7fda791b7636dccd418927a805c12d0c
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.0rc1-cp39-abi3-macosx_11_0_arm64.whl

Download URL phloem-0.1.0rc1-cp39-abi3-macosx_11_0_arm64.whl
Size 6.3 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
651d97a2c5da1070008f50f51ee7502bc1eeb76e65d9e158c2644c36d3a4b502
BLAKE2b-256 checksum
How to use checksums
c12386c2b0790164322cb2af77861152b3bc89867303d6b4af78a025f26832d9
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.0rc1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page