Skip to content

Commit c338326

Browse files
committed
Merge branch 'usgs_5_to_15' of https://github.com/tsressin/cwms-cli into usgs_5_to_15
2 parents d7b9757 + 578810f commit c338326

59 files changed

Lines changed: 3441 additions & 240 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM mcr.microsoft.com/devcontainers/python:1-3.12-bookworm
2+
3+
ARG POETRY_VERSION=2.0.1
4+
5+
ENV TZ=Etc/UTC \
6+
POETRY_HOME=/opt/poetry \
7+
VIRTUAL_ENV=/home/vscode/.venv \
8+
POETRY_VIRTUALENVS_CREATE=false
9+
ENV PATH="${VIRTUAL_ENV}/bin:${POETRY_HOME}/bin:${PATH}"
10+
11+
RUN python -m venv "${POETRY_HOME}" \
12+
&& "${POETRY_HOME}/bin/python" -m pip install --no-cache-dir \
13+
"poetry==${POETRY_VERSION}" \
14+
&& python -m venv "${VIRTUAL_ENV}" \
15+
&& chown -R vscode:vscode "${VIRTUAL_ENV}"

.devcontainer/devcontainer.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "cwms-cli",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"args": {
6+
"POETRY_VERSION": "2.0.1"
7+
}
8+
},
9+
"remoteUser": "vscode",
10+
"containerEnv": {
11+
"TZ": "Etc/UTC",
12+
"POETRY_HOME": "/opt/poetry",
13+
"VIRTUAL_ENV": "/home/vscode/.venv",
14+
"POETRY_VIRTUALENVS_CREATE": "false"
15+
},
16+
"postCreateCommand": "git config --global --add safe.directory \"$(pwd)\" && poetry install --with dev --no-interaction",
17+
"customizations": {
18+
"vscode": {
19+
"extensions": [
20+
"ms-python.python"
21+
],
22+
"settings": {
23+
"python.defaultInterpreterPath": "/home/vscode/.venv/bin/python"
24+
}
25+
}
26+
}
27+
}

.github/CODEOWNERS

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,25 @@
22
# Generated from maintainers.toml by scripts/sync_ownership.py.
33
# Update maintainers.toml, then rerun the sync script.
44

5-
* charles.r.graham@usace.army.mil eric.v.novotny@usace.army.mil # Default owners for repository-wide files and shared cwms-cli behavior
5+
* charles.r.graham@usace.army.mil eric.v.novotny@usace.army.mil # Fallback owners for paths without a later, more specific rule; keep this rule first
66
/.github/CODEOWNERS charles.r.graham@usace.army.mil eric.v.novotny@usace.army.mil # Protect ownership rules themselves
7+
/maintainers.toml charles.r.graham@usace.army.mil eric.v.novotny@usace.army.mil # Primary configuration file for ownership metadata
8+
/scripts/sync_ownership.py charles.r.graham@usace.army.mil eric.v.novotny@usace.army.mil # Ownership metadata generator
9+
/AGENTS.md charles.r.graham@usace.army.mil eric.v.novotny@usace.army.mil # Repository ownership maintenance guidance
710
/cwmscli/commands/csv2cwms/ charles.r.graham@usace.army.mil
811
/docs/cli/csv2cwms*.rst charles.r.graham@usace.army.mil
912
/cwmscli/commands/blob.py charles.r.graham@usace.army.mil
1013
/docs/cli/blob.rst charles.r.graham@usace.army.mil
1114
/cwmscli/utils/update.py charles.r.graham@usace.army.mil
1215
/docs/cli/update.rst charles.r.graham@usace.army.mil
16+
/tests/cli/test_update_command.py charles.r.graham@usace.army.mil
1317
/cwmscli/load/ charles.r.graham@usace.army.mil eric.v.novotny@usace.army.mil
1418
/docs/cli/load_*.rst charles.r.graham@usace.army.mil eric.v.novotny@usace.army.mil
19+
/tests/load/ charles.r.graham@usace.army.mil eric.v.novotny@usace.army.mil
20+
/tests/commands/test_load_*.py charles.r.graham@usace.army.mil eric.v.novotny@usace.army.mil
1521
/cwmscli/usgs/ eric.v.novotny@usace.army.mil
16-
/cwmscli/commands/shef_critfile_import.py eric.v.novotny@usace.army.mil
22+
/tests/usgs/ eric.v.novotny@usace.army.mil
23+
/tests/cli/test_usgs_*.py eric.v.novotny@usace.army.mil
24+
/cwmscli/commands/shef/ eric.v.novotny@usace.army.mil
25+
/tests/commands/test_shef_*.py eric.v.novotny@usace.army.mil
1726
/cwmscli/commands/commands_cwms.py charles.r.graham@usace.army.mil eric.v.novotny@usace.army.mil # Shared Click wrappers span commands owned by both maintainers

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ body:
88
label: CLI Script
99
description: Select the script this pertains to
1010
options:
11-
- blob
12-
- cwms-cli
13-
- csv2cwms
14-
- getusgs-measurements
11+
- blob
12+
- cwms-cli
13+
- csv2cwms
14+
- dss
15+
- getusgs-measurements
1516
- getusgs-ratings
1617
- getusgs-timeseries
1718
- shefcritimport

