You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
An error is created when I am trying to use Taipy SDM (Scenario and Data Management) from another script. The issue only arises when my tasks use functions inside my main.py (main).
How to reproduce main.py
This is working fine:
fromtaipyimportConfigimporttaipyastpimportpandasaspdimportdatetimeasdtdata=pd.read_csv("https://raw.githubusercontent.com/Avaiga/taipy-getting-started-core/develop/src/daily-min-temperatures.csv")
# Normal function used by Taipydefpredict(historical_temperature: pd.DataFrame, date_to_forecast: dt.datetime) ->float:
print(f"Running baseline...")
historical_temperature['Date'] =pd.to_datetime(historical_temperature['Date'])
historical_same_day=historical_temperature.loc[
(historical_temperature['Date'].dt.day==date_to_forecast.day) &
(historical_temperature['Date'].dt.month==date_to_forecast.month)
]
returnhistorical_same_day['Temp'].mean()
# Configuration of Data Nodeshistorical_temperature_cfg=Config.configure_data_node("historical_temperature")
date_to_forecast_cfg=Config.configure_data_node("date_to_forecast")
predictions_cfg=Config.configure_data_node("predictions")
# Configuration of taskspredictions_cfg=Config.configure_task("predict",
predict,
[historical_temperature_cfg, date_to_forecast_cfg],
predictions_cfg)
# Configuration of scenarioscenario_cfg=Config.configure_scenario(id="my_scenario", task_configs=[predictions_cfg])
Config.export('config.toml')
if__name__=='__main__':
# Run of the Coretp.Core().run()
# Creation of the scenario and executionscenario=tp.create_scenario(scenario_cfg)
scenario.historical_temperature.write(data)
scenario.date_to_forecast.write(dt.datetime.now())
tp.submit(scenario)
test.py:
This throws an error.
importtaipyastpif__name__=='__main__':
# Creation of the scenario and executionscenario=tp.get_scenarios()[0]
print(scenario.date_to_forecast.read())
Error:
Expected behavior
At a minimum, better logs should appear.
Indeed, the internal Taipy data (.taipy folder) is not designed to be shared across multiple applications (multiple main scripts).
The data stores some user code locations relative to the main script. Switching from one application to another is not guaranteed to work properly. This would depend on where the user code is located and how it is imported and declared to Taipy objects.
I keep the ticket open to investigate if we can do something to make it work in more cases or at least to document the use cases that don't work.
Description
An error is created when I am trying to use Taipy SDM (Scenario and Data Management) from another script. The issue only arises when my tasks use functions inside my main.py (main).
How to reproduce
main.py
This is working fine:
test.py:
This throws an error.
Error:
Expected behavior
At a minimum, better logs should appear.
Runtime environment
Please specify relevant indications.
The text was updated successfully, but these errors were encountered: