From 783f2cfdd850c74949c39f48c4c48a3f447d6a0a Mon Sep 17 00:00:00 2001 From: FlorianJacta <98709993+FlorianJacta@users.noreply.github.com> Date: Thu, 12 Oct 2023 11:07:10 +0200 Subject: [PATCH 1/5] Update compare scenarios --- .../src/step_08.py | 16 +++++----- .../step_08/{config_08.svg => config.svg} | 0 .../step_08/{step_08.md => index.md} | 30 ++++++++----------- 3 files changed, 19 insertions(+), 27 deletions(-) rename docs/knowledge_base/tutorials/scenario_management_overview/step_08/{config_08.svg => config.svg} (100%) rename docs/knowledge_base/tutorials/scenario_management_overview/step_08/{step_08.md => index.md} (76%) diff --git a/docs/knowledge_base/tutorials/scenario_management_overview/src/step_08.py b/docs/knowledge_base/tutorials/scenario_management_overview/src/step_08.py index 60d462fba..b8fb0becf 100644 --- a/docs/knowledge_base/tutorials/scenario_management_overview/src/step_08.py +++ b/docs/knowledge_base/tutorials/scenario_management_overview/src/step_08.py @@ -17,14 +17,14 @@ def add(nb): # Configuration of tasks first_task_cfg = Config.configure_task("double", - double, - input_cfg, - intermediate_cfg) + double, + input_cfg, + intermediate_cfg) second_task_cfg = Config.configure_task("add", - add, - intermediate_cfg, - output_cfg) + add, + intermediate_cfg, + output_cfg) @@ -62,6 +62,4 @@ def compare_function(*data_node_results): scenario_1.submit() scenario_2.submit() - print(tp.compare_scenarios(scenario_1, scenario_2)) - - tp.Rest().run() + print(tp.compare_scenarios(scenario_1, scenario_2)) \ No newline at end of file diff --git a/docs/knowledge_base/tutorials/scenario_management_overview/step_08/config_08.svg b/docs/knowledge_base/tutorials/scenario_management_overview/step_08/config.svg similarity index 100% rename from docs/knowledge_base/tutorials/scenario_management_overview/step_08/config_08.svg rename to docs/knowledge_base/tutorials/scenario_management_overview/step_08/config.svg diff --git a/docs/knowledge_base/tutorials/scenario_management_overview/step_08/step_08.md b/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md similarity index 76% rename from docs/knowledge_base/tutorials/scenario_management_overview/step_08/step_08.md rename to docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md index 14774b704..9802781bf 100644 --- a/docs/knowledge_base/tutorials/scenario_management_overview/step_08/step_08.md +++ b/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md @@ -1,25 +1,22 @@ -> You can download the code for -Step 8 -or all the steps here. - -# Comparing scenarios +> You can download the code +here. *Estimated Time for Completion: 15 minutes; Difficulty Level: Advanced* -![](config_08.svg){ width=700 style="margin:auto;display:block;border: 4px solid rgb(210,210,210);border-radius:7px" } +![](config.svg){ width=700 style="margin:auto;display:block;border: 4px solid rgb(210,210,210);border-radius:7px" } Taipy offers a way to compare data nodes across scenarios by including a function directly in the configuration of the scenario. ## Step 1: The first step consists in declaring on which data nodes to apply the comparison functions: -In this example, we want to apply a comparison to the '_output_' Data Node. It is indicated in the comparators parameter of the `configure_scenario()`. +In this example, we want to apply a comparison to the '_output_' Data Node. It is indicated in the comparators parameter of the `configure_scenario`. ```python scenario_cfg = Config.configure_scenario(id="multiply_scenario", - name="my_scenario", - tasks_configs=[first_task_cfg, - second_task_cfg], - comparators={output_data_node_cfg.id: compare_function},) + name="my_scenario", + tasks_configs=[first_task_cfg, + second_task_cfg], + comparators={output_data_node_cfg.id: compare_function},) ``` ## Step 2: Implement the comparison function (`compare_function()`) used above. @@ -40,7 +37,7 @@ def compare_function(*data_node_results): return compare_result ``` -Now, the `compare_scenarios()` can be used within Taipy. +Now, the `compare_scenarios` can be used within Taipy. ```python tp.Core().run() @@ -63,7 +60,6 @@ Results: # Entire code - ```python from taipy.core.config import Config, Frequency import taipy as tp @@ -111,9 +107,9 @@ def compare_function(*data_node_results): scenario_cfg = Config.configure_scenario(id="multiply_scenario", - name="my_scenario", - task_configs=[first_task_cfg, second_task_cfg], - comparators={output_cfg.id: compare_function}) + name="my_scenario", + task_configs=[first_task_cfg, second_task_cfg], + comparators={output_cfg.id: compare_function}) if __name__=="__main__": @@ -129,6 +125,4 @@ if __name__=="__main__": scenario_2.submit() print(tp.compare_scenarios(scenario_1, scenario_2)) - - tp.Rest().run() ``` \ No newline at end of file From e2f7b54ff9583d8ccd22ca61a7efea07527cee4c Mon Sep 17 00:00:00 2001 From: FlorianJacta <98709993+FlorianJacta@users.noreply.github.com> Date: Thu, 12 Oct 2023 14:47:34 +0200 Subject: [PATCH 2/5] Put description in image --- .../tutorials/scenario_management_overview/step_08/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md b/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md index 9802781bf..ad3d1b206 100644 --- a/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md +++ b/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md @@ -3,7 +3,7 @@ *Estimated Time for Completion: 15 minutes; Difficulty Level: Advanced* -![](config.svg){ width=700 style="margin:auto;display:block;border: 4px solid rgb(210,210,210);border-radius:7px" } +![Configuration](config.svg){ width=700 style="margin:auto;display:block;border: 4px solid rgb(210,210,210);border-radius:7px" } Taipy offers a way to compare data nodes across scenarios by including a function directly in the configuration of the scenario. From e0c51cb15dcb69fc96a13b71a77f1248b936629d Mon Sep 17 00:00:00 2001 From: FlorianJacta <98709993+FlorianJacta@users.noreply.github.com> Date: Thu, 12 Oct 2023 14:53:31 +0200 Subject: [PATCH 3/5] Move Python code --- .../src/config_08.toml | 30 ------------------- .../step_08/index.md | 2 +- .../scenario_comparison.py} | 0 3 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 docs/knowledge_base/tutorials/scenario_management_overview/src/config_08.toml rename docs/knowledge_base/tutorials/scenario_management_overview/{src/step_08.py => step_08/scenario_comparison.py} (100%) diff --git a/docs/knowledge_base/tutorials/scenario_management_overview/src/config_08.toml b/docs/knowledge_base/tutorials/scenario_management_overview/src/config_08.toml deleted file mode 100644 index 999c3f4c4..000000000 --- a/docs/knowledge_base/tutorials/scenario_management_overview/src/config_08.toml +++ /dev/null @@ -1,30 +0,0 @@ -[TAIPY] - -[DATA_NODE.input] -default_data = "21:int" - -[DATA_NODE.intermediate] - -[DATA_NODE.output] - -[TASK.double] -function = "__main__.double:function" -inputs = [ "input:SECTION",] -outputs = [ "intermediate:SECTION",] -skippable = "False:bool" - -[TASK.add] -function = "__main__.add:function" -inputs = [ "intermediate:SECTION",] -outputs = [ "output:SECTION",] -skippable = "False:bool" - -[SCENARIO.multiply_scenario] -tasks = [ "double:SECTION", "add:SECTION",] -additional_data_nodes = [] -name = "my_scenario" - -[SCENARIO.multiply_scenario.comparators] -output = [ "__main__.compare_function:function",] - -[SCENARIO.multiply_scenario.sequences] diff --git a/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md b/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md index ad3d1b206..622eaac18 100644 --- a/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md +++ b/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md @@ -1,5 +1,5 @@ > You can download the code -here. +here. *Estimated Time for Completion: 15 minutes; Difficulty Level: Advanced* diff --git a/docs/knowledge_base/tutorials/scenario_management_overview/src/step_08.py b/docs/knowledge_base/tutorials/scenario_management_overview/step_08/scenario_comparison.py similarity index 100% rename from docs/knowledge_base/tutorials/scenario_management_overview/src/step_08.py rename to docs/knowledge_base/tutorials/scenario_management_overview/step_08/scenario_comparison.py From e100e401b75d9b6871bae5921c1e21cb8b452376 Mon Sep 17 00:00:00 2001 From: Jean-Robin Date: Thu, 12 Oct 2023 16:25:27 +0200 Subject: [PATCH 4/5] Update docs/knowledge_base/tutorials/scenario_management_overview/step_08/scenario_comparison.py --- .../step_08/scenario_comparison.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/knowledge_base/tutorials/scenario_management_overview/step_08/scenario_comparison.py b/docs/knowledge_base/tutorials/scenario_management_overview/step_08/scenario_comparison.py index b8fb0becf..d6371eb26 100644 --- a/docs/knowledge_base/tutorials/scenario_management_overview/step_08/scenario_comparison.py +++ b/docs/knowledge_base/tutorials/scenario_management_overview/step_08/scenario_comparison.py @@ -62,4 +62,5 @@ def compare_function(*data_node_results): scenario_1.submit() scenario_2.submit() - print(tp.compare_scenarios(scenario_1, scenario_2)) \ No newline at end of file + print(tp.compare_scenarios(scenario_1, scenario_2)) + \ No newline at end of file From 520bd4fb6c7c6b97c9cb8b1beb77e4eba1f065ab Mon Sep 17 00:00:00 2001 From: FlorianJacta <98709993+FlorianJacta@users.noreply.github.com> Date: Thu, 12 Oct 2023 17:13:07 +0200 Subject: [PATCH 5/5] Update index.md --- .../scenario_management_overview/step_08/index.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md b/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md index 622eaac18..12a40df56 100644 --- a/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md +++ b/docs/knowledge_base/tutorials/scenario_management_overview/step_08/index.md @@ -7,7 +7,9 @@ Taipy offers a way to compare data nodes across scenarios by including a function directly in the configuration of the scenario. -## Step 1: The first step consists in declaring on which data nodes to apply the comparison functions: +# Comparing scenarios + +**Step 1:** Declare data nodes on which the comparison functions are applied. In this example, we want to apply a comparison to the '_output_' Data Node. It is indicated in the comparators parameter of the `configure_scenario`. @@ -18,7 +20,8 @@ scenario_cfg = Config.configure_scenario(id="multiply_scenario", second_task_cfg], comparators={output_data_node_cfg.id: compare_function},) ``` -## Step 2: Implement the comparison function (`compare_function()`) used above. + +**Step 2:** Implement the comparison function (`compare_function()`) used above. _data_node_results_ is the list of the Output Data Nodes from all scenarios passed in the comparator. We iterate through it to compare scenarios.