stability-sdk icon indicating copy to clipboard operation
stability-sdk copied to clipboard

There is a issue with python dotenv restricting Azure Function usage with this SDK

Open polavishnu4444 opened this issue 3 years ago • 2 comments

Stability SDK is relying on python-dotenv package which is having or causing issue with its implementation as mentioned in the dotenv github issues here.

It would be helpful to overcome and fix this for the SDK.

Main issue:

Result: Failure Exception: ModuleNotFoundError: No module named 'main' Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 448, in _handle__invocation_request call_result = await self._loop.run_in_executor( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 691, in _run_sync_func return ExtensionManager.get_sync_invocation_wrapper(context, File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py", line 215, in _raw_invocation_wrapper result = function(**args) File "/home/site/wwwroot/HttpTrigger_jetson_01_test/init.py", line 43, in main container_client = adls.get_container_client(place_name) File "/home/site/wwwroot/adls.py", line 14, in get_container_client dotenv.load_dotenv() File "/home/site/wwwroot/.python_packages/lib/site-packages/dotenv/main.py", line 322, in load_dotenv dotenv_path = find_dotenv() File "/home/site/wwwroot/.python_packages/lib/site-packages/dotenv/main.py", line 275, in find_dotenv if usecwd or _is_interactive() or getattr(sys, 'frozen', False): File "/home/site/wwwroot/.python_packages/lib/site-packages/dotenv/main.py", line 272, in _is_interactive main = import('main', None, None, fromlist=['file'])

polavishnu4444 avatar Sep 01 '22 09:09 polavishnu4444

Thanks for reporting this! I poked around and I suspect what's going on is a bug in the azure functions python runtime, which is being fixed presently: https://github.com/Azure/azure-functions-python-worker/issues/1094

that said: I'm pretty sure dotenv isn't a critical dependency, so we may address it on our side as well.

dmarx avatar Sep 08 '22 02:09 dmarx

@polavishnu4444 #66 may solve this, but I don't have an Azure setup to test - could you check out cnri.dotenv-optional (or you can pip install git+https://github.com/Stability-AI/[email protected]) and see if it works in your setup?

chigozienri avatar Sep 28 '22 12:09 chigozienri