Skip to content

[🐛 BUG] Scenario_selector filter by custom property not working #2855

@arcanaxion

Description

@arcanaxion

🔍 What went wrong?

Issues:

  1. Filter by custom property not working
  2. Value of date key in on_creation callback payload wrong?

Example code:

Details
import taipy as tp
import taipy.gui.builder as tgb
from taipy import Config, Gui, Scenario
from taipy.gui import State


def square(x: int) -> int:
    return x**2


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

selected_scenario = None

def on_create_scenario(state: State, id: str, payload: dict):
    config = payload["config"]
    date = payload["date"]
    label = payload["label"]
    properties = payload["properties"]

    label += f" {date.strftime('%Y-%m-%d %H:%M:%S')}"
    sc: Scenario = tp.create_scenario(config, name=label, creation_date=date)
    sc.properties.update(properties)
    sc.properties["another_key"] = "another_value"
    return sc


with tgb.Page() as page:
    tgb.toggle(theme=True)
    with tgb.part(class_name="container"):
        tgb.text("# Select scenario:", mode="md")
        with tgb.layout(columns="1 1"):
            tgb.scenario_selector("{selected_scenario}", on_creation=on_create_scenario, filter=["another_key", "Label"])
            tgb.scenario_selector("{selected_scenario}", on_creation=on_create_scenario)
        tgb.scenario("{selected_scenario}")

if __name__ == "__main__":
    Config.configure_core()
    tp.Orchestrator().run()
    Gui(page=page).run(title="Filter by Custom Property", run_browser=False)

🔄 Steps to Reproduce

Custom property issue:

  1. Create a scenario on the left
  2. Observe that it was created with properties another_key = another_value
  3. Try to filter "another_key contains value"
  4. Observe that the selector is now empty (i.e. nothing matches)
  5. No warning in terminal

Date issue:

  1. Create a scenario on the left
  2. Observe that the on_creation added the value of the callback's payload's date key to the label
  3. Create another scenario on the left
  4. Observe that the date is the same, even though time has passed

📦 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

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions