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...

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 majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
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