figoyouwei / taipy_success

This is a sample code that tests the deployment on heroku
2 stars 2 forks source link

Issue 02: scenario error with yfinance data task #2

Closed figoyouwei closed 2 months ago

figoyouwei commented 2 months ago

The download is fine and the submit running also seems fine, but it returns a freeze_support error https://github.com/figoyouwei/taipy_success/blob/main/app/scenarios/yfin.py

Please run the code and fix, thanks.

FlorianJacta commented 2 months ago

Don't ommit the if __name__ == "__main__":. It is important when using parallelism and asynchronous submission.


... # the beginning of your code

# Put the rest of your code in this "if"
if __name__ == "__main__":
    # Configure job execution mode
    tcc.configure_job_executions(mode="standalone", max_nb_of_workers=2)

    # Configuration of Data Nodes
    node_yfin_args_in = tcc.configure_data_node("node_yfin_args_in")
    node_yfin = tcc.configure_data_node("node_yfin")

    # Configuration of tasks
    task_cfg_yfin = tcc.configure_task(
        id="task_yfin", function=download_yfin, input=node_yfin_args_in, output=node_yfin
    )

    # Configuration of scenario
    scenario_cfg_yfin = tcc.configure_scenario(
        id="scenario_yfin", task_configs=[task_cfg_yfin]
    )

    # ------------------------------
    # run scenario
    # ------------------------------

    # Run core
    tp.Core().run()

    # 1.create
    scenario_yin = tp.create_scenario(scenario_cfg_yfin)

    # 2.initialize input
    scenario_yin.data_nodes["node_yfin_args_in"].write(args_in)
    scenario_yin.data_nodes["node_yfin_args_in"].read()

    # 3.submit: error freeze_support()
    scenario_yin.submit(wait=True, timeout=120)
    data_out = scenario_yin.data_nodes["node_yfin"].read()
    print(data_out)

    tp.Core().stop()