| name | hecras_compute_remote |
| shared_corpus | true |
| harness_scope | shared |
| source_owner | gpt-cmdr |
| security_review | internal |
| description | Distributed HEC-RAS execution across remote workers (PsExec, Docker, SSH, cloud).
Handles worker initialization, queue scheduling, and result aggregation. Use when
setting up remote execution, distributed computation, cloud workflows, scaling
HEC-RAS across machines, parallel processing on multiple computers, Windows remote
execution, container-based execution, session-based remote execution, PsExec
configuration, Docker worker setup, or multi-machine HEC-RAS workflows.
Triggers: remote execution, distributed execution, PsExec, Docker worker, SSH execution, cloud execution, parallel remote, multi-machine, session_id, remote worker, worker initialization, queue scheduling, network share, container execution.
|
Executing Remote Plans
Use compute_parallel_remote() to distribute HEC-RAS plans across multiple remote machines. Read the primary sources below for complete configuration requirements.
PRIMARY SOURCES (read these for complete details):
ras_commander/remote/AGENTS.md - Coding conventions, architecture
.claude/rules/hec-ras/remote.md - Machine setup (Group Policy, Registry, session_id)
examples/500_remote_execution_psexec.ipynb - Complete PsExec workflow
Quick Start
from ras_commander import init_ras_project, init_ras_worker, compute_parallel_remote
init_ras_project("/path/to/project", "7.0")
worker = init_ras_worker(
"psexec",
hostname="192.168.1.100",
share_path=r"\\192.168.1.100\RasRemote",
session_id=2,
cores_total=16,
cores_per_plan=4
)
results = compute_parallel_remote(
plan_numbers=["01", "02", "03"],
workers=[worker],
num_cores=4
)
for plan_num, result in results.items():
if result.success:
print(f"Plan {plan_num}: SUCCESS ({result.execution_time:.1f}s)")
print(f" HDF: {result.hdf_path}")
else:
print(f"Plan {plan_num}: FAILED - {result.error_message}")
CRITICAL: Session-Based Execution
HEC-RAS is a GUI application -- always use session-based execution:
worker = init_ras_worker(
"psexec",
hostname="192.168.1.100",
share_path=r"\\192.168.1.100\RasRemote",
session_id=2,
...
)
NEVER use system_account=True - HEC-RAS will hang without desktop session.
Determining Session ID
Query from controlling machine:
query session /server:192.168.1.100
Typical Values:
- Session 0: SYSTEM (services only, NO DESKTOP)
- Session 1: Sometimes system (varies by Windows version)
- Session 2: Typical interactive user (MOST COMMON)
- Session 3+: Additional RDP sessions
Read ras_commander/remote/AGENTS.md for critical implementation notes.
Worker Types
Local Worker
Parallel execution on local machine:
worker = init_ras_worker(
"local",
worker_folder="C:/RasRemote",
cores_total=8,
cores_per_plan=2
)
PsExec Worker
Windows remote via network share:
worker = init_ras_worker(
"psexec",
hostname="192.168.1.100",
share_path=r"\\192.168.1.100\RasRemote",
worker_folder=r"C:\RasRemote",
session_id=2,
cores_total=16,
cores_per_plan=4
)
Setup Requirements (see REMOTE_WORKER_SETUP_GUIDE.md):
- Network share created (
C:\RasRemote shared as \\hostname\RasRemote)
- Group Policy configuration (network access, local logon, batch job rights)
- Registry key:
LocalAccountTokenFilterPolicy=1
- Remote Registry service running
- User in Administrators group
Docker Worker
Container execution (local or remote):
worker = init_ras_worker(
"docker",
docker_image="hecras:6.6",
cores_total=8,
cores_per_plan=4,
preprocess_on_host=True
)
worker = init_ras_worker(
"docker",
docker_image="hecras:6.6",
docker_host="ssh://user@192.168.1.100",
ssh_key_path="~/.ssh/docker_worker",
share_path=r"\\192.168.1.100\DockerShare",
remote_staging_path=r"C:\DockerShare",
cores_total=8,
cores_per_plan=4
)
Docker Prerequisites:
- Docker Desktop installed (local) or Docker daemon on remote
- Python packages:
pip install docker paramiko
- HEC-RAS Docker image built (see
ras-commander-cloud repo)
- SSH key configured for remote execution
Distributed Execution
results = compute_parallel_remote(
plan_numbers=["01", "02", "03"],
workers=[worker1, worker2],
num_cores=4,
clear_geompre=False,
max_concurrent=None,
autoclean=True
)
Returns: Dict[str, ExecutionResult]
plan_number - Plan that was executed
worker_id - Worker that executed the plan
success - True if successful
hdf_path - Path to output HDF file
error_message - Error message if failed
execution_time - Execution time in seconds
Queue-Aware Scheduling
Workers execute in priority order (lower queue_priority first):
local = init_ras_worker("local", queue_priority=0, cores_total=8, cores_per_plan=2)
remote = init_ras_worker("psexec", hostname="...", queue_priority=1, ...)
cloud = init_ras_worker("docker", docker_host="...", queue_priority=2, ...)
results = compute_parallel_remote(
plan_numbers=["01", "02", "03", "04", "05", "06"],
workers=[local, remote, cloud]
)
Worker Slots: Workers with max_parallel_plans > 1 create multiple slots:
- Worker with
cores_total=16 and cores_per_plan=4 → 4 parallel slots
- Each slot can run one plan at a time
- Total slots = sum of all worker
max_parallel_plans
Mixed Worker Pools
Combine local, remote, and cloud workers:
local = init_ras_worker(
"local",
worker_folder="C:/RasRemote",
cores_total=8,
cores_per_plan=2,
queue_priority=0
)
remote = init_ras_worker(
"psexec",
hostname="192.168.1.100",
share_path=r"\\192.168.1.100\RasRemote",
session_id=2,
cores_total=16,
cores_per_plan=4,
queue_priority=1
)
docker = init_ras_worker(
"docker",
docker_image="hecras:6.6",
docker_host="ssh://user@192.168.1.200",
ssh_key_path="~/.ssh/docker",
cores_total=8,
cores_per_plan=4,
queue_priority=2
)
results = compute_parallel_remote(
plan_numbers=["01", "02", "03", "04", "05", "06", "07", "08"],
workers=[local, remote, docker]
)
Result Processing
results = compute_parallel_remote(plan_numbers=["01", "02"], workers=[worker])
for plan_num, result in results.items():
print(f"\nPlan {plan_num}:")
print(f" Worker: {result.worker_id}")
print(f" Success: {result.success}")
print(f" Time: {result.execution_time:.1f}s")
if result.success:
print(f" HDF: {result.hdf_path}")
from ras_commander import HdfResultsPlan
msgs = HdfResultsPlan.get_compute_messages(result.hdf_path)
if "completed successfully" in msgs.lower():
print(f" Status: Verified successful")
else:
print(f" Error: {result.error_message}")
Common Issues
PsExec Worker Hangs
Symptom: No error, HDF not created
Diagnosis:
query session /server:192.168.1.100
net localgroup Administrators
sc query RemoteRegistry
Fix: Ensure session_id=2 (or correct session) and all configuration requirements met.
See REMOTE_WORKER_SETUP_GUIDE.md for complete setup instructions.
Permission Denied
Symptom: "Access is denied"
Fix: Check:
- Registry key:
LocalAccountTokenFilterPolicy=1
- Group Policy settings (network access, local logon, batch job)
- Share permissions (Share + NTFS)
Network Path Not Found
Symptom: Cannot access \\hostname\share
Diagnosis:
dir \\192.168.1.100\RasRemote
Test-NetConnection -ComputerName 192.168.1.100 -Port 445
sc \\192.168.1.100 query RemoteRegistry
Docker Connection Failed
Symptom: Cannot connect to Docker daemon
Diagnosis:
docker ps
ssh user@192.168.1.100 "docker info"
Fix: Ensure Docker Desktop running (local) or SSH keys configured (remote)
Architecture Overview
Module Structure
Read ras_commander/remote/AGENTS.md for complete module structure and coding conventions.
ras_commander/remote/
├── __init__.py # Exports all public classes and functions
├── RasWorker.py # RasWorker base dataclass + init_ras_worker()
├── PsexecWorker.py # PsexecWorker (IMPLEMENTED)
├── LocalWorker.py # LocalWorker (IMPLEMENTED)
├── DockerWorker.py # DockerWorker (IMPLEMENTED, requires docker+paramiko)
├── SshWorker.py # SshWorker (stub, requires paramiko)
├── WinrmWorker.py # WinrmWorker (stub, requires pywinrm)
├── SlurmWorker.py # SlurmWorker (stub)
├── AwsEc2Worker.py # AwsEc2Worker (stub, requires boto3)
├── AzureFrWorker.py # AzureFrWorker (stub, requires azure-*)
├── Execution.py # compute_parallel_remote() + helpers
└── Utils.py # Shared utilities
Factory Pattern
worker = init_ras_worker(worker_type, **config)
Lazy Loading
Workers with optional dependencies use check_*_dependencies() for lazy loading:
- Docker:
pip install docker paramiko
- SSH:
pip install paramiko
- AWS:
pip install boto3
Read ras_commander/remote/AGENTS.md for the lazy loading pattern.
Cross-References
Rules (follow these):
.claude/rules/hec-ras/remote.md -- CRITICAL: session_id=2, Group Policy, Registry config
.claude/rules/hec-ras/execution.md -- General execution parameters
Agents (delegate when needed):
remote-executor -- Delegate for remote worker setup and management
Skills (related workflows):
hecras_plan_execution -- Upstream: mode selection (decides if remote is needed)
hecras_compute_plans -- Alternative: local execution
hecras_extract_results -- Downstream: extract results after remote execution
Primary sources:
ras_commander/remote/AGENTS.md -- Remote execution architecture
examples/500_remote_execution_psexec.ipynb -- PsExec remote execution