How do imports work with python scripts that live ...
# nostupidquestions
a
How do imports work with python scripts that live in
/template
. I have a process that runs a python script like this:
Copy code
script:
    template("script1.py")
script1.py
imports
script2.py
which lives inside the
template/
folder. Running the module produces an error about missing imports "ModuleNotFoundError"
a
Nextflow writes the template file to the workDir, so
script1.py
is created as a new file in the
workDir
with the variables interpreted. This means your import script doesn't exist unless you also stage it and make it available in the
PYTHONPATH
somehow.
p
That seems not correct - the template use here causes the
script
session to get the value of the evaluated template - but that ends up in
.command.sh
. It may be a better design to go with binaries rather than templates.
a
That seems not correct - the template use here causes the
script
session to get the value of the evaluated template - but that ends up in
.command.sh
.
Yes, sorry that's what I was trying (and failing) to say
It may be a better design to go with binaries rather than templates.
I think so - once your Python script is large enough to start using imports you're moving beyond a template.
a
Dang, I was hoping to keep the python files separate.