Skip to content

Revisit validation for WRF-Hydro channel-restart reader selector (leave lenient for now) #39

Description

@jameshalgren

Context

This issue is a companion to the implementation of the reordering WRF-Hydro channel-restart reader (new function get_channel_restart_from_wrf_hydro_reorder, selected by the config parameter wrf_hydro_channel_restart_input_type: reorder).

That implementation deliberately uses lenient validation. This issue tracks revisiting it. For now, we are intentionally leaving validation less strict — this is a placeholder to come back to, not an immediate action item.

Current (lenient) behavior

  1. Selector value is not validated. wrf_hydro_channel_restart_input_type is declared as Optional[str] = None. Any value other than exactly "reorder" (including "Reorder", "REORDER", or a typo) silently falls through to the default reader. The comparison is case-sensitive and happens at the call sites via .get(..., None) == "reorder".

  2. Crosswalk file still required even when unused. The existing validator check_wrf_hydro_restart_files in src/troute-config/troute/config/config.py (lines ~218–235) asserts wrf_hydro_channel_ID_crosswalk_file is present whenever wrf_hydro_channel_restart_file is given. The reorder reader does not use the crosswalk file, so this requirement is technically unnecessary in that pathway. It was kept for symmetry and to avoid changing behavior.

What to revisit later

  • Validate the selector value. Consider a Pydantic validator on RestartParameters.wrf_hydro_channel_restart_input_type (in compute_parameters.py) that restricts it to a known set (e.g. {None, "reorder"}), or model it as an Enum / Literal, so typos raise an error instead of silently reverting to the default reader.
  • Relax the crosswalk requirement for the reorder pathway. Optionally allow omitting wrf_hydro_channel_ID_crosswalk_file when wrf_hydro_channel_restart_input_type == "reorder", since it is ignored there.
  • Case sensitivity. Decide whether the selector should be case-insensitive and normalize accordingly.

Decision for now

Leave validation lenient (as implemented). Revisit under this issue once the reorder pathway has seen real-world use and we understand the desired strictness. Use uv for any Python/test invocations when this is picked up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions