Skip to content
executing-hms-runs logo

Executing HEC-HMS Runs

executing-hms-runs

Executes HEC-HMS simulations using HmsCmdr.compute_run(), handles parallel execution across multiple runs, and manages Jython script generation. Use when running HMS simulations, executing runs, computing models, or setting up parallel computation workflows. Handles HMS 3.x and 4.x version differ...

mattnigh/skills_collection0installs24stars

SKILL.md

Full skill instructions

Executing HEC-HMS Runs

Quick Start

from hms_commander import init_hms_project, HmsCmdr

# Initialize project
init_hms_project(r"C:\Projects\watershed")

# Execute single run
HmsCmdr.compute_run("Run 1")

# Execute multiple runs in parallel
HmsCmdr.compute_parallel(["Run 1", "Run 2", "Run 3"], max_workers=2)

Primary Sources

Code (Authoritative API):

  • hms_commander/​HmsCmdr.py - Execution engine with complete docstrings
  • hms_commander/​HmsJython.py - Script generation and version detection

Examples (Working Demonstrations):

  • examples/​01_multi_version_execution.ipynb - Complete workflow
  • examples/​04_hms_workflow.ipynb - End-to-end simulation

Rules (Patterns & Decisions):

  • .claude/​rules/​hec-hms/​execution.md - Execution patterns
  • .claude/​rules/​hec-hms/​version-support.md - HMS 3.x vs 4.x differences

When to Use This Skill

Trigger Scenarios:

  • User says "run HMS simulation"
  • User says "execute this model"
  • User says "compute all runs in parallel"
  • User mentions "Jython script"
  • Working with HMS 3.x (requires Python 2 compatibility)
  • Need to execute batch simulations
  • Setting up automated workflows

Core Capabilities

1. Single Run Execution

Pattern: Initialize → Compute → Verify

See reference/​compute_run.md for complete API details.

Key Decision: When to use compute_run() vs compute_test_mode()

  • Use compute_run() for actual simulation
  • Use compute_test_mode() to validate setup without running

2. Parallel Execution

Pattern: Batch runs across multiple workers

See reference/​parallel.md for parallel execution strategies.

Key Decision: How many workers?

  • Default: 2 workers (safe for most systems)
  • CPU-bound: Use os.cpu_count() - 1
  • Memory-constrained: Use 1 worker (sequential)
  • Large models: Consider memory per run × workers

3. Jython Script Generation

Pattern: Generate version-appropriate script → Execute via HMS

See reference/​jython.md for script generation details.

Critical Decision: HMS 3.x vs 4.x

  • HMS 3.x: MUST use python2_compatible=True
  • HMS 4.x: Use default (Python 3 syntax)
  • Auto-detection: Check install path contains "(x86)" = 3.x

HMS Version Awareness

This skill handles BOTH HMS 3.x and 4.x:

AspectHMS 3.xHMS 4.x
Architecture32-bit64-bit
Python SyntaxPython 2 (print "x")Python 3 (print("x"))
Script Flagpython2_compatible=TrueDefault
Max Memory~1.3 GB32+ GB
Install PathProgram Files (x86)Program Files

See: .claude/​rules/​hec-hms/​version-support.md for complete differences

Common Workflows

Workflow 1: Basic Execution

from hms_commander import init_hms_project, HmsCmdr

init_hms_project(r"C:\Projects\watershed")
HmsCmdr.compute_run("Run 1")

See: examples/​basic-run.md for complete walkthrough

Workflow 2: Batch Execution (Sequential)

runs = ["Baseline", "Alternative_1", "Alternative_2"]
HmsCmdr.compute_batch(runs)

See: examples/​batch-runs.md for batch strategies

Workflow 3: Parallel Execution

runs = ["Run_1", "Run_2", "Run_3", "Run_4"]
HmsCmdr.compute_parallel(runs, max_workers=2)

See: reference/​parallel.md for worker allocation

Workflow 4: Legacy HMS 3.x Project

from hms_commander import HmsJython

# Generate Python 2 compatible script
script = HmsJython.generate_compute_script(
    project_path=r"C:\Projects\old_project",
    run_name="Run 1",
    python2_compatible=True  # CRITICAL for HMS 3.x!
)

# Execute with HMS 3.x
success, stdout, stderr = HmsJython.execute_script(
    script_content=script,
    hms_exe_path=r"C:\Program Files (x86)\HEC\HEC-HMS\3.5"
)

See: .claude/​rules/​hec-hms/​version-support.md for legacy workflows

Troubleshooting

Common Issues:

  1. HMS Not Found: See reference/​jython.md#finding-hms
  2. Memory Errors: See reference/​jython.md#memory-allocation
  3. Python 2 Syntax Errors: See .claude/​rules/​hec-hms/​version-support.md
  4. Parallel Execution Hangs: See reference/​parallel.md#debugging

Integration Points

Before Execution:

  • Use HmsBasin to modify parameters (see parsing-basin-models skill)
  • Use HmsMet to update precipitation (see updating-met-models skill)
  • Use HmsControl to set time window (see .claude/​rules/​hec-hms/​control-files.md)

After Execution:

  • Use HmsDss to extract results (see extracting-dss-results skill)
  • Use HmsResults for analysis (see .claude/​rules/​hec-hms/​dss-operations.md)

Reference Files

Detailed API Documentation (load on-demand):

  • reference/​compute_run.md - HmsCmdr.compute_run() complete API
  • reference/​parallel.md - Parallel execution strategies
  • reference/​jython.md - Script generation and execution
  • reference/​troubleshooting.md - Common issues and solutions

