promptflow icon indicating copy to clipboard operation
promptflow copied to clipboard

[BUG] [VSCode Extension] Running bulk test vs code interactive window errors not show

Open zyw400 opened this issue 3 years ago • 3 comments

Describe the bug I was running the code below to do a bulk test using the vs code python interactive window (shift-enter to execute the cells). image The flow has some issues. But from the VS code interactive window, the cell execution never stops.

How To Reproduce the Bug Steps to reproduce the behavior, how frequently can you experience the bug: every time.

Screenshots image

image

Environment Information

  • Operating System: Windows 11
  • Python Version using python --version: 3.9.17
  • VS Code version.
  • Prompt Flow extension version.
  • If your code to repro the issue is public and you want to share us, please share the link.

Additional context Add any other context about the problem here.

zyw400 avatar Sep 15 '23 17:09 zyw400

Hi @zyw400 , could you provide the code of the stuck cell so we can try repro it? From your screenshot seems the flow run has completed.

D-W- avatar Sep 19 '23 03:09 D-W-

Seems executor stucks when executing in python interactive window. @huaiyan's helping take a look.

D-W- avatar Sep 19 '23 08:09 D-W-

Thanks for reporting @zyw400 This issue is by design since we need to create child process for exec_bulk. The workaround is executing your code in main block, for example:

if __name__ == "__main__":
    flow_executor = FlowExecutor.create(
        flow_file="./flow.dag.yaml",
        connections={"azure_open_ai_connection": AzureOpenAIConnection(
            api_key="fake_api_key",
            api_base="fake_api_base",
        )._to_execution_connection_dict()},
    )
    result = flow_executor.exec_bulk(inputs=[
        {"input1": "value"}
    ])

Root cause about it: When Python multiprocessing module creates child processes, it imports the main module. So, if we don't execute the code in main block, the code will be triggered again as importing, which should be forbidden. We will try to improve doc about it.

huaiyan avatar Sep 20 '23 04:09 huaiyan