Skip to content
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

Dynamic pipelines - a new foreach block #1480

Merged
merged 33 commits into from
Feb 12, 2025
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
94509e7
Proposal for dynamic pipelines
ptodev Aug 15, 2024
1f2ce8d
Foreach prototype
ptodev Oct 31, 2024
247b68d
Initial implementation
ptodev Nov 20, 2024
afdeb23
wip
wildum Nov 20, 2024
b917da4
Fixes to summation1 and summation2
ptodev Dec 17, 2024
439b300
fix foreach run
wildum Dec 17, 2024
7de0aa1
foreach uses the value from the collection via the var
wildum Dec 18, 2024
5174a33
compute an ID for the foreach instances and add tests
wildum Dec 19, 2024
2290e44
rework foreach txtar tests
wildum Jan 7, 2025
534e07e
support using modules inside of foreach
wildum Jan 8, 2025
68b7c7c
cleanup
wildum Jan 9, 2025
e192510
update frontend to use the moduleID of the component instead of the m…
wildum Jan 9, 2025
56437f7
plug the foreach node to the UI
wildum Jan 9, 2025
2625f1d
fix internal template components link
wildum Jan 9, 2025
91778c6
update comment in component references
wildum Jan 10, 2025
0d95adc
cleanups
wildum Jan 13, 2025
0b9f400
Disable debug metrics for components inside foreach, and for foreach …
ptodev Jan 15, 2025
6148600
Add stability lvl to config blocks (#2441)
wildum Jan 17, 2025
b91aee3
Add tests for types other than integers (#2436)
ptodev Jan 23, 2025
b690b16
Add docs for foreach (#2447)
ptodev Jan 23, 2025
6bf628c
use full hash on foreach instances and fix test
wildum Jan 27, 2025
417bd4d
Add a changelog entry.
ptodev Jan 27, 2025
86435e4
typo
wildum Jan 31, 2025
0b42dc3
allow non alphanum strings
wildum Jan 31, 2025
8611fa3
add test for wrong collection type
wildum Jan 31, 2025
7db7859
added capsule test
wildum Jan 31, 2025
1ab03b9
Add more tests for non-alphanumeric strings.
ptodev Jan 31, 2025
00c8dca
Apply suggestions from code review
ptodev Feb 10, 2025
737cd0d
Apply suggestions from code review
ptodev Feb 10, 2025
9781fab
Add comments regarding the override registry for modules
ptodev Feb 10, 2025
5ec5380
Rename hashObject to objectFingerprint
ptodev Feb 11, 2025
8f2f642
add comment for the hash function
wildum Feb 12, 2025
43c4d74
add additional detail to the comment
wildum Feb 12, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,41 @@ func TestNonAlphaNumericString(t *testing.T) {
require.ElementsMatch(t, customComponentIds, []string{"foreach_123__st_4__1"})
}

func TestNonAlphaNumericString2(t *testing.T) {
// All non-alphanumeric characters are replaced with "_".
// This test uses two different strings that will be normalized to the same string.
// Both "123./s4" and "123/.s4" will become "123__s4".
// We expect this to be ok - the controller will name one of them "123__s4_1", and the other "123__s4_2"
config := `foreach "default" {
collection = ["123./s4", "123/.s4"]
var = "num"
template {
}
}`
foreachConfigNode := NewForeachConfigNode(getBlockFromConfig(t, config), getComponentGlobals(t), nil)
require.NoError(t, foreachConfigNode.Evaluate(vm.NewScope(make(map[string]interface{}))))
customComponentIds := foreachConfigNode.moduleController.(*ModuleControllerMock).CustomComponents
require.ElementsMatch(t, customComponentIds, []string{"foreach_123__s4_1", "foreach_123__s4_2"})
}

func TestNonAlphaNumericString3(t *testing.T) {
// The "123./s4" non-alphanumeric string should normally be converted into "foreach_123__s4_1".
// However, there is already a "foreach_123__s4_1".
// We expect the controller to avoid such name collisions.
config := `foreach "default" {
collection = ["123./s4", "123__s4_1"]
var = "num"
template {
}
}`
foreachConfigNode := NewForeachConfigNode(getBlockFromConfig(t, config), getComponentGlobals(t), nil)
require.NoError(t, foreachConfigNode.Evaluate(vm.NewScope(make(map[string]interface{}))))
customComponentIds := foreachConfigNode.moduleController.(*ModuleControllerMock).CustomComponents
//TODO: It's not very clear which item became "foreach_123__s4_1_1".
// To avoid confusion, maybe we should log a mapping?
require.ElementsMatch(t, customComponentIds, []string{"foreach_123__s4_1", "foreach_123__s4_1_1"})
}

func TestCollectionNonArrayValue(t *testing.T) {
config := `foreach "default" {
collection = "aaa"
Expand Down
Loading