.github/ISSUE_TEMPLATE/feature-request.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ body:
88
label: CLI Script
99
description: Select the script this pertains to
1010
options:
11-
- blob
12-
- cwms-cli
13-
- csv2cwms
14-
- getusgs-measurements
11+
- blob
12+
- cwms-cli
13+
- csv2cwms
14+
- dss
15+
- getusgs-measurements
1516
- getusgs-ratings
1617
- getusgs-timeseries
1718
- shefcritimport

.github/workflows/cli-tests.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,34 @@ on:
66

77
jobs:
88
test:
9-
name: Test CLI on ${{ matrix.python-version }}
10-
runs-on: ubuntu-latest
9+
name: Test CLI on ${{ matrix.name }} with Python ${{ matrix.python-version }}
10+
runs-on: ${{ matrix.os }}
1111

1212
strategy:
13+
fail-fast: false
1314
matrix:
14-
# Test 3.9 for T7, 3.12 for general/cloud use
15-
python-version: ["3.9", "3.12"]
15+
include:
16+
# Test the supported Python range on Linux and exercise the primary
17+
# Python version on each supported desktop operating system.
18+
- name: Linux
19+
os: ubuntu-latest
20+
python-version: "3.9"
21+
- name: Linux
22+
os: ubuntu-latest
23+
python-version: "3.12"
24+
- name: Windows
25+
os: windows-latest
26+
python-version: "3.12"
27+
- name: macOS
28+
os: macos-latest
29+
python-version: "3.12"
1630

1731
steps:
1832
- name: Checkout repository
1933
uses: actions/checkout@v7
2034

2135
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v6
36+
uses: actions/setup-python@v7
2337
with:
2438
python-version: ${{ matrix.python-version }}
2539

@@ -38,3 +52,17 @@ jobs:
3852

3953
- name: Run full test suite
4054
run: poetry run pytest -q
55+
56+
test-devcontainer:
57+
name: Test dev container on 3.12
58+
runs-on: ubuntu-latest
59+
60+
steps:
61+
- name: Checkout repository
62+
uses: actions/checkout@v7
63+
64+
- name: Build dev container and run tests
65+
uses: devcontainers/ci@v0.3
66+
with:
67+
push: never
68+
runCmd: poetry run pytest -q

.github/workflows/code-check.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v7
1212

13-
- uses: actions/setup-python@v6
13+
- uses: actions/setup-python@v7
1414
with:
1515
python-version: "3.12"
1616

@@ -25,4 +25,12 @@ jobs:
2525
- name: Verify generated ownership files
2626
run: poetry run python scripts/sync_ownership.py --check
2727

28-
- uses: pre-commit/action@v3.0.1
28+
- name: Show quality tool versions
29+
run: |
30+
poetry run black --version
31+
poetry run isort --version-number
32+
poetry run yamlfix --version
33+
poetry run pre-commit --version
34+
35+
- name: Run pre-commit checks
36+
run: poetry run pre-commit run --all-files --show-diff-on-failure

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v7
19-
- uses: actions/setup-python@v6
19+
- uses: actions/setup-python@v7
2020
with:
2121
python-version: "3.12"
2222
- name: Install deps

.github/workflows/release-please.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ jobs:
4747
ref: ${{ needs.release-please.outputs.tag_name }}
4848

4949
- name: Set Up Python
50-
uses: actions/setup-python@v6
50+
uses: actions/setup-python@v7
5151
with:
5252
python-version: "3.x"
5353

