Skip to content

Add safe env injector in logging demonstrator#65

Open
emmuhamm wants to merge 1 commit intodevelopfrom
emmuhamm/demonstrator-env-injector
Open

Add safe env injector in logging demonstrator#65
emmuhamm wants to merge 1 commit intodevelopfrom
emmuhamm/demonstrator-env-injector

Conversation

@emmuhamm
Copy link
Copy Markdown
Collaborator

Description

Fix #58

See above for full desc.

Add a new class called EnvInjector which does this automatically for us:

  • initialise with a known ers env mapping that we want
  • scrapes the currently defined env variables for safe keeping
  • Methods to inject, return, and restore env variables

Used in any of the tests that require this environment variable.

Atm only defined in logging demonstrator, as it is unclear where the EnvInjector might be useful for the public. If the need arises, we can move to the utils file or similar.

Testing

Check out on latest nightly

In the terminal, if currently unset, set DUNEDAQ_ERS_WARNING to be any random string (anything works, if you need inspiration try 'bippityboppityboo')

Run daqpytools-logging-demonstrator -r -eh -hc

See that both the handlerconf and the ers handler test behave as expected

When back in the terminal, try echoing the previously set variable. It should remain as whatever you set it as.

(I'm pretty sure this isnt needed, as shown in the discussion in the linked issue, but eh why not include it)

Type of change

  • New feature or enhancement (non-breaking change which adds functionality)

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)

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))

@emmuhamm emmuhamm added the enhancement New feature or request label Mar 25, 2026
@emmuhamm emmuhamm requested a review from PawelPlesniak March 25, 2026 11:10
@emmuhamm emmuhamm self-assigned this Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Some simple features to add (all can be done in one PR)

2 participants