Skip to content

Commit f360dc3

Browse files
Add cli to downscaling (#18)
* first pass pre-test * Add magic-downscaling CLI: prepare/cluster/extract/downscale/analyze verbs - tested on pecan env ver 1.10 * re-org of verbs, split of demo data obtain, and correction so that prepare can be run ahead of other verbs. * update to run_script and check_r_libraries to correctly determine exit status to identify step failure/success. * fixes to sourcing of helper functions, previously covered by sourcing config, now covered by sourcing specific files. * - actually added intended code to wire CLI together - correctly reads steps from workflow manifest via get_steps_array - handles input scalar parameters and path parameters via resolve_param and resolve_path respectively -- inputs and outputs are paths -- params are scalars - dynamically builds command arguments from specified inputs,outputs, and params - command-line parameter names are the keys (e.g., raw_data_dir --> '--raw_data_dir') - the values in the manifest are passed as values to the specified key (raw_data_dir: 'data_raw') - demo workflow completes as normal - CI basics for demo workflow in place: needs repo config to actually work. * Fix PR review issues: config keys, r_libraries, CI, manifest validation - Move aws_profile from downscaling: to global: in example_user_config.yaml and .github/ci/downscaling_ci_config.yaml; fix magic-downscaling's stale help text to match the code, which already read global.aws_profile - Correct r_libraries across all 11 manifest steps (cluster/extract/ downscale/analyze) against actual script imports, including sourced R/ helpers: add missing hard deps (here, knitr, magick, units, withr, ClusterR, PEcAn.utils, future, lubridate, arrow, janitor, jsonlite, randomForest, iml, vroom, patchwork, scales, PEcAn.data.land), drop confirmed-unused ones (caladaptr from prepare_anchor_sites; sf, furrr from cluster_sites; sf from subsample_design_points) - Drop unused AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_DEFAULT_REGION env exports from the CI workflow; --profile magic already resolves credentials on the runner, so those secrets were dead weight - Fix check_r_libraries capturing stderr into the same variable as the package-availability check's stdout, which could misreport stray stderr (e.g. locale warnings) as a missing package; capture stderr separately so it's only surfaced on a genuine Rscript failure - Delete unused .Renviron.bak / .Rprofile.bak (nothing in the repo reads either file; leftover from the pre-conda renv setup) - Remove the dangling docs/manifest-driven-cli-design.md reference from downscaling_manifest.yaml (that doc is intentionally not tracked) - Drop the "placeholder name" parenthetical from the cluster verb's help text now that the name is settled - Make get_steps_array validate that every manifest step has both `script` and `name`, failing fast with the offending step's index/script instead of silently misaligning STEPS/STEP_NAMES (dispatch elsewhere is name-keyed via `select(.name == ...)`, so a missing name breaks that lookup silently otherwise) - Sweep scripts/*.R: replace the copy-pasted stop() calls for --run_dir/ --mode validation with PEcAn.logger::logger.severe(), matching house logging style - Fix get-demo-data help text to say demo-data/ lands relative to the invocation directory, not "the repo root" (matching actual INVOCATION_CWD-based behavior) * Resolve PR #18 review feedback: disconnect cluster verb, trim manifest cruft - Fixed: cluster verb removed from CLI, scripts left as non-CLI tools - Fixed: 031 (mixed-system aggregation) excluded from extract step - Fixed: dead placeholder path keys removed (prepare_dir, extract_dir, downscaled_csv, county_totals_csv, analyze_dir, aggregated_output_csv) - included data resources for github ci * add readme update * wired in the n_cores parameter is 030 and 040. used config to set n_cores, but falls back to environment variables from slurm as needed. * Apply suggestion from @dlebauer --------- Co-authored-by: David LeBauer <dlebauer@gmail.com>
1 parent 1d9a799 commit f360dc3

23 files changed

Lines changed: 12296 additions & 152 deletions

‎.Renviron‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎.Rprofile‎

Lines changed: 0 additions & 66 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# CI config for test-downscaling-demo.yml — same shape as example_user_config.yaml,
2+
# with an isolated run_dir so CI runs don't collide with local dev-run dirs.
3+
4+
global:
5+
run_dir: "ci-downscaling-rundir/"
6+
aws_profile: magic
7+
8+
downscaling:
9+
mode: demo
10+
pecan_output_dir: "demo-data/modelout/ccmmf_phase_3_scenarios_v2_n2o_ch4"
11+
data_layers_dir: "demo-data/data"
12+
anchor_site_locations: "data_raw/anchor_site_locations.csv"

‎.github/data/anchor_sites.csv‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
site_id,lat,lon,external_site_id,site_name,crops,pft
2+
26336,36.17114,-120.19718,US-ASH,San Joaquin Valley Almond High Salinity,Almond,woody perennial crop
3+
159849,36.94729,-120.10535,US-ASL,San Joaquin Valley Almond Low Salinity,Almond,woody perennial crop
4+
534243,36.1778,-120.20411,US-ASM,San Joaquin Valley Almond Medium Salinity,Almond,woody perennial crop
5+
169473,36.23738,-119.92755,US-PSH,San Joaquin Valley Pistachio High Salinity,Pistachio,woody perennial crop
6+
557284,36.82778,-120.13963,US-PSL,San Joaquin Valley Pistachio Low Salinity,Pistachio,woody perennial crop
7+
328163,38.09936,-121.50154,US-Bi1,Bouldin Island Alfalfa,Alfalfa,herbaceous crop
8+
565118,38.10958,-121.53613,US-Bi2,Bouldin Island Corn/Sorghum,"Corn, Sorghum",herbaceous crop
9+
522375,32.81281,-115.44207,US-Dea,UC Desert REC Alfalfa,Alfalfa,herbaceous crop
10+
205678,38.13153,-121.55174,US-DS1,Staten Corn 1,Corn,herbaceous crop
11+
592578,38.13799,-121.51401,US-DS2,Staten Corn 2,Corn,herbaceous crop
12+
413887,38.12346,-121.54982,US-DS3,Staten Rice 1,Rice,herbaceous crop
13+
590334,36.35733,-119.09283,US-Lin,Lindcove Orchard,Oranges,woody perennial crop
14+
440393,39.57712,-121.86221,US-RGB,Butte County Rice Farm,Rice,herbaceous crop
15+
420343,37.69949,-121.1391,US-RGF,Stanislaus Forage Farm,Forage crops,herbaceous crop
16+
132390,39.59614,-122.0226,US-RGG,Glenn County Rice Farm,Rice,herbaceous crop
17+
218534,38.1741,-121.50302,US-Si1,Staten Island Fallow,Fallow,non crop
18+
52519,38.17441,-121.51733,US-Si2,Staten Island Flooded,Rice,herbaceous crop
19+
248496,38.11573,-121.64507,US-Tw3,Twitchell Alfalfa,Alfalfa,herbaceous crop
20+
296871,38.54294,-121.87237,russell-ranch,Russell Ranch,"tomato, corn, wheat",herbaceous crop
21+
16073,38.50244,-121.97646,wolfskill,Wolfskill Experimental Orchards,Fruit and nut breeding,woody perennial crop
22+
415399,33.96684,-117.34049,ucr-citrus,UC Riverside Citrus Research,Citrus variety collection,woody perennial crop
23+
589918,36.62289,-121.54925,salinas_socs,USDA-ARS Salinas Organic Cropping Systems,"Romaine lettuce, broccoli",herbaceous crop
24+
514070,37.62903,-121.08781,modesto_almond_usda,USDA-ARS Modesto almond fertigation trial,Almond,woody perennial crop
25+
535358,39.68222,-122.0026,US-RGO,Glenn County Organic Rice,Organic rice,herbaceous crop
26+
589581,38.09222,-121.64036,US-Tw2,Twitchell Corn,Corn,herbaceous crop
27+
590073,38.10809,-121.65527,US-Twt,Twitchell Island Rice,Rice,herbaceous crop
28+
452888,36.34204,-120.1055,west-side,West Side Research Center,Row crops including cotton,herbaceous crop

0 commit comments

Comments
 (0)