-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only allow a single target_keys key value pair #90
Conversation
"target_id": "wk ahead inc flu hosp", | ||
"target_name": "weekly influenza hospitalization incidence", | ||
"target_units": "rate per 100,000 population", | ||
"target_keys": null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
section relevant to test
"target_keys": { | ||
"target": "wk flu hosp", | ||
"target_metric": "rate change" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
section relevant to tests
R/create_target_metadata_item.R
Outdated
#' @param target_keys named list or `NULL`. The `target_keys` value defines a | ||
#' single target. | ||
#' Should be `NULL`, in the case where the target is not specified as a task_id | ||
#' but is specified solely through the `target_id` argument. | ||
#' Otherwise, should be a named list containing a single character string element. | ||
#' The name of the element should match a `task_id` | ||
#' variable name within the same `model_tasks` object and the value should match | ||
#' a single value of that variable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although in the code I only apply the restriction to configs with version v4.0.1 and greater, I've gone ahead an just updated the docs with what's allowed going forward. Otherwise I think the docs would be too complex and prehaps confusing when I don't belivee anyone was using the feature anyways.
R/create_target_metadata_item.R
Outdated
is_gte_v4_0_1 <- hubUtils::version_gte( | ||
"v4.0.1", | ||
schema_version = schema_version | ||
) | ||
target_key_n <- length(target_keys) | ||
if (is_gte_v4_0_1 && target_key_n > 1L) { | ||
cli::cli_abort( | ||
c( | ||
"!" = "{.arg target_keys} must be a named {.cls list} of | ||
length {.val {1L}} not {.val {target_key_n}}." | ||
), | ||
call = call | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I restricted this to the relevant versions to ensure it matches what's actually described in earlier schema
…o the default value anyways.
A weird bug just popped up and I don't know where it's coming from, but effectively, when a value with a class of "error" is passed to `encodeString()`, it fails with: Error in UseMethod("conditionMessage") : no applicable method for 'conditionMessage' applied to an object of class "error" This never used to happen, so I'm fixing it here.
@@ -6,7 +6,7 @@ test_that("Missing files returns an invalid config with an immediate message", { | |||
"File does not exist" | |||
) | |||
}) | |||
expect_false(out) | |||
expect_false(unclass(out)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes new errors from changes in testthat. Cherry picked from 8e8ed51
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these changes look good to me. I'm commenting rather than approving for the same reasons outlined in this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks cromulent to me! Approving pending the bump to major version discussed in hubverse-org/schemas#118 (comment)
Co-authored-by: Zhian N. Kamvar <[email protected]>
Co-authored-by: Zhian N. Kamvar <[email protected]>
upgrade schema version to v5.0.0
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #90 +/- ##
==========================================
+ Coverage 89.25% 89.30% +0.05%
==========================================
Files 30 30
Lines 2420 2432 +12
==========================================
+ Hits 2160 2172 +12
Misses 260 260 ☔ View full report in Codecov by Sentry. |
This PR resolves #89 and is related to hubverse-org/schemas#118
Specifically In v4.0.1, we are only allowing a single
target_keys
key value pair.To ensure
hubAdmin
functionality conform to this pattern this PR:target_keys
key value pair when validating task.json files withvalidate_config()
target_keys
with more that 1 key value pair programmatically for configs using schema versions v4.0.1 and abovehubAdmin.branch
option specification. This didn't affect tests though as it was setting it to the default value anyways.Note: unrelated test failures still exist and will need resolving before mergingFound solution @zkamvar had applied in #86 (8e8ed51) and cherry picked into here!