pamoja-profile
Named, ready-to-run device profiles from plain data or a JSON manifest. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
pip install pamoja-profile
from pamoja import profile
This pulls in pamoja-native, the compiled engine. pip install pamoja is the whole framework in one package.
Example
The script the test suite runs, spliced here as it ran.
From bindings/python/guides/profile.py:
from pamoja.profile import AlertKind, ControlKind, ElementSpec, Presentation, Profile, Viz
# A profile is plain data, so a fleet ships one as a file rather than as code. The two
# power thresholds are optional and fall back to the documented defaults.
manifest = """{
"name": "brooder-heater",
"topic": "poultry/brooder/temperature",
"control": {
"kind": "setpoint", "setpoint": 32.0, "hysteresis": 0.5,
"cooling": false, "safe_band": 4.0
},
"power": { "active_secs": 120, "saver_secs": 600, "critical_secs": 1800 }
}"""
profile = Profile.from_json(manifest)
print(f"{profile.name} reports on {profile.topic}")
print(f"wakes every {profile.power.active_secs}s while the battery is healthy")
print(f"saver mode below {profile.power.saver_below * 100:.0f}% charge")
# The manifest is the whole control loop. At 27.5 C the reading is below the deadband, so
# the lamp switches on, and it is more than 4 C from target, so the chicks are cold.
cold = profile.controller().evaluate(27.5)
print(f"at 27.5 C: lamp {cold.actuator}, alert {cold.alert.kind if cold.alert else None}")
# Back inside the deadband the lamp is left as it was, and nothing is raised.
settled = profile.controller().evaluate(32.2)
print(f"at 32.2 C: lamp {settled.actuator}, alert {settled.alert}")
# Serializing writes the defaulted fields out in full, so a profile edited on a device and
# shared back carries no value the next reader has to infer.
shared = profile.to_json()
print(f"shared form names its defaults: {'saver_below' in shared}")
# The manifest also carries how a dashboard draws the node: one element here, the
# brooder's temperature as a thermometer with the band the chicks are safe in.
drawn = profile.with_presentation(
Presentation(
[
ElementSpec(
"brooder_temperature", "celsius", "Brooder temperature", Viz.THERMOMETER,
band=(28, 36),
),
]
)
)
element = drawn.presentation.elements[0]
low, high = element.band
print(f"draws {element.key} in {element.unit} with a safe band of {low:g} to {high:g}")
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-profile |
reference, docs.rs, install |
| TypeScript | @pamoja/profile |
reference, install |
| Python | pamoja-profile |
reference, install |
| C# | Pamoja.Profile |
reference, install |
Documentation
pamoja.profilereference, every class and function in this module.- The Device profiles guide, with the same example in Rust, TypeScript, and C#.
- Every capability, and the install page.
License
MIT
Release files for pamoja-profile 0.1.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pamoja_profile-0.1.18.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pamoja_profile-0.1.18-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.5 kB
Release files / pamoja_profile-0.1.18.tar.gz
| Download URL | pamoja_profile-0.1.18.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28d4e2e60543773f0a660515e055532f38ddc2fd5b38ace094c61c4b4f07c950
|
|
BLAKE2b-256 checksum How to use checksums |
04dce227bb994ed6d6020f493ab0457504582d0da372812b50f22f98b98d7413
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pamoja_profile-0.1.18-py3-none-any.whl
| Download URL | pamoja_profile-0.1.18-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db304e4867b91fee328d41cf41a1642bb13190718eec615c0b7eea5391b9c320
|
|
BLAKE2b-256 checksum How to use checksums |
b4aa5fbe9dcad861fa464dd39bab968877827beddbd288daec82544bca7a2457
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|