imports of libraries such as numpy and pandas cause function to be very slow (20-30 seconds)
import pandas
python
Unfortunately this is expected behavior right now. You're hitting a combination of two separate issues:
Our support for python will probably stay in "experimental" mode until issue (1) is solved.
@paulbatum I hit into this as well. By moving away from ConsumptionPlan to AppServicePlan, I manage to reduce the load time from 30 sec to 10 sec but still not quite acceptable for production use.
@ylbillyli Sorry but I'm not aware of any good workarounds. Also you should not be looking at using the python support in production as its still considered an experimental feature. I would try using App Service (i.e. a web app) for your scenario. There are some docs on using python in App Service here.
@paulbatum do u have an update on this? Our python app might need to go live soon. Before migrating everything we have already setup from function app to web app, I just want to check if this issue is anywhere close to be resolved soon?
Alternatively, do you think I can wrap it in c# and store the Process in a static variable, start the process and never stop it and use it like this https://stackoverflow.com/questions/43876965/using-c-sharp-for-input-and-output-to-python ?
Hi billy,
If you need to stick with Python and are going into production soon then my recommendation is you move to using web apps, since the current support for python in functions is not intended for production usage. In theory the approach you mentioned of starting a python process from c# and then passing input params in through stdin or similar could work and is in fact a primitive version of how we plan on making python and other languages work well in functions in the long term, but it feels like a risky approach for you to take since your apps need to go live soon.
From: Billy notifications@github.com
Sent: Thursday, July 13, 2017 8:53:45 PM
To: Azure/azure-webjobs-sdk-script
Cc: Paul Batum; Mention
Subject: Re: [Azure/azure-webjobs-sdk-script] Functions run very slow when importing libraries [lang-Python] (#1626)
@paulbatumhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpaulbatum&data=02%7C01%7Cpbatum%40microsoft.com%7C42053473139e4b070e1108d4ca6bedb3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636356012282976274&sdata=DZqFs4Eyrnl2fMZvgPSDDhITIQi4%2BqQN5MuLBKNbLTs%3D&reserved=0 do u have an update on this? Our python app might need to go live soon. Before migrating everything we have already setup from function app to web app, I just want to check if this issue is anywhere close to be resolved soon?
Alternatively, do you think I can wrap it in c# and store the Process in a static variable, start the process and never stop it and use it like this https://stackoverflow.com/questions/43876965/using-c-sharp-for-input-and-output-to-pythonhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F43876965%2Fusing-c-sharp-for-input-and-output-to-python&data=02%7C01%7Cpbatum%40microsoft.com%7C42053473139e4b070e1108d4ca6bedb3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636356012282976274&sdata=wZFQY0cwerxMEensC76ms0V1pGfY%2F7KKdtIupcq6tFQ%3D&reserved=0 ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-webjobs-sdk-script%2Fissues%2F1626%23issuecomment-315263088&data=02%7C01%7Cpbatum%40microsoft.com%7C42053473139e4b070e1108d4ca6bedb3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636356012282976274&sdata=zB6CDgoeixEC3h1JPmoJoXSVidoToUEQb4VdHvEYJGU%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAApp4ce7fjLUdCexwzDXULhfLO5XlLGks5sNuZJgaJpZM4OEpT5&data=02%7C01%7Cpbatum%40microsoft.com%7C42053473139e4b070e1108d4ca6bedb3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636356012282976274&sdata=aimzuCCGiiQwl%2BfR6iyEXhX%2B%2Fvcoq9T9fMbzw9%2B9pZo%3D&reserved=0.
hi bily,
Due to this issue (I opened it under my old github user) I've moved my code to a azure app service with docker.
I've open-sourced a sample api for python with flask, docker and sklrean, it might help...
https://github.com/Soluto/python-flask-sklearn-docker-template
or move to AWS lambdas :-) I just like azure because it is simpler. deployment and security on AWS is hell
Any updates?
There is some work in progress on an implementation of python support for functions V2 that does not have the severe performance problems of the experimental support in V1, and you can track the progress of that here:
https://github.com/Azure/azure-functions-python-worker/
Most helpful comment
There is some work in progress on an implementation of python support for functions V2 that does not have the severe performance problems of the experimental support in V1, and you can track the progress of that here:
https://github.com/Azure/azure-functions-python-worker/