Conditions
Conditions
The Conditions tab holds a Python condition that decides, row by row, which rows are
written. Everything it refuses is produced, judged, and then thrown away: it never
reaches the destination.
The tab appears when the pipeline's Filter is set to Conditions, and it sits
where the filter runs: after the calculation, before the mapping.
What the script has to do
Set keep. Truthy writes the row, falsy drops it, and not setting it at all is an
error rather than a quiet pass.
keep = c1 > 40A fresh Conditions tab starts with keep = True already in the box: a complete
filter that keeps every row. Edit it into the rule you want; it is there so the task
runs before you have written anything, and so the one rule you have to know is on
screen as code rather than as a sentence.
Every key is an object
A condition sees the match the way a mapping does: the same words, without the
brackets. [a5.value] in a map is a5.value here, and the same key also answers its
properties:
| In a map | In a condition | What it is |
|---|---|---|
[c1.value] | c1: also c1.value | The channel's reading on this row |
[a1.uom] | a1.uom | The attribute's engineering units |
[e1.name] | e1.name | The matched element's name |
[tf1.template] | tf1.template | The event frame's AF template |
[scope.gmttime] | scope.gmttime | The row's own timestamp |
keep = a5.name == 'Pwr1' and 40.0 < a5.value < 120.0
keep = e1.name[-2:] == a3.name[-2:] and tf1.template == 'Batch'
keep = not a1.isexcluded and scope.page == 1Object properties lists every property of every kind, with its type
and what it resolves to: the same tables the Example button opens.
Three rules apply:
- A property the key does not have answers
Nonerather than raising, soa1.uom is Noneis a legal test. - Properties are read-only: assigning to one raises.
- A key whose name is not a valid Python word is reached through
keys:keys['5'].
The tab will offer them to you
The panel on the left lists everything this task can name: the pattern's keys, the
channels, the calculation's results, and a Context tab for scope. Double-click
one to write it into the script at the cursor, or drag it in. Type . after a key in
the editor and the properties it answers to appear with their data types.
Scalar or dataframe
The control at the top right of the script box is the same one the
Calculation tab has, and the two scripts are shaped differently:
| Mode | What keep is |
|---|---|
| Scalar (int, double, string) | One verdict for the row: keep = x1 > 40 |
| Timeseries Dataframe | A time-indexed mask over the series: keep = x1['value'] > 40 |
A dataframe mask must carry timestamps: a pandas Series on a DatetimeIndex, a
one-column frame, or a {t, v} dict. It is projected onto rows by carry-forward:
a row takes the latest verdict at or before its own time, and rows before the first
verdict are dropped.
The control only appears when the filter owns the mode, which is when the pipeline has
no calculation. With a calculation the condition runs in the calculation's mode,
and the tab says so instead of offering a second control that would be ignored.
Example
The Example button beside the Condition (Python) label opens a worked example: a
seven-row table, the same rule applied to it, and the four rows a destination would
receive. It also lists what this task can name: your own keys, with the properties
each answers to.
It is the fastest way to see what a condition does to a dataset without running one.
What happens to the rows it drops
A dropped row is gone for good. It never reaches the destination, the hold-back, the
checkpoint or a JSON document, and it does not advance the written-row index.
- The run log and every preview carry
filter kept [k] of [n] rows. - A window in which the filter drops every row still advances the watermark, so an
outage is not re-read forever. - A script that raises, or that never sets
keep, stops the run at the first error.
To see them, use Preview. Run the preview and tick Show filtered: the rows the
condition refused appear among the ones it kept, on a light red ground, marked
dropped. See Preview.
Test before you schedule
A condition that is subtly wrong produces a task that runs successfully and writes
nothing, which looks identical to a task with no data. Run preview on the
Conditions tab runs the task over its window and opens Preview with the verdicts
already on screen.
Where it is available
The filter feeds Table and JSON outputs. Choosing Conditions against a
write-back moves the output to Table, and the console says why.
What's Next
- Preview: the rows a destination would receive, and the ones the
filter refused - Calculation: the script that runs before this one
- Mapping: the columns the surviving rows become
Related
- Object properties: every property a condition can read
- Tasks: the pipeline the filter is a stage of
- Calculation Preview: what the calculation itself
produced