You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am unable to import local function/classes into the method.
Details:
Say, I have a file say
some_file.py
def function(x):
return x*x
Now I am trying to import this file into the following file (They are located in the same folder):
file_to_be_deployed.py
def deploy_function(x):
from some_file import function # This is what I want to do
return function(x)
client.deploy('deploy_function',
deploy_function,
'Squares'
'x',
override=True
)
But This is throwing an error
Responding with status=500, message="Error querying function 'deploy_function'", info="{'uri': 'deploy_function', 'error': "ModuleNotFoundError : No module named 'some_file.py'", 'type': 'QueryFailed'}"
What I Tried:
So, I tried deploying the some_file.py onto the server, even then I got the same issue as above.
I looked up solutions for this, but none of them used another file as an import.
So, for now, I am writing the function(x) in every file I need it. But this defeats the purpose of me having a separate file for it.
file_to_be_deployed.py
def function(x):
return x*x # This is what I am doing now
def deploy_function(x):
return function(x)
client.deploy('deploy_function',
deploy_function,
'Squares'
'x',
override=True
)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Issue:
I am unable to import local function/classes into the method.
Details:
Say, I have a file say
Now I am trying to import this file into the following file (They are located in the same folder):
But This is throwing an error
Responding with status=500, message="Error querying function 'deploy_function'", info="{'uri': 'deploy_function', 'error': "ModuleNotFoundError : No module named 'some_file.py'", 'type': 'QueryFailed'}"What I Tried:
So, I tried deploying the
some_file.pyonto the server, even then I got the same issue as above.I looked up solutions for this, but none of them used another file as an import.
So, for now, I am writing the
function(x)in every file I need it. But this defeats the purpose of me having a separate file for it.What can I do to achieve it?
Beta Was this translation helpful? Give feedback.
All reactions