Skip to content

[🐛 BUG] Job selector does not update if scenario is submitted in callback #2869

Description

@arcanaxion

🔍 What went wrong?

  • Submitting scenario via tgb.scenario will update the job selector
  • Submitting scenario via callback will not update the job selector

Example code:

import time

import taipy as tp
import taipy.gui.builder as tgb
from taipy import Config
from taipy.gui import Gui
import datetime as dt


def square(x: int) -> int:
    time.sleep(5)
    return x**2


x_xfg = Config.configure_data_node(id="x", default_data=5)
y_xfg = Config.configure_data_node(id="y")
square_task_cfg = Config.configure_task(id="square", function=square, input=x_xfg, output=y_xfg)
scenario_cfg = Config.configure_scenario(id="scenario", task_configs=[square_task_cfg])

selected_scenario = None

with tgb.Page() as root_page:
    with tgb.layout():
        with tgb.part():
            tgb.button(
                "Create scenario",
                on_action=lambda state: tp.create_scenario(
                    scenario_cfg, name=f"Scenario - {dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
                ),
            )
            tgb.scenario_selector("{selected_scenario}")
        with tgb.part():
            tgb.scenario("{selected_scenario}")
            tgb.button("Submit selected scenario", on_action=lambda state: state.selected_scenario.submit())
    tgb.job_selector()

pages = {"/": root_page}

if __name__ == "__main__":
    Config.configure_job_executions(mode="standalone", max_nb_of_workers=1)

    orchestrator = tp.Orchestrator()
    orchestrator.run()

    gui = Gui(pages=pages)
    gui.run(dark_mode=False, run_browser=False)

🔄 Steps to Reproduce

  1. Click "Create scenario"
  2. Click Submit in the tgb.scenario
  3. Observe that the job selector updates with the running job
  4. Click "Create scenario"
  5. Click "Submit selected scenario" regular button
  6. Observe that the job selector does not update
  7. Refresh the page: no update
  8. Reopen browser: successful update

📦 Taipy Version

develop

📋 Additional Context (Optional)

📜 Code of Conduct

  • I have checked the existing issues to avoid duplicates.
  • I am willing to work on this issue (optional)

✅ Acceptance Criteria

  • A reproducible unit test is added.
  • Code coverage is at least 90%.
  • The bug reporter validated the fix.
  • Relevant documentation updates or an issue created in

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions