Skip to content
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

on_submission_change called twice with the same status #2325

Conversation

FredLL-Avaiga
Copy link
Member

resolves #2152

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

on_sumission_changed can be called twice with the same status.
fix: initiliaze the context status to None and report only increase in status

Related Tickets & Documents

How to reproduce the issue

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


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


# Configuration of Data Nodes
input_cfg = Config.configure_data_node("input_dn", default_data=21)
output_cfg = Config.configure_data_node("output_dn")


# Configuration of tasks
first_task_cfg = Config.configure_task("double",
                                       double,
                                       input_cfg,
                                       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')

    if submission_status == 'COMPLETED':
        print("COMPLETED")
        print(submittable)
        print(details)
        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.Orchestrator().run()
    scenario_1 = tp.create_scenario(scenario_cfg)

    scenario_md = """
<|{scenario_1}|scenario|on_submission_change=notify_from_submissions|>
"""
    Gui(scenario_md).run(title="2152 [🐛 BUG] On_submission_change - submission is completed twice")

@FredLL-Avaiga FredLL-Avaiga added Core Related to Taipy Core 🟥 Priority: Critical Must be addressed as soon as possible 💥Malfunction Addresses an identified problem. 📝Release Notes Impacts the Release Notes or the Documentation in general Gui: Back-End labels Dec 12, 2024
@FredLL-Avaiga FredLL-Avaiga self-assigned this Dec 12, 2024
Copy link
Member

@FabienLelaquais FabienLelaquais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫤

Fred Lefévère-Laoide added 2 commits December 12, 2024 11:21
Copy link
Contributor

github-actions bot commented Dec 12, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
19485 16952 87% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
taipy/gui_core/_context.py 62% 🟢
taipy/gui_core/_utils.py 100% 🟢
TOTAL 81% 🟢

updated for commit: 3724a81 by action🐍

Copy link
Member

@FabienLelaquais FabienLelaquais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮‍💨

@FredLL-Avaiga FredLL-Avaiga merged commit abe324c into develop Dec 12, 2024
126 checks passed
@FredLL-Avaiga FredLL-Avaiga deleted the bug/#2152-on-submission-change-called-twice-with-same-status branch December 12, 2024 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Related to Taipy Core Gui: Back-End 💥Malfunction Addresses an identified problem. 🟥 Priority: Critical Must be addressed as soon as possible 📝Release Notes Impacts the Release Notes or the Documentation in general
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🐛 BUG] On_submission_change - submission is completed twice
2 participants