Complete Examples (working code):

  • examples/​basic-run.md - Simple single run
  • examples/​batch-runs.md - Sequential batch execution
  • examples/​parallel-runs.md - Parallel execution with worker allocation
  • examples/​legacy-3x.md - HMS 3.x compatibility

Testing This Skill

Use real HMS projects for testing:

from hms_commander import HmsExamples

# Extract example project
HmsExamples.extract_project("tifton")

# Test execution
init_hms_project("tifton/​tifton")
HmsCmdr.compute_run("1970_simulation")

See: .claude/​rules/​testing/​tdd-approach.md for testing philosophy

Key Patterns (Not in Primary Sources)

Pattern 1: Destination Folder Management

HMS creates output in the project folder. For organized results:

# Results go to project_folder/​results/​RUN_<run_name>.results
# DSS file location specified in .run file

Decision: HMS writes to project folder, not a separate destination folder like RAS.

Pattern 2: Version Auto-Detection

from pathlib import Path

hms_path = Path(r"C:\Program Files (x86)\HEC\HEC-HMS\3.5")
is_3x = "(x86)" in str(hms_path)  # 32-bit = HMS 3.x
python2_compatible = is_3x

Decision: Use install path pattern for version detection, not HMS version file.

Pattern 3: Error Handling

try:
    HmsCmdr.compute_run("Run 1")
except Exception as e:
    # Check HMS log file for details
    log_file = hms.project_folder / f"RUN_Run 1.log"
    if log_file.exists():
        print(log_file.read_text())
    raise

Decision: HMS errors appear in log files, check those for diagnostics.

Related Skills

  • parsing-basin-models - Modify parameters before execution
  • updating-met-models - Update precipitation before execution
  • extracting-dss-results - Process outputs after execution
  • cloning-hms-components - Create QAQC comparison runs
  • managing-hms-versions - Multi-version testing workflows

Navigation: This skill points to primary sources. For complete API details, read the code docstrings in hms_commander/​HmsCmdr.py and hms_commander/​HmsJython.py.

More skills from mattnigh

spring-framework-patterns logo
mattnigh/skills_collection

spring-framework-patterns

Comprehensive Spring Framework and Spring Boot best practices including dependency injection patterns, bean lifecycle and scopes, REST API development, Spring Data JPA, service layer design, Spring Security, testing strategies, caching, AOP, async processing, error handling, and common anti-patte...

24 0
View

TypeScript厳格モードによる型安全性設計を専門とするスキル。 📖 参照書籍: - 『Effective TypeScript』(Dan Vanderkam): 型設計 📚 リソース参照: - `resources/Level1_basics.md`: レベル1の基礎ガイド - `resources/Level2_intermediate.md`: レベル2の実務ガイド - `resources/Level3_advanced.md`: レベル3の応用ガイド - `resources/Level4_expert.md`: レベル4の専門ガイド - `resources/di...

24 0
View
deploying-cloud-k8s logo
mattnigh/skills_collection

deploying-cloud-k8s

Deploys applications to cloud Kubernetes (AKS/GKE/DOKS) with CI/CD pipelines. Use when deploying to production, setting up GitHub Actions, troubleshooting deployments. Covers build-time vs runtime vars, architecture matching, and battle-tested debugging.

24 0
View
moai-alfred-agent-guide logo
mattnigh/skills_collection

moai-alfred-agent-guide

19-agent team structure, decision trees for agent selection, Haiku vs Sonnet model selection, and agent collaboration principles. Use when deciding which sub-agent to invoke, understanding team responsibilities, or learning multi-agent orchestration.

24 0
View
mermaid-diagram-generator logo
mattnigh/skills_collection

mermaid-diagram-generator

Converts architecture descriptions, module specs, or workflow docs into Mermaid diagrams. Use when visualizing brick module relationships, workflows (DDD, investigation), or system architecture. Supports: flowcharts, sequence diagrams, class diagrams, state machines, entity relationship diagrams,...

24 0
View
pre-flight-check logo
mattnigh/skills_collection

pre-flight-check

INVOKE FIRST before any code work. Validates git workflow (branch, issue, worklog) and checks approach. Use at START of every task and END before completing. Prevents skipped steps.

24 0
View
browser-dev-tools logo
mattnigh/skills_collection

browser-dev-tools

This skill should be used when working with browser-rendered artifacts (i.e. Bun, React/React Native) to proactively validate that development work on localhost is being built appropriately and to support debugging browser-rendered content. Use this skill after making frontend changes to verify t...

24 0
View
lead-dev logo
mattnigh/skills_collection

lead-dev

Lead Développeur - Coordination technique opérationnelle, code review, mentoring et livraison. Pair de web-dev-process au niveau OPÉRATIONS.

24 0
View
worker-monitor logo
mattnigh/skills_collection

worker-monitor

Monitor Docker workers, RQ queue health, and auto-scale workers (max 4). Use when: checking job progress, monitoring queue depth, scaling workers up/down, diagnosing slow processing, or waiting for jobs to complete. Referenced by data-quality skill during reprocessing.

24 0
View
quality-advisor logo
mattnigh/skills_collection

quality-advisor

Proactive quality guidance system that monitors artifact creation and provides real-time feedback on documentation quality

24 0
View
bump-version logo
mattnigh/skills_collection

bump-version

This skill should be used when the user wants to bump the version number in the workspace. It updates versions across all pyproject.toml files (root, tde, and tda packages) and the CHANGELOG.md to keep them synchronized.

24 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View