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
Describe the bug
Batch runs cannot be successfully completed if the flow call produces an AsyncIterator that ends up wrapped by promptflow.tracing.TracedAsyncIterator. Each run from data files errors with TypeError: cannot pickle 'thread.lock' object
How To Reproduce the bug
Code below produces error consistently
importtempfilefromopenaiimportAzureOpenAIfrompromptflow.tracingimporttracefrompromptflow.coreimportAzureOpenAIModelConfiguration, Promptyfrompromptflow.clientimportPFClientclassChatFlow:
def__init__(
self, model_config: AzureOpenAIModelConfiguration
):
self.model_config=model_config@traceasyncdef__call__(
self,
topic: str,
) ->str:
"""Flow entry function."""client=AzureOpenAI(
azure_endpoint=self.model_config.azure_endpoint,
api_key=self.model_config.api_key,
api_version=self.model_config.api_version,
)
response=client.chat.completions.create(
model=self.model_config.azure_deployment,
messages= [
{"role": "system", "content": "Create a story about the topic provided by the user"},
{"role": "user", "content": f"Tell me a story about {topic}"},
],
max_tokens=150,
)
forchunkinresponse:
iflen(chunk.choices) >0and (message:=chunk.choices[0].message):
content=message.contentyieldcontent+"\n"defmain():
f=tempfile.NamedTemporaryFile(suffix=".csv", mode="w+t")
try:
f.write("topic\nlittle league\n")
f.seek(0)
config=AzureOpenAIModelConfiguration(
connection="aoai_connection", azure_deployment="gpt-35-turbo"
)
chat_flow=ChatFlow(model_config=config)
result=PFClient().run(chat_flow, data=f.name)
finally:
f.delete()
if__name__=="__main__":
main()
Bug can be traced to run_info submitted to queue at
For the example code, the results property within run_info has an instance of promptflow.tracing.TracedAsyncIterator which is not able to be pickled when submitted to multiprocessing queue and raises the mentioned error.
Describe the bug
Batch runs cannot be successfully completed if the flow call produces an AsyncIterator that ends up wrapped by
promptflow.tracing.TracedAsyncIterator
. Each run from data files errors withTypeError: cannot pickle 'thread.lock' object
How To Reproduce the bug
Code below produces error consistently
Bug can be traced to
run_info
submitted to queue atpromptflow/src/promptflow-core/promptflow/storage/_queue_run_storage.py
Line 24 in 745704a
For the example code, the results property within
run_info
has an instance ofpromptflow.tracing.TracedAsyncIterator
which is not able to be pickled when submitted to multiprocessing queue and raises the mentioned error.Error file from batch run attached
error.json
Expected behavior
Successful execution of batch run
Running Information(please complete the following information):
pf -v
: 1.12.0python --version
: 3.12.2The text was updated successfully, but these errors were encountered: