Skip to content

Johnfreeman/detdataformats issue100 code refactoring#101

Merged
jcfreeman2 merged 10 commits into
developfrom
johnfreeman/detdataformats_issue100_code_refactoring
Apr 28, 2026
Merged

Johnfreeman/detdataformats issue100 code refactoring#101
jcfreeman2 merged 10 commits into
developfrom
johnfreeman/detdataformats_issue100_code_refactoring

Conversation

@jcfreeman2
Copy link
Copy Markdown
Contributor

@jcfreeman2 jcfreeman2 commented Apr 24, 2026

Description

This is a refactor of the existing code, along with the addition of tests and the removal of a little unused API surface; it can be considered part of Issue #100, which itself falls under the umbrella of DUNE-DAQ/daq-deliverables#215.

Further details can be found in the commit statements themselves, but broadly speaking, this PR will:

  • Add unit tests for HSIFrame, DAQHeader and DAQEthHeader, none of which previously had unit tests
  • Add Python scripts in a new scripts/ directory which can be run to test the Python bindings in this package
  • Mitigate the general layout uncertainty introduced by bit fields by (1) not using them when they're not necessary, and (2) running static_asserts to check endianness
  • Further ensuring layout safety by checking structure size to guard against compiler padding, checking offsets, and checking that structures have standard layout and are trivially copyable
  • Separate implementation from interface by, e.g., moving streaming operators into *.hxx files
  • Remove unused API surface. This includes the DetID::to_string function as well as the version field of DetID, which I don't see used anywhere. If we're going to re-introduce it I feel like it should be under the condition that we put in PRs for code which use it in downstream packages.
  • Added Python bindings which were just missing (e.g., kVD_BernCRT and kVD_GrenobleCRT enum values for DetID) or which help with testing other Python bindings.

Testing the changes will involve:

  • Running the new tests and seeing that they all pass
  • Ensuring that the rest the of the codebase is unaffected, since this is a refactor PR - in other words, regression testing

Note that suggestions which will affect the interface should be implemented in a separate PR. Note also that after this PR is approved the code will be run through clang-format.

A test build using this feature branch was created for testing purposes, DDFFD_DEV_260427_A9.

Type of change

  • Documentation (non-breaking change that adds or improves the documentation)
  • New feature or enhancement (non-breaking change which adds functionality)
  • [X ] Optimization (non-breaking change that improves code/performance)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (whatever its nature)

Testing checklist

  • Unit tests pass (e.g. dbt-build --unittest)
  • Minimal system quicktest passes (pytest -s minimal_system_quick_test.py)
  • Full set of integration tests pass (dunedaq_integtest_bundle.sh) (*)
  • Python tests pass if applicable (e.g. python -m pytest)
  • Pre-commit hooks run successfully if applicable (e.g. pre-commit run --all-files)

(*) One thing went wrong during the integration tests, but it's not related to this PR and is the sort of thing we see occasionally in our nightlies: in the tpstream test there was There were 2 failures to insert data into the latency buffer out of 4882 attempts in the latest monitoring interval.

Further checks

  • Code is commented where needed, particularly in hard-to-understand areas
  • Code style is correct (dbt-build --lint, and/or see https://dune-daq-sw.readthedocs.io/en/latest/packages/styleguide/)
  • If applicable, new tests have been added or an issue has been opened to tackle that in the future.
    (Indicate issue here: # (issue))

Your Name added 8 commits April 15, 2026 16:50
…s to regular data types where possible to make checking more thorough
…s explicitly initialize uninitialized members to (absurd) values
In practice, this means simplifying DetID, since nowhere in the
codebase is its version field used or is its "is_in_valid_state()"
function called (which is just a check that the wrapped enum value
isn't kUnknown).
…putting streamer declarations into headers but their definitions into *.hxx files
… with our coding standards, as well as quieting linter complaints about unavoidable unsigned integer use
@jcfreeman2 jcfreeman2 marked this pull request as ready for review April 27, 2026 18:09
Comment thread pybindsrc/daqethheader.cpp Outdated
…tionality Eric introduced into styleguide scripts to deal with extensive unsigned integer use; also update unit tests to pass our linters
Comment thread pybindsrc/hsi.cpp Outdated
Copy link
Copy Markdown
Member

@eflumerf eflumerf left a comment

Choose a reason for hiding this comment

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

LGTM!

@jcfreeman2 jcfreeman2 merged commit f7ae3e0 into develop Apr 28, 2026
3 checks passed
@jcfreeman2 jcfreeman2 deleted the johnfreeman/detdataformats_issue100_code_refactoring branch April 28, 2026 18:40
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