Skip to content

[BUG] - Gadi: uw.Params ignores CLI arguments unless options are parsed first #111

@gthyagi

Description

@gthyagi

Summary

On Gadi HPC, uw.Params does not apply CLI overrides (e.g. -uw_cellsize 1/16) even though arguments are correctly passed via sys.argv. This occurs because CLI options are not loaded into the PETSc options database (uw.options) before Params(...) is constructed. As a result, parameters silently fall back to defaults.

Repro

Run: python script.py -uw_cellsize 1/16
Code:

params = uw.Params(uw_cellsize=uw.Param("1/8", type=uw.ParamType.STRING))
print(params.uw_cellsize) → returns 1/8 (default, incorrect)

Observations
• sys.argv contains CLI arguments correctly
• uw.options.hasName("cellsize") == False on Gadi
• CLI values are ignored during Params initialization
• After calling uw.parse_cmd_line_options(), CLI values are correctly applied
• Behaviour differs from macOS where it works without explicit parsing

Root cause

Params reads CLI values from uw.options (PETSc options DB), not directly from sys.argv.
On Gadi, this database is not populated automatically before Params(...) is created, leading to missed overrides.

Fix / Workaround

Call uw.parse_cmd_line_options() before creating Params:

uw.parse_cmd_line_options()
params = uw.Params(...)

Impact
• Silent fallback to defaults (no warning)
• Incorrect results in batch/PBS workflows
• Hard-to-debug, environment-dependent behaviour

Suggested improvement

Automatically parse CLI options before Params(...), or clearly document this requirement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions