Avaiga / taipy

Turns Data and AI algorithms into production-ready web applications in no time.
https://www.taipy.io
Apache License 2.0
15.43k stars 1.86k forks source link

[πŸ› BUG] Scenario Selector - Cannot select scenario after scenario creation #2169

Closed FlorianJacta closed 3 weeks ago

FlorianJacta commented 3 weeks ago

What went wrong? πŸ€”

The scenario selector doesn't automatically select the new scenario when creating a scenario. It is also impossible to select any scenario afterward.

After a page refresh, it is possible.

C:\Users\jacta\.conda\envs\patch\Lib\site-packages\taipy\gui\gui.py:707: TaipyGuiWarning: Decoding Message has failed: {'type': 'RU', 'name': '', 'payload': {'id': '', 'names': ['_TpL_tp_TpExPr_gui_get_adapted_lov_taipy_gui_core_Ctx_get_scenarios_None_tpgc_sc_filter31_tpgc_sc_sort31_tgc_scenario_TPMDL_1_0'], 'refresh': True}, 'propagate': True, 'client_id': '20241028105504955673-0.5756708616347557', 'ack_id': 'XPtMYBUOXA5fZMEd4iGvF', 'module_context': '__main__'}:
'types.SimpleNamespace' object has no attribute '_TpL_tp_TpExPr_gui_get_adapted_lov_taipy_gui_core_Ctx_get_scenarios_None_tpgc_sc_filter31_tpgc_sc_sort31_tgc_scenario_TPMDL_1_0'
  _warn(f"Decoding Message has failed: {message}", e)
C:\Users\jacta\.conda\envs\patch\Lib\site-packages\taipy\gui\gui.py:707: TaipyGuiWarning: Decoding Message has failed: {'type': 'RU', 'name': '', 'payload': {'id': '', 'names': ['_TpL_tp_TpExPr_gui_get_adapted_lov_taipy_gui_core_Ctx_get_scenarios_None_tpgc_sc_filter31_tpgc_sc_sort31_tgc_scenario_TPMDL_1_0'], 'refresh': True}, 'propagate': True, 'client_id': '20241028105504955673-0.5756708616347557', 'ack_id': 'yTk9bU2I-RhhV0eKW2usd', 'module_context': '__main__'}:
'types.SimpleNamespace' object has no attribute '_TpL_tp_TpExPr_gui_get_adapted_lov_taipy_gui_core_Ctx_get_scenarios_None_tpgc_sc_filter31_tpgc_sc_sort31_tgc_scenario_TPMDL_1_0'
  _warn(f"Decoding Message has failed: {message}", e)
C:\Users\jacta\.conda\envs\patch\Lib\site-packages\taipy\gui\gui.py:707: TaipyGuiWarning: Decoding Message has failed: {'type': 'RU', 'name': '', 'payload': {'id': '', 'names': ['_TpL_tp_TpExPr_gui_get_adapted_lov_taipy_gui_core_Ctx_get_scenarios_None_tpgc_sc_filter31_tpgc_sc_sort31_tgc_scenario_TPMDL_1_0'], 'refresh': True}, 'propagate': True, 'client_id': '20241028105504955673-0.5756708616347557', 'ack_id': 'JylotNvl52oD5pWwU_K3d', 'module_context': '__main__'}:
'types.SimpleNamespace' object has no attribute '_TpL_tp_TpExPr_gui_get_adapted_lov_taipy_gui_core_Ctx_get_scenarios_None_tpgc_sc_filter31_tpgc_sc_sort31_tgc_scenario_TPMDL_1_0'
  _warn(f"Decoding Message has failed: {message}", e)
C:\Users\jacta\.conda\envs\patch\Lib\site-packages\taipy\gui\gui.py:707: TaipyGuiWarning: Decoding Message has failed: {'type': 'RU', 'name': '', 'payload': {'id': '', 'names': ['_TpL_tp_TpExPr_gui_get_adapted_lov_taipy_gui_core_Ctx_get_scenarios_None_tpgc_sc_filter71_tpgc_sc_sort71_tgc_scenario_TPMDL_1_0'], 'refresh': True}, 'propagate': True, 'client_id': '20241028105504955673-0.5756708616347557', 'ack_id': 'w_N7MX6S565zCoJmvEsv5', 'module_context': '__main__'}:
'types.SimpleNamespace' object has no attribute '_TpL_tp_TpExPr_gui_get_adapted_lov_taipy_gui_core_Ctx_get_scenarios_None_tpgc_sc_filter71_tpgc_sc_sort71_tgc_scenario_TPMDL_1_0'
  _warn(f"Decoding Message has failed: {message}", e)

Expected Behavior

This is a regression. It should work like before. Creating a scenario through the scenario selector should select the newly created scenario. You should also be able to change the chosen scenario afterward.

Steps to Reproduce Issue

from taipy import Config, Frequency
import taipy as tp
import pandas as pd
import datetime as dt
import taipy.gui.builder as tgb

data = pd.read_csv(
    "https://raw.githubusercontent.com/Avaiga/taipy-getting-started-core/develop/src/daily-min-temperatures.csv"
)

# Normal function used by Taipy
def predict(
    historical_temperature: pd.DataFrame, date_to_forecast: dt.datetime
) -> float:
    print(f"Running baseline...")
    historical_temperature["Date"] = pd.to_datetime(historical_temperature["Date"])
    historical_same_day = historical_temperature.loc[
        (historical_temperature["Date"].dt.day == date_to_forecast.day)
        & (historical_temperature["Date"].dt.month == date_to_forecast.month)
    ]
    return historical_same_day["Temp"].mean()

# Configuration of Data Nodes
historical_temperature_cfg = Config.configure_data_node("historical_temperature")
date_to_forecast_cfg = Config.configure_data_node("date_to_forecast")
predictions_cfg = Config.configure_data_node("predictions", storage_type="json")

# Configuration of tasks
predictions_cfg = Config.configure_task(
    "predict",
    predict,
    [historical_temperature_cfg, date_to_forecast_cfg],
    predictions_cfg,
)

# Configuration of scenario
scenario_cfg = Config.configure_scenario(
    id="my_scenario", task_configs=[predictions_cfg], frequency=Frequency.MONTHLY
)

if __name__ == "__main__":
    # Run of the Core
    tp.Core().run()

    # Creation of the scenario and execution
    scenario = tp.create_scenario(scenario_cfg)
    tp.create_scenario(scenario_cfg, name="Hello World")

    with tgb.Page() as page:
        tgb.scenario_selector("{scenario}")
        tgb.scenario("{scenario}")

    tp.Gui(page).run()

Version of Taipy

4.0.1.dev0

Acceptance Criteria

Code of Conduct

AlexandreSajus commented 1 week ago

Fixed in 4.0.1.dev1 πŸŽ‰