Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
needs: changed
if: needs.changed.outputs.run == 'true'
runs-on: ubuntu-latest
timeout-minutes: 60
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
outputs:
tested: ${{ steps.data.outputs.ok }}
steps:
Expand All @@ -73,7 +74,10 @@ jobs:
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2
with:
save-if: false
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
# Restored and saved as separate steps: the combined action would save a set missing a file
# whose download failed, and an exact hit is never saved again.
- id: cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: workflow-data
key: workflow-data-census-2024-1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing -1 cache entry may still hold an incomplete set. The new restore/save split only stops new incomplete saves. The earlier combined actions/cache step saved whatever files were present when the job succeeded, and the data step succeeds even when ok=false. So a -1 entry from a run with a failed download can already exist. An exact hit then never triggers a save, and the missing file is downloaded on every run. This is the part of the earlier "rotate the existing key" thread that this PR does not address. Bumping the key to -2 in both places (here and in the "Keep the Census files" step at line 107) makes the first verified run repopulate the cache. Confidence: medium. I can't inspect the cache contents from here.

Suggested change
key: workflow-data-census-2024-1
key: workflow-data-census-2024-2

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No -1 entry exists to rotate. gh cache list --key workflow-data returns nothing, and every nightly run from 11-01 to 11-07 logs Cache not found for input keys: workflow-data-census-2024-1, downloads both files, and saves again. The entry is evicted between nights, so none can be left half-filled, and the key stays.

Expand All @@ -87,14 +91,20 @@ jobs:
while read -r sum url; do
file="${url##*/}"
if ! echo "$sum $file" | sha256sum -c --status 2>/dev/null; then
curl -sSfL --retry 3 -o "$file" "$url" || { echo "::warning::could not download $url"; ok=false; continue; }
curl -sSfL --retry 3 --retry-max-time 600 --connect-timeout 30 --max-time 300 -o "$file" "$url" || { echo "::warning::could not download $url"; ok=false; continue; }
echo "$sum $file" | sha256sum -c || { echo "::error::$file has changed: update its checksum and check the test"; exit 1; }
fi
done <<'LIST'
e635ccb4f3035f8fa19b76352a63c89b893f57d0b96ecd5b713754141184bd3d https://www2.census.gov/geo/tiger/TIGER2024/TRACT/tl_2024_47_tract.zip
38cdd818f50248f67fabf4baf4b82df4ed6110dcaafebcbe4d4f9a389bb47ab8 https://www2.census.gov/geo/docs/maps-data/data/gazetteer/2024_Gazetteer/2024_gaz_tracts_47.txt
LIST
echo "ok=$ok" >> "$GITHUB_OUTPUT"
- name: Keep the Census files
if: steps.data.outputs.ok == 'true' && steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: workflow-data
key: workflow-data-census-2024-1
- name: Run the workflow tests on them
if: steps.data.outputs.ok == 'true'
env:
Expand All @@ -104,8 +114,9 @@ jobs:
report:
name: Report
needs: [changed, rust, workflows]
# A cancelled run is neither a failure nor a fix.
if: always() && github.event_name == 'schedule' && needs.changed.outputs.run == 'true' && needs.rust.result != 'cancelled' && needs.workflows.result != 'cancelled'
# A cancelled run is neither a failure nor a fix. A job that ran out of time ends cancelled too,
# but the run isn't: that is a failure.
if: ${{ !cancelled() && github.event_name == 'schedule' && needs.changed.outputs.run == 'true' }}
runs-on: ubuntu-latest
permissions:
issues: write
Expand Down
29 changes: 20 additions & 9 deletions crates/engine/tests/workflows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,9 @@ fn parcel_id(col: usize, row: usize) -> String {

/// The parcels and zoning layers, and an assessment table to join to the parcels.
///
/// The table keys parcels by the same text ids. It has no row for the last parcel, and has a row
/// for "101": the first parcel's id read as a number, which must not match it.
/// The table keys parcels by the same text ids. It has no rows for "00103", which straddles the
/// zones' boundary, or for the last parcel, and has a row for "101": the first parcel's id read as
/// a number, which must not match it.
fn job_data() -> (String, String, String) {
let mut parcels = Vec::new();
for row in 0..3 {
Expand All @@ -396,7 +397,7 @@ fn job_data() -> (String, String, String) {
json!({"type": "Feature", "properties": {"zone": "C2"}, "geometry": rect(SPLIT, SOUTH, WEST + 4.0 * STEP, SOUTH + 2.0 * STEP)}),
];
let mut csv = String::from("parcel_id,value_usd\n");
for k in 0..11 {
for k in (0..12).filter(|&k| !unassessed(k)) {
csv += &format!("{},{}\n", parcel_id(k % 4, k / 4), 100_000 + k * 1_000);
}
csv += "101,999999\n";
Expand Down Expand Up @@ -480,10 +481,16 @@ fn check_totals(stats: &Dataset) {
}
}

/// The value the assessment table gives a parcel: none for the last, which has no row.
/// Whether the assessment table has no row for the parcel numbered `k` from 0: "00103", split
/// into two pieces by the overlay, and the last, which is in no zone.
fn unassessed(k: usize) -> bool {
k == 2 || k == 11
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

/// The value the assessment table gives a parcel: none for those with no row.
fn assessment(parcel: &str) -> Field {
let k = parcel.parse::<i64>().unwrap_or_else(|_| panic!("{parcel}")) - 101;
if k < 11 { Field::Int(100_000 + k * 1_000) } else { Field::Null }
let k = parcel.parse::<usize>().unwrap_or_else(|_| panic!("{parcel}")) - 101;
if unassessed(k) { Field::Null } else { Field::Int(100_000 + k as i64 * 1_000) }
}

/// Checks that every feature carries its parcel's assessed value; the number checked.
Expand All @@ -509,13 +516,17 @@ fn join_overlay_summarise_map_save_reopen_and_share() {
s.run("gp.run", step).unwrap_or_else(|e| panic!("{}: {e}", step["tool"]));
}

// The join matched every parcel by its text id; "101" matched none, and the parcel with no
// assessment kept its row with no value.
// The join matched every parcel by its text id; "101" matched none, and the parcels with no
// assessment kept their rows with no value.
assert_eq!(check_values(layer(&s, "assessed")), 12);
check_totals(table(&s, "zoned_Statistics"));
let zoned = layer(&s, "zoned").clone();
// Every piece keeps its parcel's value through the overlay.
// Every piece keeps its parcel's value through the overlay, "00103"'s two pieces none.
assert_eq!(check_values(&zoned), 13);
let (id, value) = (zoned.field_index("parcel_id").unwrap(), zoned.field_index("value_usd").unwrap());
let split = (0..zoned.features.len()).filter(|&r| zoned.value(r, id).to_string() == "00103").collect::<Vec<_>>();
assert_eq!(split.len(), 2, "the overlay splits 00103");
assert!(split.iter().all(|&r| zoned.value(r, value) == &Field::Null), "00103 has no assessment");

let png = dir.path("map.png");
s.run("share.exportMap", &json!({"path": png, "width": 320, "height": 200})).unwrap();
Expand Down
Loading