Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
335 stars 103 forks source link

remote build VS code issue - ModuleNotFoundError: No module named 'teradatasqlalchemy.dialect #1299

Closed Sagarthore11 closed 1 year ago

Sagarthore11 commented 1 year ago

Error : Result: Failure Exception: ModuleNotFoundError: No module named 'teradatasqlalchemy.dialect'

Hello Team,

Please refer the requirement.txt and init.py for reference and to reproduce issue

init.py

import logging from sqlalchemy import create_engine import azure.functions as func

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

teradata_client = create_engine("teradatasql://username:passwd@server_name")
logging.info('after teradata')

name = req.params.get('name')
if not name:
    try:
        req_body = req.get_json()
    except ValueError:
        pass
    else:
        name = req_body.get('name')

if name:
    return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
else:
    return func.HttpResponse(
         "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
         status_code=200
    )

requirement.txt

azure-functions teradatasqlalchemy

Deployed the above code using vs code in python function app version ~4 and receiving an Failure Exception: ModuleNotFoundError: No module named 'teradatasqlalchemy.dialect' . even though same code is working fine on local

=> Also noticed that adding there is an issue with remote build only I believe => Even tried to do the pip install explicitly on kudu site but no luck

Can you please help me with this? You can simply create the test function app, create the sample http trigger, add the code, and reproduce.

Thanks

Sagarthore11 commented 1 year ago

Hello Team any help would be appreciated

bhagyshricompany commented 1 year ago

Thanks for reporting will check and update you.

Sagarthore11 commented 1 year ago

@bhagyshricompany Thank you for looking into it. Please feel free to let me know if you need any information from me.

Sagarthore11 commented 1 year ago

Any update on it please ?

bhagyshricompany commented 1 year ago

investigating on it will update once done

Sagarthore11 commented 1 year ago

@bhagyshricompany are you able to reproduce the issue ?

YunchuWang commented 1 year ago

tried repro the code and i got this error both running in a simple python file or function app in local:

image image

in my .venv, teradatasql is installed

image

Look like a sqlalchemy issue

Sagarthore11 commented 1 year ago

Hello @YunchuWang for looking into it. But we are not seeing any issue in vs code local. Please refer the below screen shot for the same

image

Sagarthore11 commented 1 year ago

@YunchuWang could you please try once by doing pip intsall in vs code

pip3 install -r requirements.txt

YunchuWang commented 1 year ago

@Sagarthore11 thanks for clarification, i am able to repro this error. As you mentioned right seem an issue with remote build, I downloaded the deployed code and i found it seems an issue with remote build not building this package teradatasqlalchemy properly. In my screenshot you can see all the package module files are missing.

image

while building with local dependencies works, (func azure functionapp publish --build-native-deps)

image image

Will try if i can check the remote build logs and let you know, meantime you can try local build

Sagarthore11 commented 1 year ago

Hello @YunchuWang ,

Thank you so much for looking into it and helping.

Yes I tried with the local build and it's working.

Also, after adding ENABLE_ORYX_BUILD = false and SCM_DO_BUILD_DURING_DEPLOYMENT = 0 in the configuration setting of function app explicitly when I am deploying using GitHub workflow action, it's working.

Ask: We would like to know if there is only one issue with the remote build?

Thank you so much for your help

Sagarthore11 commented 1 year ago

Hello @YunchuWang

Thanks for helping into it.

Did you get chance to check the remote build logs?

Thanks

Sagarthore11 commented 1 year ago

Hello @YunchuWang ,

Do you have any update on it please ?

Thanks

Sagarthore11 commented 1 year ago

Hello @YunchuWang and Team,

Greetings!!!

Thank you so much for helping us. Do you have any update on it please?

YunchuWang commented 1 year ago

@Sagarthore11 Hi Sagarthore, sorry for delay. I was busy with other work past few days and just got a chance. I checked the oxry build log but cant find any err logs related https://statics.teams.cdn.office.net/evergreen-assets/safelinks/1/atp-safelinks.html. Will try build with oryx locally to see why this package is not installed properly and let you know soon.

Sagarthore11 commented 1 year ago

@YunchuWang Thank you for the response and help.

I will wait for your update. Thanks

Sagarthore11 commented 1 year ago

Hello @YunchuWang ,

Any luck on it please ?

Thanks

Sagarthore11 commented 1 year ago

Hello @YunchuWang ,

Thanks for helping on it

Any help on it please?

YunchuWang commented 1 year ago

@Sagarthore11 Hi Saga, sorry. I tried oyrx build(the same way how remote build builds the packages) and see the same err

image

. This is first time we observe issue like this, thanks for bringing it up. I contacted oyrx team internally for further investigation on this matter and will let you know once they give an update.

Sagarthore11 commented 1 year ago

Thanks a lot @YunchuWang for helping us on it 👍

YunchuWang commented 1 year ago

@Sagarthore11 No problem, a heads up, oyrx team identified this is a known issue which got fixed in https://github.com/microsoft/Oryx/releases/tag/20230403.1 by setting app setting ORYX_DISABLE_PIP_UPGRADE to true then publish with remote build. image

Remote build right now uses Oryx Version: 0.2.20230210.1. I will let you know when remote build will release with oyrx 20230403.1

Sagarthore11 commented 1 year ago

Thanks a lot once again @YunchuWang for your help.

bhagyshricompany commented 1 year ago

hope now resolved query hence its closing

microsoft-github-policy-service[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.