Python Expr Service (f8.pyexpr)¶
Standalone expression runtime service for simplified data-flow transforms.
- Service class:
f8.pyexpr - Version:
0.0.1 - Source directory:
f8/pyexpr - Tags:
python,expr,service
When to Use¶
- Use
f8.pyexprfor lightweight one-expression extraction, remapping, and conditional logic. - It is best for quick field access, formula-based transforms, and simple glue logic.
- It is often faster than spinning up a full
PyEnginebranch when the logic is truly small.
Common Wiring Patterns¶
- Place it between two modules as a thin expression layer.
- It is commonly used to turn structured payloads into one clean numeric or boolean output.
- It is a strong choice for quick prototyping and validation.
Pitfalls / Gotchas¶
- Once the logic needs multiple steps, imports, or persistent state, move it to
f8.pyengineorf8.pyscript. - If upstream payload shape is unstable, write defensively rather than assuming one exact structure forever.
- It is best for quick, thin logic, not for the most important long-term business rules in the graph.
Service Reference¶
How to Run¶
pixi run -e default f8pyexpr
- Workdir:
../../../ - Environment overrides: none
Typical Inputs / Outputs¶
- Data inputs:
msg - Data outputs:
out,monitor - Commands: none
Service State Fields¶
| Name | Access | Required | On Node | Schema | Description |
|---|---|---|---|---|---|
code |
rw |
true |
true |
string / default=msg |
Single-line expression. Available names: inputs + identifier-safe input ports. |
allowNumpy |
wo |
true |
false |
boolean / default=False |
Enable numpy calls in expressions (np., numpy.). |
unpackDictOutputs |
wo |
true |
false |
boolean / default=False |
When enabled, dict results are emitted per matching output port key. |
lastError |
ro |
true |
false |
string / default= |
Last expression compile/eval error. |
active |
rw |
true |
false |
boolean / default=True |
Service lifecycle state (activate/deactivate). |
svcId |
ro |
true |
false |
string |
Readonly: current service instance id (svcId). |
Key Fields That Matter¶
code(Expr,rw): Single-line expression. Available names: inputs + identifier-safe input ports. Schema:string / default=msg.allowNumpy(Allow Numpy,wo): Enable numpy calls in expressions (np., numpy.). Schema:boolean / default=False.unpackDictOutputs(Unpack Dict Outputs,wo): When enabled, dict results are emitted per matching output port key. Schema:boolean / default=False.lastError(Last Error,ro): Last expression compile/eval error. Schema:string / default=.active(Active,rw): Service lifecycle state (activate/deactivate). Schema:boolean / default=True.svcId(Service Id,ro): Readonly: current service instance id (svcId). Schema:string.
Service Commands¶
None
Service Data Input Ports¶
| Name | Required | On Node | Schema | Description |
|---|---|---|---|---|
msg |
false |
true |
any |
Default input value. |
Service Data Output Ports¶
| Name | Required | On Node | Schema | Description |
|---|---|---|---|---|
out |
false |
true |
any |
Default expression output value. |
monitor |
true |
false |
object{active, alive, cpu, error, ...} |
Unified runtime monitor snapshots (health/resource/perf/error). |
Operators¶
None