-
Notifications
You must be signed in to change notification settings - Fork 14
Ensure correctness in query without suffix #429
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
Merged
greenc-FNAL
merged 4 commits into
Framework-R-D:main
from
beojan:creator-query-correctness
Mar 17, 2026
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| #include "phlex/core/framework_graph.hpp" | ||
| #include "phlex/model/data_cell_index.hpp" | ||
| #include "phlex/model/product_store.hpp" | ||
|
|
||
| #include "catch2/catch_test_macros.hpp" | ||
| #include "plugins/layer_generator.hpp" | ||
|
|
||
| #include "fmt/format.h" | ||
|
|
||
| #include <array> | ||
| #include <string> | ||
| #include <tuple> | ||
|
|
||
| using namespace phlex; | ||
| using namespace std::string_literals; | ||
|
|
||
| namespace { | ||
| // Provider functions | ||
| int provide_idx(data_cell_index const& dci) { return int(dci.number()); } | ||
| int provide_number(data_cell_index const&) { return 3; } | ||
| double provide_temperature(data_cell_index const& dci) { return double(dci.number()) * 100.0; } | ||
| std::string provide_name(data_cell_index const& dci) | ||
| { | ||
| return fmt::format("John the {}th", dci.number()); | ||
| } | ||
| } | ||
|
|
||
| TEST_CASE("Querying products in different ways", "[graph]") | ||
| { | ||
| constexpr int num_events = 25; | ||
| experimental::layer_generator gen; | ||
| gen.add_layer("event", {.parent_layer_name = "job", .total_per_parent_data_cell = num_events}); | ||
| experimental::framework_graph g{driver_for_test(gen)}; | ||
|
|
||
| // Register providers | ||
| g.provide("provide_number_in_job", provide_number, concurrency::unlimited) | ||
| .output_product(product_query{.creator = "input", .layer = "job", .suffix = "number"}); | ||
| g.provide("provide_number_in_event", provide_idx, concurrency::unlimited) | ||
| .output_product(product_query{.creator = "input", .layer = "event", .suffix = "evt_number"}); | ||
| g.provide("provide_temperature_in_event", provide_temperature, concurrency::unlimited) | ||
| .output_product(product_query{.creator = "input", .layer = "event", .suffix = "temperature"}); | ||
| g.provide("provide_temperature_in_event_again", provide_temperature, concurrency::unlimited) | ||
| .output_product( | ||
| product_query{.creator = "thermometer", .layer = "event", .suffix = "temperature"}); | ||
| g.provide("provide_name_in_event", provide_name, concurrency::unlimited) | ||
| .output_product(product_query{.creator = "give_name", .layer = "event", .suffix = "name"}); | ||
|
|
||
| // Duplicate with transform | ||
| g.transform("duplicate_temperature", [](double const& t) { return t; }) | ||
| .input_family(product_query{.creator = "input", .layer = "event", .suffix = "temperature"}) | ||
| .output_products("temperature"); | ||
|
|
||
| SECTION("All fields") | ||
| { | ||
| g.transform("all_fields", [](int const& i) { return i + 1; }) | ||
| .input_family(product_query{.creator = "input", .layer = "job", .suffix = "number"}) | ||
| .output_products("job_number"); | ||
| g.execute(); | ||
| CHECK(g.execution_count("all_fields") == 1); | ||
| } | ||
|
|
||
| SECTION("Creator and Layer, using creator (and using type alone)") | ||
| { | ||
| g.transform("creator_and_layer_by_creator", [](std::string const& str) { return str; }) | ||
| .input_family(product_query{.creator = "give_name", .layer = "event"}) | ||
| .output_products("event_name"); | ||
| g.observe( | ||
| "verify_name", | ||
| [](std::string const& str, int const& n) { CHECK(str == fmt::format("John the {}th", n)); }) | ||
| .input_family(product_query{.creator = "give_name", .layer = "event"}, | ||
| product_query{.creator = "input", .layer = "event"}); | ||
| g.execute(); | ||
| CHECK(g.execution_count("creator_and_layer_by_creator") == num_events); | ||
| } | ||
|
|
||
| SECTION("Creator and Layer, using layer") | ||
| { | ||
| g.transform("creator_and_layer_by_layer", [](double const& d) { return d; }) | ||
| .input_family(product_query{.creator = "input", .layer = "event"}) | ||
| .output_products("event_temp"); | ||
| g.execute(); | ||
| CHECK(g.execution_count("creator_and_layer_by_layer") == num_events); | ||
| } | ||
|
|
||
| SECTION("Creator and Layer only, after transform") | ||
| { | ||
| g.transform("creator_and_layer_after_transform", [](double const& d) { return d; }) | ||
| .input_family(product_query{.creator = "duplicate_temperature", .layer = "event"}) | ||
| .output_products("event_temp"); | ||
| g.execute(); | ||
| CHECK(g.execution_count("creator_and_layer_after_transform") == num_events); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.