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

BUG- on_submission_change called twice with same status #357

Closed
FlorianJacta opened this issue Oct 25, 2023 · 8 comments
Closed

BUG- on_submission_change called twice with same status #357

FlorianJacta opened this issue Oct 25, 2023 · 8 comments
Assignees
Labels
🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem. 🟧 Priority: High Must be addressed as soon
Milestone

Comments

@FlorianJacta
Copy link
Member

FlorianJacta commented Oct 25, 2023

Issue

The callback is called twice with the same status.

How to replicate

Run this code and see that two notifications are emitted.

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


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

def add(nb):
    return nb + 10


# Configuration of Data Nodes
input_cfg = Config.configure_data_node("input", default_data=21)
intermediate_cfg = Config.configure_data_node("intermediate")
output_cfg = Config.configure_data_node("output")


# Configuration of tasks
first_task_cfg = Config.configure_task("double",
                                       double,
                                       input_cfg,
                                       intermediate_cfg)

second_task_cfg = Config.configure_task("add",
                                        add,
                                        intermediate_cfg,
                                        output_cfg)



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



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

    if submission_status == 'COMPLETED':
        print(f"{[submittable.name](http://submittable.name/)} has completed.")
        notify(state, 'success', 'Completed!')
        # Add additional actions here, like updating the GUI or logging the completion.

    elif submission_status == 'FAILED':
        print(f"{[submittable.name](http://submittable.name/)} has failed.")
        notify(state, 'error', 'Completed!')
        # Handle failure, like sending notifications or logging the error.


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

    scenario_1.submit(wait=True)

    scenario_md = """
<|{scenario_1}|scenario|on_submission_change=notify_from_submissions|>
<|{scenario_1.output if scenario_1 else None}|data_node|>
"""
    Gui(scenario_md).run()

Environment

Taipy 3.0

@FredLL-Avaiga
Copy link
Member

Needs a blocking event queue to make event management cleaner

@FredLL-Avaiga FredLL-Avaiga added 🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem. 🟧 Priority: High Must be addressed as soon labels Oct 25, 2023
@jrobinAV jrobinAV added 🟨 Priority: Medium Not blocking but should be addressed 🟧 Priority: High Must be addressed as soon and removed 🟧 Priority: High Must be addressed as soon 🟨 Priority: Medium Not blocking but should be addressed labels Nov 20, 2023
joaoandre-avaiga pushed a commit that referenced this issue Nov 23, 2023
* #255 add core package ref man

* Apply suggestions from code review

feedback from Toan

Co-authored-by: Toan Quach <93168955+toan-quach@users.noreply.github.com>

* remove import * from init file

* remove import * from init file

* remove import * from init file

Co-authored-by: Toan Quach <93168955+toan-quach@users.noreply.github.com>
@jrobinAV
Copy link
Member

IS it a duplicate or the ticket #475 ?

@FlorianJacta
Copy link
Member Author

FlorianJacta commented Dec 15, 2023

Yes, it is a duplicate. I guess I wanted it to be solved, or my memory is fading. Do I close the other issue?

@jrobinAV
Copy link
Member

Yes, it is a duplicate. I guess I wanted it to be solved, or my memory is fading. Do I close the other issue?

YEs please @FlorianJacta.

@toan-quach
Copy link
Member

Hi @FlorianJacta
I was able to reproduce it with 3.0 but not with 3.1dev. I think the issue has been fixed!

@jrobinAV @FredLL-Avaiga I believe no fixes need to be made, but will make some changes to make some of the conditions correct. However, I must note that the on_submission_change doesn't run on development mode but does run in standalone mode, which is to be expected I think

@FredLL-Avaiga
Copy link
Member

I don't understand why it runs in one mode and not in another one ?

@toan-quach
Copy link
Member

because in development mode, after submitting the scenario, it will run it immediately without stopping until finished. Meaning the submission entity has complete status when we're creating the _SubmissionDetails. No status change will happen after that and so the function was not called as it depends on the change in status of the job (previously, now it's submission status)

@FredLL-Avaiga
Copy link
Member

that would need to be documented
Or better find a workaround to make it work in dev mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem. 🟧 Priority: High Must be addressed as soon
Projects
None yet
Development

No branches or pull requests

5 participants