HydrologicEngineeringCenter / HydrologicEngineeringCenter/cwms-cli

Reporting Script

Open
#28 1 comment 0 reactions 0 assignees View on GitHub

@krowvin is already working on this.

Since Sep 30, 2025.

  • #46 by @krowvin — open
enhancement
Dominant language
Python
Stars
2
Forks
4
Avg merge
19h 59m
Merged PRs (30d)
3

Description

CLI Script

Other

Feature Proposal

Talking with @danieltosborne about reports

Integrating Report Generation (repgen) into cwms-cli

What are our thoughts on creating the following

cwms-cli reporting --engine repgen5 --output=myfile.txt --input=mytemplate.txt ..args
or
cwms-cli reporting --engine jinja3 --output=myfile.html --input=myfile.html.j2 ..args

Idea is to make re-use of the existing click arg handling, the same package distribution, and provide users with the ability to have a one stop shop for their scripting needs.

We talked briefly about if it made sense to GitHub sub module these, i.e. keep them in their own repos. But this has potential to archive the existing repgen5 repo?

Another thought, for down the road is we could add a .pdf output and make it use itext (with jpype) with input template libraries.

Details

Repgen would be updated to use cwms-python and jinja and the pdf option later could also use jinja.

This combines the DEF and FORM tags and makes for highly dynamic reports and outsources template documentation to Jinja while making use of the enterprise data fetch library and exposing it's mathematical capabilities straight in the template.

Things like JSON, HTML, TXT, and many other formats are dynamically opened with built-in vscode syntax highlighters.

@NobuNobuu has had success using Jinja + Cwms-Python to generate reports at SWF

Examples:
<!-- templates/_table.html.j2 -->
<div class="table-responsive plot-container mb-5">
  <table class="table align-middle table-hover table-bordered mb-0 data-table">
    <thead>
      <tr class="first-row">
        <th rowspan="1">Reservoir</th>
        <th colspan="2">Pool Elevation (ft)</th>
      </tr>
      <tr class="second-row">
        <th rowspan="2"></th>
        <th rowspan="2">8AM<br>FT-NGVD</th>
      </tr>
    </thead>
    <tbody>
      {% for basin_name, reservoirs in basins.items() %}
      <tr class="table-secondary">
        <th colspan="17" class="text-start">{{ basin_name }}</th>
      </tr>
      {% for prefix, name in reservoirs %}
      <tr class="table-light">
        <td class="text-start">{{ name }}</td>
        <td>{{ ts(name="keys.elev.inst.1Hour.0.Ccp-Rev", office="SWT") }}</td>
      </tr>
      {% endfor %}
      {% endfor %}
    </tbody>
  </table>
</div>

Additional thoughts

If we are looking at a whole rewrite of repgen for the new engine in addition to what exists, it was thought we could do that in the repgen repo. But perhaps some change to add it to cwms-cli would help with adoption and get most districts using the same report generation methods.

Going a step further (in the future) we can define standard template types that regions might need. For example

cwms-cli reporting --template-theme=USACE-WM ...args

Related Context or Links

https://jinja.palletsprojects.com/en/stable/

https://github.com/USACE-WaterManagement/repgen5

https://github.com/HydrologicEngineeringCenter/cwms-python/

http://www.jpype.org/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the cwms-cli command entry points and the linked pull request #46, then compare the existing repgen5 and cwms-python repositories. The issue proposes several engines, output formats, template themes, and possible repository changes, so the scope and acceptance criteria need to be resolved before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.