Stability-AI / stability-sdk

SDK for interacting with stability.ai APIs (e.g. stable diffusion inference)
https://platform.stability.ai/
MIT License
2.43k stars 340 forks source link

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

Open polavishnu4444 opened 2 years ago

polavishnu4444 commented 2 years ago

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'])

dmarx commented 2 years ago

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.

chigozienri commented 2 years ago

@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/stability-sdk.git@cnri.dotenv-optional) and see if it works in your setup?