Let us consider I have three files in 3 different folders.
folder-1:
|-file-1.py
folder-2:
|-file-2.py
folder-3:
|-file-main.py
file-1 contains a function:
def foo(*, nr1, nr2):
return nr1 + nr2
file 2 contains a function:
def goo(*, nr1, nr2):
return nr1 - nr2
file-3 is the main file that requires a function to be provided as an argument.
def main(func):
inputs=dict(nr1=2, nr2=5) # reading inputs from cloud
return func(**inputs)
if __name__ == "__main__":
main(sys.argv[1])
dockerfile contains an entrypoint as below:
enntrypoint["python", "-m", "folder-3.file-main", "folder-2.file-1.foo"]
The question is: How to pass the function as an argument through the entry point of the docker file and to be called inside the main function?
errors thrown:
`TypeError: 'str' object is not callable
I tried using eval
across the sys.srgv[1]
and then the error is thrown for folder_1
is not defined.
if __name__ == "__main__":
main(eval(sys.argv[1])) # to remove the string formatted return of sys.argv
What am I missing here? I would like to pass the required function as an argument.