Reputation: 373
I'm trying to move a python function over to Google Cloud Functions, and I seem to be having an issue with aliases.
I have a module with the following in its init;
import tweetBot.generator, tweetBot.poster
# Add aliases when this module is imported
tweetBot.ebooksGen = tweetBot.generator.ebooksGen
tweetBot.genreGen = tweetBot.generator.genreGen
tweetBot.variantGen = tweetBot.generator.variantGen
tweetBot.postTweet = tweetBot.poster.postTweet
It's then imported with a simple import tweetBot
.
Running this on my local machine, it works perfectly and the function has absolutely no issues. The output is all correct, and everything is fine.
However, when running this using Google Cloud Functions, I get the following error;
AttributeError: module 'tweetBot' has no attribute 'genreGen'
This makes absolutely no sense to me, since it is absolutely defined in the import. In addition, I know this works because it's working absolutely fine on my local machine from the exact same repo.
https://github.com/Jademalo/JadeBots/tree/gcp-functions
Ignore the code being terrible, at the very least it works. I simply don't understand why I'm having an attribute error running it on Google Cloud when it's absolutely fine locally.
Thanks
EDIT: After replacing the calls for the aliases with the originals (such as tweetBot.generator.genreGen
, I'm still having the same issue;
File "/workspace/JadeBots.py", line 18, in postGenreDefining
tweetText, altGenreGameDebug, altGenreExtraDebug, gameText, genreText, altPostDebug = tweetBot.generator.genreGen(gameFile, genreFile, genreExtraFile, altPostFreq, altGenreGameFreq, altGenreExtraFreq)
AttributeError: module 'tweetBot' has no attribute 'generator'
Upvotes: 0
Views: 457
Reputation: 373
It seems that Google Cloud Functions isn't downloading the submodule when creating the function.
Downloading the source results in the submodule folder being empty, which explains why the arrtibute error is happening.
Upvotes: 2