Skip to content

fixes to shef exporter - #76

Merged
Enovotny merged 4 commits into
masterfrom
73-shefparser-export-command-generates-empty-shef-file-when-some-aliases-are-empty
Jun 3, 2026
Merged

fixes to shef exporter#76
Enovotny merged 4 commits into
masterfrom
73-shefparser-export-command-generates-empty-shef-file-when-some-aliases-are-empty

Conversation

@Enovotny

@Enovotny Enovotny commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes for issue #73, #74, #75 plus
related robustness improvements to the CDA exporter/loader and the export CLI.

Changes

CDA exporter (shef/exporters/cda_exporter.py)

  • Skip time series whose CDA fetch errors, returns a non-dict payload, or has
    no values in the window — log and continue instead of aborting the whole
    export.
  • Build the JSON payload via json.dumps(list) rather than hand-assembling
    [...] with comma bookkeeping.
  • Defer make_export_transforms() until needed, and pass the specific group_id
    when exporting a group.

CDA loader (shef/loaders/cda_loader.py)

  • make_export_transforms() now accepts an optional group_id so a single group
    can be fetched instead of all SHEF Export groups. Tracks loaded groups to
    avoid redundant CDA calls.
  • Skip assigned time series with missing/empty alias-id (root cause of shefParser export command generates empty SHEF file when some aliases are empty #73)
    with a warning instead of producing an empty SHEF file.
  • Added group_office_id filter on cwms.get_timeseries_groups.

Export CLI (shef/shef_parser.py)

  • Replaced the hec.HecTime dependency in export with a local parse_dt
    supporting ISO 8601 and HEC-style relative times (T, T-1D, T+2H, …).
  • Require both --start-time and --end-time; raise click.BadParameter on
    unparseable input.
  • Remainder of the file is whitespace/line-wrap reformatting (no logic
    changes).

Optional dependencies (pyproject.toml, dss_loader.py, abstract_exporter.py)

  • cwms-python and hecdss are now optional extras (pip install .[cda], .[dss]).
  • dss_loader guards imports and raises a clear ImportError if hecdss is
    missing.
  • Removed unused top-level import cwms from abstract_exporter.py.

Tests

Three new test files:

Test plan

  • pytest tests/test_cda_exporter_empty_series.py
    tests/test_cda_loader_make_export_transforms.py
    tests/test_export_time_window.py
  • Run shef export against a real CDA office with at least one group containing
    an empty-alias entry and verify the output SHEF file is non-empty.
  • Verify pip install . (no extras) still imports shef.shef_parser without
    hecdss/cwms installed.

@Enovotny
Enovotny merged commit fad34bf into master Jun 3, 2026
4 checks passed
@Enovotny Enovotny linked an issue Jun 3, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant