Skip to content

Commit

Permalink
Test a delete-model-runs workflow where one run is valid and one isn't
Browse files Browse the repository at this point in the history
  • Loading branch information
jeancochrane committed Nov 17, 2023
1 parent 0e56190 commit cf4ff3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/delete-model-runs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ jobs:
run: Rscript ./R/delete_current_year_model_runs.R "$RUN_IDS"
shell: bash
env:
RUN_IDS: 2024-11-14-foo-bar,2024-11-15-baz
RUN_IDS: 2023-11-14-frosty-jacob,2024-11-15-baz
8 changes: 6 additions & 2 deletions R/delete_current_year_model_runs.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ year <- if (current_month < "03") {
# intended to be called from a dispatched GitHub workflow, it's easier to parse
# one comma-delimited string than split a space-separated string passed as a
# workflow input
run_ids <- commandArgs(trailingOnly = TRUE) %>%
raw_run_ids <- commandArgs(trailingOnly = TRUE)
run_ids <- raw_run_ids %>%
strsplit(split = ",", fixed = TRUE) %>%
unlist()

"Confirming artifacts exist for run IDs in year {year}: {run_ids}" %>%
"Confirming artifacts exist for run IDs in year {year}: {raw_run_ids}" %>%
glue::glue() %>%
print()

Expand All @@ -65,6 +66,9 @@ run_id_is_valid <- function(run_id, year) {
# before deleting any objects so that this script is nondestructive
# in the case of a malformed ID
valid_run_ids <- run_ids %>% sapply(run_id_is_valid, year = year)
"Valid run IDs: {paste(valid_run_ids, collapse = ', ')}" %>%
glue::glue() %>%
print()

if (!all(valid_run_ids)) {
invalid_run_ids <- run_ids[which(valid_run_ids == FALSE)] %>%
Expand Down

0 comments on commit cf4ff3c

Please sign in to comment.