Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.57k stars 2.79k forks source link

Clarify Azure ML client reuse #37780

Open bastbu opened 1 day ago

bastbu commented 1 day ago

Is your feature request related to a problem? Please describe.

I am using the Azure ML SDK inside an Azure Function. I've measured that reusing a (global) Azure ML SDK MLClient instance throughout the application is significantly faster, compared to instantiating a new client for every operation, even when reusing the Azure Identity credential. Since synchronous Azure Functions can be scaled via a thread pool, this means that the MLClient would be shared across multiple threads.

Is MLClient and its instance methods thread-safe and supports being reused throughout the application?

Other Azure SDKs, such as the Azure Blob Storage SDK or Azure Identity document whether their API is thread-safe or not.

Describe the solution you'd like

If the MLClient is safe to be shared across threads, it would be great to document it is. If it's not, it would be great to make it thread safe.

Describe alternatives you've considered

Creating an MLClient on each request, or alternatively maintain our own pool of MLClients.

github-actions[bot] commented 17 hours ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/azure-ml-sdk @azureml-github.