Avaiga / taipy

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

BUG- on_submission_change not working in development mode #684

Closed FlorianJacta closed 7 months ago

FlorianJacta commented 7 months ago

Description The callback function is never called in development mode. It only works in standalone mode.

How to reproduce

from taipy.config import Config
import taipy as tp
from taipy.gui import Gui, notify

#Config.configure_job_executions(mode="standalone")

# Normal function used by Taipy
def double(nb):
    return nb * 2

# Configuration of Data Nodes
input_cfg = Config.configure_data_node(id="somedata", default_data=21)
output_cfg = Config.configure_data_node(id="result")

# Configuration of tasks
first_task_cfg = Config.configure_task(id="double",
                                       function=double,
                                       input=input_cfg,
                                       output=output_cfg)

# Configuration of scenario
scenario_cfg = Config.configure_scenario(id="my_scenario",
                                         task_configs=[first_task_cfg],
                                         name="my_scenario")

def notify_from_submissions(state, submittable, details):
    submission_status = details.get('submission_status')
    print(submission_status)

    if submission_status == 'COMPLETED':
        print("COMPLETED")
        notify(state, 'success', 'Completed!')
        # Add additional actions here, like updating the GUI or logging the completion.

    elif submission_status == 'FAILED':
        print("FAILED")
        notify(state, 'error', 'FAILED!')
        # Handle failure, like sending notifications or logging the error.

if __name__=="__main__":
    tp.Core().run()
    scenario_1 = tp.create_scenario(scenario_cfg)

    scenario_md = """
<|{scenario_1}|scenario|on_submission_change=notify_from_submissions|>
"""
    Gui(scenario_md).run()

Expected behavior The callback function should be called and work.

Runtime environment Please specify relevant indications.

Acceptance Criteria

FredLL-Avaiga commented 7 months ago

@FlorianJacta tested with latest develop and I get COMPLETED printed twice in the console AND a notification in the browser

FredLL-Avaiga commented 7 months ago

there's an issue when not in develop mode.

FlorianJacta commented 7 months ago

@FlorianJacta tested with latest develop and I get COMPLETED printed twice in the console AND a notification in the browser

Similar to this issue? https://github.com/Avaiga/taipy/issues/357

jrobinAV commented 7 months ago

there's an issue when not in develop mode.

Any information about it? 🤣

FredLL-Avaiga commented 7 months ago

there's an issue when not in develop mode.

Any information about it? 🤣

Yes, it's fixed