Skip to content

Build data releases with a targets pipeline; ship cna-v7.70-3arcmin - #39

Open
achubaty wants to merge 66 commits into
developmentfrom
feat/climatena-docker
Open

achubaty wants to merge 66 commits into
developmentfrom
feat/climatena-docker

Conversation

@achubaty

@achubaty achubaty commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Replaces the manual data-raw/03-*.R workflow with a targets pipeline (data-raw/pipeline/) that runs ClimateNA in the Docker image from #38. It also ships the pipeline's first data release, cna-v7.70-3arcmin: every 3 arcmin archive rebuilt with ClimateNA v7.70.

For package users

  • The tile index now points at cna-v7.70-3arcmin. Historical years run to 2025, and radiation (rsds*) has values for every year and scenario.
  • Future normals can be requested (future_<VAR>_normal with future_period).
  • climateDataRelease() names the data release behind the installed index. Code that caches prepClimateLayers() results should add its release_id to the cache key.
  • prepClimateLayers() now downloads into <srcdir>/<release_id>/. The new archives keep the old file names, and in a srcdir that already held them, the download was skipped and the old data were used (checked). Older folders can be deleted.
  • Index lookups, climateDataRelease() included, open the index read-only (Read the tile index read-only; set busy_timeout before other pragmas #41). The shipped index is no longer in WAL mode, so they also work from a library folder the user can't write to, and leave no -wal/-shm files there. Version 2.2.3.9012: development took 2.2.3.9011 for Read the tile index read-only; set busy_timeout before other pragmas #41.
  • Cells outside Canada with no DEM elevation are NA in every archive, normals included (Mask tiles 6 and 7's invalid cells for annual-only requests and normals #40). ClimateNA had written values there, computed at too low an elevation (US cells next to the border were a median 4.5 °C too warm in tile 6). Canadian coast and lakeshore cells without a DEM value keep their values. This replaces the read-time check on all-zero monthly PPT (maskInvalidPPT(), removed), which caught only tiles 6 and 7's zero-precipitation cells.
  • Archives are also published as seasonal (S) subsets, and seasonal variables requested alone now come from them rather than from the all-variables (MSY) archive.
  • Land cells where ClimateNA writes no values now hold ClimateNA's values for the nearest land cell it covers within 50 km, run at the empty cell's own elevation. Most are coastal cells its future data miss (all of tile 63's land, on Baffin Island's coast); a few had no values at all. 560 of 608 cells are filled, from a median of 3.5 km away (90% within 10 km); the 48 with no covered land within 50 km stay empty. filledCells() lists them all, as points.
  • Tile 53 is gone from the 3 arcmin release. Its 3 arcmin DEM was a copy of the 1 arcmin tile, and at 3 arcmin no cell centre is in Canada. Its old Drive files stay, but the index no longer lists them.

For maintainers

  • One branch per tile and decade, per type (historical, future, and both normals). Batches run in Docker on crew workers and write to node-local disk; each year's output is stored as one zip with a stamp (ClimateNA version, DEM hash, image).
  • Zips are rebuilt byte-identically, uploaded as new Drive files under the release's folder, and reuse an earlier release's file when it is identical. With replace_changed = TRUE in _local.R, a zip that changes replaces its file in place, so its Drive ID stays the same; without it, the upload stops and names the zip. The index is built fresh, with archives and release tables, and a report lists errors and missing uploads.
  • When the zips are cut, cells with no DEM elevation whose centre is outside Canada (GADM 4.1) are set to NODATA. The stored raw outputs are unchanged, and a masked file keeps its modification time, so masked zips also rebuild byte-identically.
  • After the mask, empty land cells are filled: fill_points finds them and the nearest covered land cell for each (within fill_max_km in release.yml, checked with a ClimateNA point run), each batch's fills stores point-mode values per period beside the raw outputs, and zip_batch() writes them in. A land cell still empty is a warning in the report. The index gets a filled_cells table.
  • The tile list, DEM files and tile masks are re-read on every run, so adding or removing a DEM tile takes effect; a failure in them stops the run instead of failing every branch.
  • The pipeline uses at most half of each node's cores: _local.R gives a worker count (no longer a crew controller), and the pipeline lowers it if needed.
  • Adding a GCM, SSP or year reruns only the new branches (plus the batch lists and the index).
  • The old 03-*.R and 06-archive_fingerprints.R scripts now stop at the top. They ended by copying their working index over the shipped one.
  • 04-audit_archives.R can audit a pipeline release.
  • New maintainer vignette, and a pkgdown site built by the org workflow (it deploys on push to main; Pages is enabled after the first deploy).

Release run (cna-v7.70-3arcmin)

  • One compute node, 90 workers: 18.5 h to build 6,560 batches, then 4.6 h to upload 24,518 zips (190 GB on Drive; the raw outputs take 90 GB on the share).
  • The Mask tiles 6 and 7's invalid cells for annual-only requests and normals #40 mask: recutting all 24,518 zips took 4 h on 60 workers. The 19,541 that changed (all in the 67 masked tiles) replaced their Drive files in place in about 3 h 20 min, and the index was rebuilt in 1 h. Every zip keeps its Drive ID; the release is now 162 GB on Drive.
  • The fill: point runs and a recut of all zips took 11 h 47 min on 60 workers. The 12,047 zips that changed (all in the 41 tiles with filled cells) replaced their Drive files in place in about 5 h, index included (one upload hit a Google server error and was rerun). Every zip keeps its Drive ID; the index now lists 24,219 zips (tile 53 dropped).
  • Release audit after the fill: all 24,219 zips complete, 150.3 GiB. Every local zip has the same MD5 as its Drive copy.

Checks

Follow-ups (not in this PR)

  • canClimateData#29: require climateData >= 2.2.3.9012, add climateDataRelease()$release_id to its cache key, and change the default years to 1991:2025.
  • The 1 arcmin release (being rebuilt with the mask and the fill; its upload waits for the new storage).

🤖 Generated with Claude Code

achubaty and others added 30 commits November 4, 2026 09:41
Separates the formatter's whitespace changes from the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Data releases from v3.0.0 publish S archives and 2025; the index tables
also record the ClimateNA version per year or period.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each batch spec is identified by its content alone, so adding years,
GCMs or SSPs leaves existing batches unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A period is skipped only if its folder is complete and its stamp shows
an accepted ClimateNA version and the same DEM.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Compares a new release's sample outputs with stored ones; last-digit
rounding (as under Wine) counts as compatible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ClimateNA is mounted read-only, and each run is capped at one CPU and
1 GB, as the pipeline's batches will run it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Separates the formatter's whitespace changes from the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Several scenarios share a tile folder, so each is selected by its exact
folder name and mosaicked to its own file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
canClimateData caches prepClimateLayers() results; adding this to its
cache key stops a new data release being served from an old cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For users of the package and of the canClimateData module; part of the
documentation asked for in #8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thin caller of PredictiveEcology/actions' pkgdown workflow, deployed to
GitHub Pages; reference index grouped by task.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Settings are single-value targets and types are mapped separately, so
editing the release rebuilds only branches whose inputs changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each period is checked and stamped; a failed or incomplete period
errors its batch so the next run retries just that period.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each zip goes to a per-release Drive folder (reused when an identical file
is already there); the index records every zip with its ClimateNA version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A deleted or damaged output folder was never rerun: targets tracked only
the manifest. Manifests now carry stamp times, so reruns recut the zips.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Under error = "null" a failed batch passed NULL on, and its zips were cut
from a killed run's truncated files, which the name-only check accepts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A changed verdict let every batch run; and the check ignored min_version,
so raising it as asked failed the check again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unchanged decades would otherwise be uploaded again with every release
(about 1.1 TB per release at 1 arcmin). Records the real-upload checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unchanged zips now keep their MD5 when rebuilt or run from another
checkout, so the next release reuses them; uploads use 8 local workers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Writing straight to an NFS share stalled 90 concurrent runs in I/O wait;
outputs are now checked locally, copied, and checked again before stamping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per-batch previous-release rows cost the main process about 14 min per run,
and a new scenario's folders would have re-run every upload branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copying 265 small files per run to the NFS share saturated the server
(about 4 min per run); one zip per run also shrinks the raw tree ~25x.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also report missing future-normals scenarios as index gaps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every 3 arcmin archive rebuilt with ClimateNA v7.70 and uploaded as new Drive files;
the release audit found all 24,518 zips complete. The archives test now covers future normals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in 048b6cc (googledrive and httr2 to Imports) before review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New zips keep old names, so reproducible reused old files in srcdir; downloads now go
to <srcdir>/<release_id>/. S folders lack PPT01-12, so seasonal-only requests skipped the
tile 6/7 PPT mask; they read MSY again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Requests future_MAT_normal for two periods and checks they differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each ended by copying its working index over the shipped release index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
achubaty and others added 28 commits November 9, 2026 16:58
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A read-only lookup of a missing table errored with its connection open, which

warned "call dbDisconnect()" at garbage collection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ClimateNA writes values where the DEM has no elevation, at the wrong
elevation; these are the cells to blank when cutting zips (#40).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the masked values' text changes. Cells are counted in value order,
since ClimateNA wraps some rows across lines and pads with extra spaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A rebuilt zip used to go up as a second file with a new ID; now it
replaces the file in its release folder, so the index's gid stays valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New targets canada (GADM 4.1) and tile_masks; zip_batch() masks the
extracted copy, so raw outputs keep ClimateNA's values (#40).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The archives now have those cells blanked at build time, so the read-time
PPT check is redundant and S folders no longer need monthly PPT (#40).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_local.R gives a worker count; the pipeline lowers it so ClimateNA runs,
uploads and the main process use at most half of each node's cores.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Zips are byte-identical only when their files' times are, so every recut
of a masked tile changed its zips' MD5s and forced a re-upload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
upload_zips() calls .uploadAction(); on a fresh upload worker every
changed zip's upload failed with "could not find function".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A rebuilt zip that differs from its release folder's file now stops the
upload unless _local.R sets replace_changed = TRUE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It described the crew controller, one worker per core, and a pipeline
that never replaces Drive files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 19,541 zips the mask changed replaced their Drive files in place, so
gids are unchanged; only their MD5s and the upload times differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
.fillAsc() fills land cells ClimateNA left empty, sharing .maskAsc()'s
reader and splice; it never overwrites a value ClimateNA wrote.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A dem_files target (format "file") feeds tile_masks, so a replaced DEM
rebuilds its mask; masks also list each tile's land cells.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Candidates are land cells with values within a distance, nearest first;
a candidate whose point run gives no values is passed over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Point mode with the DEM's elevation text reproduces the raster run's
values exactly; the sh script is quoted for system2().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fill_points finds land cells empty in each class's reference period and
a checked source for each; fills_<type> stores a CSV per period.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zip_batch() writes each period's fill CSV into its grids after the #40
mask, and warns (without stopping) about land cells still empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A filled_cells table lists each filled land cell and its source; cells
left empty are listed with no source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lists the land cells filled from ClimateNA's point mode as sf points,
for a study area or tiles; documented in NEWS and both vignettes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A format "file" target returns its paths without names, so tile masks
and fill points lost their tile IDs; found by the fill devtest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moving a DEM file out of the folder left a stale tile list; dem_files,
tile_masks and fill_points now stop the run instead of every branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rebuilt after the fill upload: 12,047 zips replaced in place (same IDs),
tile 53 dropped, and a filled_cells table (608 cells, 48 left empty).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docs gave pre-run figures (5 km, at most 25 km, no cell left empty);
the 3 arcmin index has a median of 3.5 km and 48 of 608 cells left empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shQuote() quotes for cmd on Windows, so the test's sh-only unquoting
failed there; it now undoes the host's quoting and checks both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	NEWS.md
#	inst/extdata/ClimateNA_tiles.sqlite
#	tests/testthat/test-sqliteConcurrency.R
The pipeline's index (#39) has no rowid column; id is the tile tables' key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant