project¶
project
¶
Project scaffolding: init command, project root detection, and template generation.
Provide the hydro-param init functionality that creates a standard project
directory structure with categorical data subfolders, template pipeline and
pywatershed configurations, and a .gitignore. A hidden .hydro-param
marker file at the project root enables upward directory discovery so that
commands run from subdirectories can locate the project root automatically.
The scaffolding is intentionally lightweight -- hydro-param uses library-managed transparent caching (pooch-style), not a heavyweight project directory contract. The templates exist to give users a working starting point, not to enforce a rigid layout.
See Also
hydro_param.cli : CLI commands that invoke :func:init_project.
hydro_param.config : Pipeline config schema that the generated template follows.
MARKER_FILE
module-attribute
¶
str : Hidden file name placed at the project root by hydro-param init.
DEFAULT_CATEGORIES
module-attribute
¶
DEFAULT_CATEGORIES: list[str] = [
"climate",
"geology",
"hydrography",
"land_cover",
"snow",
"soils",
"topography",
"water_bodies",
]
list[str] : Built-in dataset categories used when the registry is unavailable.
These names correspond to the per-category YAML files in hydro_param.data.datasets
and become subdirectory names under data/ in an initialized project.
find_project_root
¶
Walk up from start looking for a .hydro-param marker file.
Traverse parent directories from start toward the filesystem root,
returning the first directory that contains the marker file. This
allows CLI commands invoked from any subdirectory to locate the
project root without requiring an explicit --project-dir flag.
| PARAMETER | DESCRIPTION |
|---|---|
start
|
Directory to begin searching from. Defaults to the current
working directory (
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path or None
|
The resolved project root directory, or |
Notes
The search terminates when parent == current, which is the
filesystem root on both POSIX and Windows systems.
Source code in src/hydro_param/project.py
get_data_categories
¶
Discover dataset categories from the registry, with built-in fallback.
Attempt to load the dataset registry and extract the union of all
category values. If the registry cannot be loaded (missing path,
parse error, etc.), fall back to :data:DEFAULT_CATEGORIES so that
project scaffolding always succeeds.
| PARAMETER | DESCRIPTION |
|---|---|
registry_path
|
Path to a registry YAML file or directory of YAML files. When
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Sorted, deduplicated list of category names. Always includes at
least the :data: |
Source code in src/hydro_param/project.py
generate_pipeline_template
¶
Generate a well-commented pipeline YAML config template.
Produce a starter pipeline.yml with inline comments explaining
each section (target fabric, domain, datasets, output, processing).
The template includes all 7 tested dataset configurations covering
all 5 data access strategies (stac_cog, local_tiff, nhgf_stac
static, nhgf_stac temporal, climr_cat).
| PARAMETER | DESCRIPTION |
|---|---|
project_name
|
Project name inserted into the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
YAML content suitable for writing to |
See Also
hydro_param.config.PipelineConfig : Schema the generated YAML must conform to.
Source code in src/hydro_param/project.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
generate_pywatershed_template
¶
Generate a well-commented pywatershed run config template (v4.0).
Produce a starter pywatershed_run.yml for Phase 2 parameterization.
This config consumes existing SIR output produced by hydro-param run
and derives pywatershed-specific parameters. The v4.0 format includes
three data sections (static_datasets, forcing, climate_normals)
that declare the pipeline-to-parameter data contract.
| PARAMETER | DESCRIPTION |
|---|---|
project_name
|
Project name inserted into the output path and header comment.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
YAML content suitable for writing to |
References
docs/reference/pywatershed_parameterization_guide.mddocs/reference/pywatershed_dataset_param_map.yml
See Also
hydro_param.pywatershed_config : Schema for pywatershed run configs.
Source code in src/hydro_param/project.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
generate_gitignore
¶
Generate .gitignore content for a hydro-param project.
The ignore rules track lightweight config files and the marker, while
ignoring downloaded raster/vector data, pipeline output, and model
exports. Large geospatial formats (*.nc, *.tif, *.zarr/)
are caught by a safety-net section.
| RETURNS | DESCRIPTION |
|---|---|
str
|
Content suitable for writing to |
Source code in src/hydro_param/project.py
init_project
¶
init_project(
project_dir: Path,
*,
force: bool = False,
registry_path: Path | None = None,
) -> None
Scaffold a hydro-param project directory.
Create the standard directory structure expected by the pipeline:
configs/-- pipeline and pywatershed run config templatesdata/fabrics/-- target polygon filesdata/<category>/-- one subdirectory per dataset categoryoutput/-- pipeline resultsmodels/pywatershed/-- pywatershed model exports.hydro-param-- marker file for project root discovery.gitignore-- rules to keep large data out of version control
Existing config templates (pipeline.yml, pywatershed_run.yml)
are never overwritten, even with force=True, so user edits are
preserved. The .gitignore is always regenerated because it is
declarative and safe to replace.
| PARAMETER | DESCRIPTION |
|---|---|
project_dir
|
Root directory for the new project. Created if it does not exist.
TYPE:
|
force
|
If
TYPE:
|
registry_path
|
Optional path to a dataset registry YAML file or directory for
category discovery. When
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
SystemExit
|
If the directory already contains a |
Notes
The marker file (.hydro-param) is a YAML file containing the
project name and UTC creation timestamp. It is used by
:func:find_project_root for upward directory discovery.
Source code in src/hydro_param/project.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | |