BUG-Scenario doesn't show up in scenario_selector list when created with on_creation function
arcanaxion opened this issue · 16 comments
Description
Using the on_creation function of the scenario_selector control to create a scenario and modify an associated data node results in the scenario not being displayed in the scenario_selector.
I.e. the following code works if scenario.x.write(3)
is removed.
How to reproduce
import taipy as tp
from taipy import Config
x_cfg = Config.configure_pickle_data_node(id="x", default_data=5)
y_cfg = Config.configure_data_node(id="y")
def square(x):
return x**2
task1_cfg = Config.configure_task(id="task1", function=square, input=x_cfg, output=y_cfg)
scenario_cfg = Config.configure_scenario(id="scenario", task_configs=[task1_cfg])
def scenario_on_creation(state, id, action, payload):
config = payload["config"]
date = payload["date"]
label = payload["label"]
properties = payload["properties"]
scenario = tp.create_scenario(config, creation_date=date, name=label)
scenario.x.write(3) # This line prevents the scenario from showing up in the scenario_selector list
for key, value in properties.items():
scenario.properties[key] = value
return scenario
selected_scenario = None
md = """
# Create scenario
<|{selected_scenario}|scenario_selector|on_creation=scenario_on_creation|>
"""
if __name__ == "__main__":
tp.Core().run()
tp.Gui(md).run()
The scenario_on_creation
function does not raise an error. Calling tp.get_scenarios
shows that the scenario was created and the x
data node's value was properly written as 3
. But the scenario does not show up in the scenario_selector
.
Small side issue, if on_creation is not specified at all, the following warning appears:
TaipyGuiWarning: on_creation(): 'None' is not a function.
Expected behavior
When clicking "Add Scenario" and creating a new scenario, the scenario_on_creation
function should create a new scenario where x
is 3 and the scenario shows up in the scenario_selector
list.
Screenshots
When available and relevant, screenshots better help show the problem.
Runtime environment
- taipy==3.0.0.dev2
Is my scenario_on_creation
a good boilerplate function for replicating the default behavior of the scenario_selector
? I would appreciate if the docs included an example of recreating the default behavior. It would make it easy for people to just copy, paste and tweak accordingly.
I have pb replicating the issue:
When I run your script with taipy-3.0, I get an error (need to remove the action parameter in scenario_on_creation)
ERROR:Taipy:DataNode not found: DATANODE_x_f70d2ca9-b1c7-4a11-963f-d944c48b3635
but the scenario is created and visible
maybe @jrobinAV will have a better idea ?
PS: I removed the annoying warning about None function
I have pb replicating the issue: When I run your script with taipy-3.0, I get an error (need to remove the action parameter in scenario_on_creation) ERROR:Taipy:DataNode not found: DATANODE_x_f70d2ca9-b1c7-4a11-963f-d944c48b3635 but the scenario is created and visible maybe @jrobinAV will have a better idea ?
I just noticed the new on_creation function signature in the docs, but I don't think it's applicable for taipy-gui==3.0.0.dev2, is it?
Anyway, I have also now tested on the new release (3.0.0.dev3) and removed the action parameter, and I can still replicate the issue.
However, I'm now noticing that I can't replicate it consistently, but it happens most of the time. And sometimes when the scenario doesn't appear in the scenario_selector, I can do a combination of:
- Refreshing the page,
- Creating new scenarios,
- Deleting existing scenarios (if any) with the
scenario
control
Which usually eventually lead to a refresh and all the scenarios properly show up in the scenario_selector, with x
also properly set to 3.
Also, I too have the "data node not found" error but I don't know if it's related.
you're right the new signature is for dev3+
We'll keep on investigating this with the Core team
What system are you running on ?
can you try with
scenario = tp.create_scenario(config, creation_date=date, name=label)
sleep(1)
scenario.x.write(3)
Unfortunately, the sleep didn't change anything for me.
System info:
- Tried in both WSL and Windows 10
- Browsers:
- Chrome Version 117.0.5938.150 (Official Build) (64-bit)
- Firefox 118.0.1 (64-bit)
- Python versions:
- 3.10.10
- 3.9.15
Actually I don't know if I'm imagining it but I feel like it's happening less frequently with the sleep... Still happening though.
Not using any special characters. Has anyone on your team been able to reproduce my issue? I tried it on another machine and am still able to reproduce it with the same consistency, i.e. most of the time but not always.
Did you try with dev3 ?
Yes I'm testing it with dev3. We could schedule a quick call if it may help
Yes let me send you an invit'.
Thx
Hi, Can you set up your env so that we can run/debug from sources ?
ie clone repo and pipenv install --dev
tx
taipy 3.0.0.dev4 was released