5454
- name: Install Poetry
5555
uses: abatilo/actions-poetry@v4
5656

5757
- name: Cache Virtual Environment
58-
uses: actions/cache@v5
58+
uses: actions/cache@v6
5959
with:
6060
path: ./.venv
6161
key: venv-${{ hashFiles('poetry.lock') }}
@@ -70,7 +70,7 @@ jobs:
7070
uses: pypa/gh-action-pypi-publish@release/v1
7171

7272
- name: Sign Distribution
73-
uses: sigstore/gh-action-sigstore-python@v3.4.0
73+
uses: sigstore/gh-action-sigstore-python@v3.5.0
7474
with:
7575
inputs: |
7676
./dist/*.tar.gz

AGENTS.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Repository instructions
2+
3+
Guidance for coding agents working in `HydrologicEngineeringCenter/cwms-cli`.
4+
5+
- Never push to `origin` unless the user explicitly says they are ready for
6+
that push.
7+
- Use JDK 21 or newer for new work that is not intended to run on T7 systems.
8+
On Windows, use JDK 21 at `C:\Program Files\Java\jdk-21`. On Linux or other
9+
Unix-like systems, select an installed JDK 21 or newer through `JAVA_HOME`.
10+
Use another Java version only when the target or task requires it.
11+
- Use the `.devcontainer` Linux/Python 3.12 environment for changes involving
12+
time zones, paths, native libraries, HEC-DSS, or other operating-system-
13+
dependent behavior.
14+
- Run the full dev-container test suite with
15+
`devcontainer exec --workspace-folder . poetry run pytest -q` when the dev
16+
container is available. The standard CI matrix separately covers Python 3.9
17+
and Python 3.12 package compatibility.
18+
19+
## Terminal colors
20+
21+
- Use the shared helpers in `cwmscli.utils.colors` for user-facing terminal
22+
color. Prefer `colors.ok`, `colors.warn`, `colors.err`, and `colors.dim` for
23+
their semantic cases, or `colors.c(text, color, bright=...)` when a specific
24+
color is needed.
25+
- Do not embed ANSI escape sequences or initialize Colorama in individual
26+
commands. Global logging setup owns Colorama initialization and calls
27+
`colors.set_enabled(...)` so `--no-color`, `--log-file`, and non-TTY output
28+
remain consistent.
29+
- Keep the text meaningful without color. Color should clarify status or
30+
structure, not carry information that disappears when color is disabled.
31+
- Reuse the existing conventions: green for success, yellow for warnings,
32+
red for errors, cyan or blue for identifiers and commands, and dim text for
33+
secondary detail.
34+
- When testing colored output, cover the plain-text behavior first. Enable the
35+
shared color helper explicitly only in tests that need to assert escape codes,
36+
and restore its state afterward.
37+
38+
## Ownership metadata
39+
40+
- Use `maintainers.toml` as the primary configuration file for maintainer names,
41+
CLI ownership, documentation maintainer notes, package authors, and
42+
CODEOWNERS rules. Do not edit generated ownership files directly.
43+
- When adding, renaming, moving, or removing a command, implementation area,
44+
documentation page, test area, workflow, or other substantial path, review
45+
and update the corresponding entries in `maintainers.toml` in the same
46+
change.
47+
- Keep the fallback `*` CODEOWNERS rule first. GitHub applies the last matching
48+
rule, so more-specific rules must appear after the fallback.
49+
- Prefer explicit CODEOWNERS rules for implementation, documentation, and tests
50+
that share the same maintainer. Keep ownership-governance files themselves
51+
explicitly owned.
52+
- After changing `maintainers.toml`, run
53+
`poetry run python scripts/sync_ownership.py`, review every generated change,
54+
and then run `poetry run python scripts/sync_ownership.py --check`.
55+
- Before completing ownership changes, verify that configured command names and
56+
CODEOWNERS paths still exist and that GitHub reports no CODEOWNERS errors.
57+
58+
## Git safety
59+
60+
- Never push to `origin` unless the user explicitly authorizes the push.
61+
- Do not use `codex`, `agent`, AI-related terms, or similar prefixes in branch
62+
names. Use a short, human-readable branch name tied to the concern.
63+
- Inspect untracked files before staging and leave unrelated work untouched.

0 commit comments

Comments
 (0)