Skip to content

Data streaming ADR for period indexing#227

Merged
rerpha merged 2 commits into
masterfrom
adr_periods
Jul 16, 2026
Merged

Data streaming ADR for period indexing#227
rerpha merged 2 commits into
masterfrom
adr_periods

Conversation

@rerpha

@rerpha rerpha commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

No description provided.


In the previous system, periods are 1-indexed to a user. This means that a dashboard can display things like `1/1 periods` if using a single period, or for example `9/12` periods to show a run that is in progress and currently collecting data to period 9. This means that PVs that interface the client and/or `genie_python` need to display as 1-indexed. Conversely, the hardware was 0-indexed, so the ICP had to subtract 1 from the served PV.

As well as hardware, periods in a NeXus file were previously 0-indexed, which made array slicing more straightforward as most programming languages similarly index starting at 0.

@FreddieAkeroyd FreddieAkeroyd Jul 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The period number in period_log in a nexus file is 1 based

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so i mean from a mantid file reading point of view it is using 1 based periods when it used period_log to find period for an event

We will use 0-indexing everywhere (in hardware, udp format, flatbuffers, nexus files) other than the period PVs served by `kafka_dae_control` and `kafka_dae_diagnostics` which will subtract and add one respectively to set and display period numbers.

There was a consideration to reserve period 0 as an "unknown" period, similar to how traditionally the 0th detector was reserved for malformed data, however this doesn't make sense in the streaming world and an event without a period should just be discarded by the hardware or UDP to Kafka layer.

@FreddieAkeroyd FreddieAkeroyd Jul 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

period 0 was traditionally used on the user facing GUI to mean "current period" i.e. you woudl setthe display to use period 0 and it would display whatever was being collected in the current period on the graph

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the current period being whatever the period card was set to

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was it - i thought 1 was, so you could have 1/1 periods rather than 0/1 periods

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Freddie means PVs like SPEC:0:1:X (where the format is SPEC:period:detector) where that zero is interpreted as current period. I think this is mainly a concern for kafka_dae_diagnostics.

@FreddieAkeroyd FreddieAkeroyd Jul 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes things like Tom says, also on PVs used by e.g. live view OPI screen - you can choose period you want to display in live view, if you choose period 0 there it displays picture for current period so saves user needing to toggle between flipper on and flipper off etc.


In the previous system, periods are 1-indexed to a user. This means that a dashboard can display things like `1/1 periods` if using a single period, or for example `9/12` periods to show a run that is in progress and currently collecting data to period 9. This means that PVs that interface the client and/or `genie_python` need to display as 1-indexed. Conversely, the hardware was 0-indexed, so the ICP had to subtract 1 from the served PV.

As well as hardware, periods in a NeXus file were previously 0-indexed, which made array slicing more straightforward as most programming languages similarly index starting at 0.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having checked, and after a discussion with @FreddieAkeroyd, the data in /raw_data_1/framelog/period_log is 1-indexed. So I think filewriter will also need to do the +1 when it writes data (we have to treat the .nxs effectively as a "user interface") to remain backwards compatible.

This doesn't change the rest of the decision that we can be zero-indexed in hardware and in flatbuffers etc, just that the nexus writer will need a bit of logic for this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also anything writing a multi-dimensional period based histogram to a nexus file will need to know to set the axis labels array for period number to be one based.


There was a consideration to reserve period 0 as an "unknown" period, similar to how traditionally the 0th detector was reserved for malformed data, however this doesn't make sense in the streaming world and an event without a period should just be discarded by the hardware or UDP to Kafka layer.

## Consequences

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this section can we list more explicitly that:

  • Hardware will use zero-indexed
  • UDP messages from detectors will use zero-indexed
  • Flatbuffers messages, both before and after event_aggregator, will use zero-indexed
  • kafka_dae_control will use zero-indexed everywhere except user-facing PVs, where it will need to do a conversion
  • kafka_dae_diagnostics will use zero-indexed everywhere except user-facing PVs, where it will need to do a conversion
  • Filewriter will need to do a conversion internally to remain consistent with old format, such that flatbuffers messages saying "period 0" end up in a frame log called "period 1".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are we considering as a "user-facing PVs" - any PV without explicit access control on it, or any pv that doesn't start/end with an _, or any not documented as user facing?

@Tom-Willemsen Tom-Willemsen Jul 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any pv that doesn't start/end with an _

This feels like a reasonable definition to me. I think we've used conventions like IN:INST:_SOMETHING:SOME_PARAMETER in the past if everything in _SOMETHING is private, so maybe

PV that has no component starting/ending with a _

might be more precise, but not that bothered.

@rerpha
rerpha marked this pull request as ready for review July 16, 2026 12:15
@rerpha

rerpha commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

let's get this in for now, can always change later

@rerpha
rerpha merged commit 5a2bb52 into master Jul 16, 2026
2 checks passed
@rerpha
rerpha deleted the adr_periods branch July 16, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants