feat(wanda): Add 'params' field for env var validation and discovery#368
feat(wanda): Add 'params' field for env var validation and discovery#368andrew-anyscale wants to merge 1 commit intomainfrom
Conversation
|
Reviews in this chain: |
|
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
0337224 to
cd893e4
Compare
05c0ded to
839b086
Compare
cd893e4 to
aa77840
Compare
aa77840 to
c1be080
Compare
839b086 to
308598c
Compare
c1be080 to
982cc46
Compare
308598c to
e8c1f1b
Compare
982cc46 to
e1c5fed
Compare
e8c1f1b to
a8a6908
Compare
e1c5fed to
aa3f891
Compare
4d7b344 to
b838030
Compare
590a1f9 to
a0cda8c
Compare
a289e51 to
2327511
Compare
a0cda8c to
9130175
Compare
2327511 to
fdbd39e
Compare
7367abf to
0c9f945
Compare
fdbd39e to
86b1c2e
Compare
bbd0070 to
3a439d3
Compare
00b3ca3 to
1a7af24
Compare
3a439d3 to
44d91e7
Compare
b0597a4 to
c0d07ae
Compare
59be694 to
922cdab
Compare
e20bf2d to
7c9b96c
Compare
922cdab to
32e8cb9
Compare
7c9b96c to
cd5a547
Compare
5ca62ee to
56081dd
Compare
cd5a547 to
987fd29
Compare
56081dd to
c63731b
Compare
543dfc4 to
5a582a1
Compare
80ff2ea to
fafb9d9
Compare
35530d6 to
a384fdf
Compare
fafb9d9 to
b4efcec
Compare
Add `params` field to wanda spec for declaring allowed values of environment variables used in templated fields (name, froms). This enables: - Strict validation: reject builds where env var values don't match declared params - Dependency discovery: specs with params are indexed under all their expanded names (e.g., base$PY with params [3.10, 3.11] is indexed as both base3.10 and base3.11), enabling dependency resolution without requiring all env vars to be set Validation runs before variable expansion in buildDepGraph, so errors reference the original $VARNAME. Topic: wanda-params Relative: wanda-build-deps Signed-off-by: andrew <andrew@anyscale.com>
b4efcec to
5408717
Compare
Code Review 👍 Approved with suggestions 0 resolved / 3 findingsWell-designed feature with comprehensive test coverage. A few minor robustness improvements suggested around edge cases. Suggestions 💡 3 suggestionsEdge Case: extractVarNames parsing differs from test expectationsLooking at the test case This is correct behavior per the parsing logic (letters/underscores continue the variable name), but the test expectation reveals a potential usability concern: users might expect Edge Case: Potential exponential blowup in cartesian product generationThe For example, with 3 variables each having 10 values, this would generate 1000 combinations. While this is likely acceptable for typical use cases (2-3 Python versions, 2 architectures), there's no upper bound or warning for unusual configurations. Consider adding a safeguard or warning if the number of combinations exceeds a reasonable threshold (e.g., 100), to help users catch misconfiguration early: const maxCombinations = 100
if len(combinations) > maxCombinations {
return nil, fmt.Errorf("params generate %d combinations, exceeding limit of %d", len(combinations), maxCombinations)
}Code Quality: Map iteration order in ValidateParams is non-deterministic📄 wanda/spec.go:211 📄 wanda/spec.go:156 In While this doesn't affect correctness (any validation failure is still a failure), it could make debugging harder since users might see different error messages for the same configuration. Consider collecting all validation errors or sorting the keys before iteration: func (s *Spec) ValidateParams(lookup lookupFunc) error {
var errs []string
for varName, allowed := range s.Params {
val, ok := lookup(varName)
if !ok {
continue
}
valid := false
for _, a := range allowed {
if val == a {
valid = true
break
}
}
if !valid {
errs = append(errs, fmt.Sprintf("%s=%q (allowed: %v)", varName, val, allowed))
}
}
if len(errs) > 0 {
sort.Strings(errs)
return fmt.Errorf("invalid param values: %s", strings.Join(errs, ", "))
}
return nil
}What Works WellClean implementation of the params feature with clear separation between validation and expansion. Thorough test coverage including edge cases like cartesian products, deduplication, and env var fallback. Excellent error messages that include valid values to guide users. OptionsAuto-apply is off Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | This comment will update automatically (Docs) |
aslonnie
left a comment
There was a problem hiding this comment.
maybe chat, but how does it handle free-formed string type env var expansion now?
Add
paramsfield to wanda spec for declaring allowed values of environment variables used in templated fields (name, froms). This enables:declared params
expanded names (e.g., base$PY with params [3.10, 3.11] is indexed as
both base3.10 and base3.11), enabling dependency resolution without
requiring all env vars to be set
Validation runs before variable expansion in buildDepGraph, so errors
reference the original $VARNAME.
Topic: wanda-params
Relative: wanda-deps
Signed-off-by: andrew andrew@anyscale.com