Skip to content

feat: Improve crashes, check apparatus defaults#75

Open
henry-wallace-phys wants to merge 7 commits into
developfrom
hwallace/feature/cleaner_startup
Open

feat: Improve crashes, check apparatus defaults#75
henry-wallace-phys wants to merge 7 commits into
developfrom
hwallace/feature/cleaner_startup

Conversation

@henry-wallace-phys

@henry-wallace-phys henry-wallace-phys commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Description

  • Checks for apparatus defaults currently NP02 and NP04
  • Does by parsing the standard setup scripts
  • Lets the user start with `runconf-shifter-ui -a [apparatus]
  • Cleaner start up crashes

Testing: Start runconf-shifter-ui with either -a np02 or -a np04. Also test start-up after running runconf_np02_env_setup.sh. Additionally test breaking path with either no -a (and no setup script) and -a foo to check for breaking paths (no apparatus or non-existent apparatus)

Type of change

  • Documentation (non-breaking change that adds or improves the documentation)
  • New feature or enhancement (non-breaking change which adds functionality)
  • 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 (daqsystemtest_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)

Comments here on the testing

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

@henry-wallace-phys henry-wallace-phys self-assigned this Jun 8, 2026
@henry-wallace-phys henry-wallace-phys changed the title Improve crashes, check apparatus defaults feat: Improve crashes, check apparatus defaults Jun 9, 2026

@MRiganSUSX MRiganSUSX left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank @henry-wallace-phys.
Few comment below :)

Comment on lines +184 to +187
if apparatus is None:
raise ValueError(
"Apparatus must be specified with -a or APPARATUS env variable"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not raise click.UsageError(...) ? That gives a clean "Error: ..." line and exits with code 2 (standard).

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.

fixed

Comment thread src/runconf_ui/apps/runconf_ui_main.py Outdated
Comment on lines +198 to +200
raise ValueError(
"If any of base_url, ops_url, or config_file_name are not specified, all three must be resolved from the apparatus defaults."
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as before, wouldn't click.UsageError(...) be more appropriate ?

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.

Fixed

Comment thread src/runconf_ui/apps/runconf_ui_main.py Outdated

# Matches lines like: export KEY="VALUE" or export KEY=${OTHER_VAR}/value
# Specifically captures the key and everything inside the quotes
export_pattern = re.compile(r'^\s*export\s+([A-Za-z0-9_]+)\s*=\s*"([^"]+)"')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not necessarily problematic atm, but this way it very much depends on the setup scripts being always the same / right for this.
For example export BASE_URL='...' or export BASE_URL=https://... are skipped with this regex.

Suggested extended pattern:

export_pattern = re.compile(
    r'^\s*export\s+([A-Za-z0-9_]+)\s*=\s*(?:"([^"]*)"'
    r"|'([^']*)'|([^#\s]*))"
)

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.

I've implemented this as I agree this is sensible to have

Comment thread src/runconf_ui/apps/runconf_ui_main.py Outdated
config_file_name = apparatus_defaults.get("config_file_name")
elif any(v is None for v in apparatus_vars):
raise ValueError(
"If any of base_url, ops_url, or config_file_name are not specified, all three must be resolved from the apparatus defaults."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggest changing this to

"Specify all of --base-url, --ops-url, and --config-file-name together, or omit all three to use apparatus defaults."

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.

Fixed

Comment on lines -121 to -128
:param apparatus: DAQ apparatus name (e.g., NP02, NP04)
:param config_directory: Path to configuration directory
:param output_directory: Directory to save run configs to
:param use_local: Use local filesystem instead of remote API
:param config_file_name: Config file to find in the ops repo
:param base_url: URL for the BASE repository
:param ops_url: URL for the operations repository
:param log_level: Log level (INFO, WARNING, DEBUG)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know you removed this because it was causing some --help problems or similar, but... isn't there a solution where we can have both proper --help and a docstring ? Some of the parameters' env-var fallbacks and mutual-exclusion rules were only documented there.

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.

[2 mins of reading documentation later....] This is now re-implemented and doesn't print with --help

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