Avaiga / taipy

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

"Cannot submit scenario" in scenario visual element without explanation #746

Closed AlexandreSajus closed 4 months ago

AlexandreSajus commented 8 months ago

The scenario visual element can display a grey send icon with "Cannot submit scenario" without an explanation: image

This bug gets triggered in the Scenario Management Overview tutorial when the user creates a new scenario and tries to run it

How to reproduce:

  1. Use the code provided in the Scenario Management Overview tutorial:
from taipy import Config
import taipy as tp
import pandas as pd
import datetime as dt

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: str) -> 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")

# 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])

Config.export('config.toml')

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

    # Creation of the scenario and execution
    scenario = tp.create_scenario(scenario_cfg)
    scenario.historical_temperature.write(data)
    scenario.date_to_forecast.write(dt.datetime.now())
    tp.submit(scenario)

    print("Value at the end of task", scenario.predictions.read())

    def save(state):
        state.scenario.historical_temperature.write(data)
        state.scenario.date_to_forecast.write(state.date)
        tp.gui.notify(state, "s", "Saved! Ready to submit")

    date = None
    scenario_md = """
<|{scenario}|scenario_selector|>

Put a Date
<|{date}|date|on_change=save|active={scenario}|>

Run the scenario
<|{scenario}|scenario|>
<|{scenario}|scenario_dag|>

View all the information on your prediction here
<|{scenario.predictions if scenario else None}|data_node|>
"""

    tp.Gui(scenario_md).run()
  1. Run the app and create a new scenario image

  2. The scenario visual element won't let you run the new scenario image

jrobinAV commented 8 months ago

Today, the is_submitable taipy API called with a scenario or a sequence returns a simple boolean value. We can imagine returning a reason as well.

jrobinAV commented 7 months ago

Two missing pieces at this stage:

jrobinAV commented 7 months ago

We will propose a design for a Reason object to be returned by is_submittable and a mechanism to publish appropriate events.

FredLL-Avaiga commented 4 months ago

This has been fixed on the UI side while integrating the necessary changes in visual elements for supporting is_submittable(): Reason! PR