-
Notifications
You must be signed in to change notification settings - Fork 107
Unable to import local module for the last few days #577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @dxkaufman, Thanks for reaching out. Seems like you're using a deprecated syntax for python import. Could you try using The proper structure:
|
Hi @Hazhzeng, I tried changing the root from Data Pipeline to DataPipeline or even sh-data-pipeline which is what I'm now calling it in my private github repo, but got the same error when I tried to refer to it using, for example, Thanks, |
I have been seeing the same issue lately. This work around fixed it:
for the following folder structure
However, I think this needs to be fixed on the product side -or- the documentation needs to be updated! |
@maknotavailable, thanks for that. I saw that work-around in a few posts, but I have it in my head (right or wrong) that once the function is in Azure it won't be able to use those path functions. I did something similar to what you did, but for my directory structure:
This is working locally, but I don't know for sure if it is going to work once it is in Azure. I guess I'm going to have to set up a dev app service so that I can deploy this there and make sure it works. I agree with you, though, this needs to be fixed (and I don't really think it should be a documentation update). This was working fine on October 31, and it really doesn't seem logical to me that it wouldn't work this way, based on the directory structure I described earlier:
At least I'm not longer dead in the water right now! Thank you! |
Thanks @maknotavailable for providing the work-around. @dxkaufman sorry for the inconvenience, because we are currently moving towards a new folder structure to support unit testing #469 by Brett Cannon (example folder structure here). We are actively working on a new design and a change in Core Tools to support this new folder structure. Since then, the linting should work as expected. |
@Hazhzeng, any idea when that Core Tools update will be ready? Microsoft support has suggested another work-around I may try, but I have to figure out whether I think it is going to work in Azure, just as I do with the one I am using now... |
@dxkaufman Currently we don't have an ETA on this feature. |
@Hazhzeng ..SharedCode doesn't work because the linter sees it as relative above the top level. I think I'm going to stick with the path insert work-around for now, but I'd appreciate it if you could let me know when the new feature is ready. Is there an issue I can follow? |
@dxkaufman, thanks for reminding, yes the issue is here #469. Feel free to follow up or make suggestions under it. |
Looks like importing module is solved now, if you have issues with linter please open another issue. Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
Environment data
"python.jediEnabled"
set to; more info #3977): python.jediEnabled not presentOther extensions:
Azure Account 0.8.7
Azure App Service 0.16.1
Azure Functions 0.20.0
Azure Storage 0.7.2
Azure Storage Explorer 0.1.2
Git History 0.4.6
SQL Server (mssql) 1.7.0
pip freeze output at the very end of the ticket.
I appear to have azure functions core tools 2.7.1846 installed (and
brew outdated
doesn't list it as needing to be updated)Expected behaviour
Code should execute while Azure attached. I also filed this in Stack Overflow the other day, as well as a ticket with Azure support - I'm stuck in the water and can't finalize my testing and upload to my production services. https://stackoverflow.com/questions/58842695/vscode-running-python-azure-function-locally-fails-with-modulenotfounderror I apologize if this isn't the right place for this post...
To be clear, this was working a couple of weeks ago. I can see, for example, that the entire data pipeline process ran successfully in my dev environment (i.e. in VSC on my desktop) on the morning of Thursday October 31, and I have literally not changed anything about my code since then, particularly with respect to the directory structure and module names.
Actual behaviour
On timer trigger or https trigger, while Azure attached, I receive this error message:
Steps to reproduce:
Relevant directory structure:
function.json contains the following:
etl.py includes the following imports:
import datetime
import logging
import azure.functions as func
import pandas as pd
import sqlalchemy
from SharedCode import FunctionApp
from SharedCode import APIs
etl.py also contains a variable & two functions that start with the same line:
Note that function main includes a lot of other code not shown here; Test only includes the two lines above.
Function main is called when executed while Azure attached and as soon as the timer fires, it generates the ModuleNotFoundError for the first "from SharedCode" import. I created function Test to be able to test for the same problem from the command line, which works:
Other than upgrading to VSC 1.40.0 and, I think, applying an azure core tools update, nothing has changed since I was last able to execute this properly while Azure attached.
I have also seen other posts in which the suggestion was to change the directory structure so that all the code was under an
__app__
directory, but that has not helped me. I changed to this directory structure:Then I changed the import to
from __app__.SharedCode import FunctionApp
, and now I get a different problem, which is that it doesn't register the function(s):No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
I also tried looking at the pvscbot code, but I can't find anything that seems different between it and mine that would cause this. It seems as if it is not finding the function.json file any longer, once I add the app directory.
Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)Complete output in Terminal for Task - host start:
Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
; turn on source maps to make any tracebacks be useful by runningEnable source map support for extension debugging
)pip freeze (after I upgraded some of the azure stuff):
The text was updated successfully, but these errors were encountered: