pallets / click

Python composable command line interface toolkit
https://click.palletsprojects.com
BSD 3-Clause "New" or "Revised" License
15.76k stars 1.4k forks source link

[BUG] utils.echo fails import with Azure Function Python Worker #2066

Closed tyler555g closed 3 years ago

tyler555g commented 3 years ago
  1. Download repo and development requirements from ReadMe.
  2. Initialize .venv with python 3.9.6
  3. Initialize debugging session in vscode with F5
  4. Get error

    [2021-08-30T14:16:09.495Z] Worker failed to function id 5cfd6c05-6b2d-46e8-b09f-6c5c8a0ac887. [2021-08-30T14:16:09.496Z] Result: Failure Exception: KeyError: 'main' ... File "C:\Users\tyler\Documents\Projects\Personal\AzureDurableFunctionsExample\func-addressparser-dev.venv\lib\site-packages\click\utils.py", line 487, in path: t.Optional[str] = None, _main: ModuleType = sys.modules["main"]

    Expected behavior

    Provide a description of the expected behavior.

Expect debugging to continue successfully.

Actual behavior

Provide a description of the actual behavior observed.

Does not work.

Contents of the requirements.txt file:

Provide the requirements.txt file to help us find out module related issues.
azure-functions
azure-functions-durable
usaddress-scourgify

Related information

Provide any related information

https://github.com/tyler555g/AzureDurableFunctionsExample https://github.com/Azure/azure-functions-python-worker/issues/887

# __init__.py

def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    return "Done"
azure-functions==1.0.0a4
azure-functions-worker==1.0.0a4
grpcio==1.14.2
grpcio-tools==1.14.2
protobuf==3.6.1
six==1.11.0

Full stack trace:

[2021-09-13T12:49:20.197Z] Worker failed to function id 1a9bb874-6433-415f-97b0-9c345fc49929. [2021-09-13T12:49:20.198Z] Result: Failure Exception: KeyError: 'main' Stack: File "C:\Users\tyler\AppData\Roaming\nvm\v16.8.0\node_modules\azure-functions-core-tools\bin\workers\python\3.9/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 301, in _handlefunction_load_request func = loader.load_function( File "C:\Users\tyler\AppData\Roaming\nvm\v16.8.0\node_modules\azure-functions-core-tools\bin\workers\python\3.9/WINDOWS/X64\azure_functions_worker\utils\wrappers.py", line 40, in call return func(*args, **kwargs) File "C:\Users\tyler\AppData\Roaming\nvm\v16.8.0\node_modules\azure-functions-core-tools\bin\workers\python\3.9/WINDOWS/X64\azure_functions_worker\loader.py", line 83, in load_function mod = importlib.import_module(fullmodname) File "C:\Users\tyler\AppData\Local\Programs\Python\Python39\lib\importlib__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 850, in exec_module File "", line 228, in _call_with_frames_removed File "C:\Users\tyler\Documents\Projects\Personal\AzureDurableFunctionsExample\func-addressparser-dev\ParseAddressActivity__init.py", line 11, in from scourgify import normalize_address_record File "C:\Users\tyler\Documents\Projects\Personal\AzureDurableFunctionsExample\func-addressparser-dev.venv\lib\site-packages\scourgify\init.py", line 9, in from scourgify.normalize import ( File "C:\Users\tyler\Documents\Projects\Personal\AzureDurableFunctionsExample\func-addressparser-dev.venv\lib\site-packages\scourgify\normalize.py", line 33, in import geocoder File "C:\Users\tyler\Documents\Projects\Personal\AzureDurableFunctionsExample\func-addressparser-dev.venv\lib\site-packages\geocoder\init.py", line 55, in from geocoder.cli import cli # noqa File "C:\Users\tyler\Documents\Projects\Personal\AzureDurableFunctionsExample\func-addressparser-dev.venv\lib\site-packages\geocoder\cli.py", line 6, in import click File "C:\Users\tyler\Documents\Projects\Personal\AzureDurableFunctionsExample\func-addressparser-dev.venv\lib\site-packages\click\init__.py", line 7, in from .core import Argument as Argument File "C:\Users\tyler\Documents\Projects\Personal\AzureDurableFunctionsExample\func-addressparser-dev.venv\lib\site-packages\click\core.py", line 16, in from . import types File "C:\Users\tyler\Documents\Projects\Personal\AzureDurableFunctionsExample\func-addressparser-dev.venv\lib\site-packages\click\types.py", line 11, in from .exceptions import BadParameter File "C:\Users\tyler\Documents\Projects\Personal\AzureDurableFunctionsExample\func-addressparser-dev.venv\lib\site-packages\click\exceptions.py", line 7, in from .utils import echo File "C:\Users\tyler\Documents\Projects\Personal\AzureDurableFunctionsExample\func-addressparser-dev.venv\lib\site-packages\click\utils.py", line 487, in path: t.Optional[str] = None, _main: ModuleType = sys.modules["main__"]

davidism commented 3 years ago

This is something you'll need to work with Microsoft to debug and address.