What is the current best practice for issues with ...
# modules
a
What is the current best practice for issues with
MPLCONFIGDIR
? Should modules be updated to set this, and if so what?
m
What's this about?
m
Several modules set this. Best practice is always to use a folder relative to the work directory.
m
Agreeing with the BP
a
So should make a modules PR if you discover this warning/error in a module then?
100 rainbow 1
j
matplotlib’s internal default is already relative to
$HOME
, which nextflow sets to the workdir. Did you find a situation where this doesn't work? https://matplotlib.org/stable/install/environment_variables_faq.html#envvar-MPLCONFIGDIR
a
Not sure where you have read that but Nextflow (
25.10.4
at least) definitely doesn’t explicitly set
$HOME
to the
workDir
. You can see which env vars it is setting for the
slurm
executor here (all other env is dropped, thus whatever the container sets for
$HOME
) is used:
Copy code
PATH="$PATH" ${TMP:+SINGULARITYENV_TMP="$TMP"} ${TMPDIR:+SINGULARITYENV_TMPDIR="$TMPDIR"} ${NXF_TASK_WORKDIR:+SINGULARITYENV_NXF_TASK_WORKDIR="$NXF_TASK_WORKDIR"} SINGULARITYENV_NXF_DEBUG="${NXF_DEBUG:=0}"
Now yes,
--no-home
should in theory mean that it’s set to something else but I do not see this in reality, the container correctly opens in the
PWD
but the
HOME
is set to the host home still. Even if I run
singularity exec
and explicitly have
HOME=$PWD
I still see that
$HOME
is my host
$HOME
in the container. Possibly there is some global option or configuration here which is causing this to be overridden? The only way so far I have been able to force it is by setting
APPTAINER_HOME
Also worth noting that it is actually running
apptainer
not
singularity
j
Oops, that's embarrassing. I am so used to dealing with an older nextflow pipeline that we're currently porting to nf-core, and that pipeline did explicitly set
$HOME
inside containers to the workdir. I realize now that nextflow itself doesn't touch
$HOME
. Sorry about that.
a
No I think this behaviour seems like a problem with my apptainer tbh but also something other people have experienced given that many modules do set MPLCONFIGDIR explicitly
j
What problems do you see? Are you getting the
Matplotlib created a temporary config/cache directory at...
message, or something worse?
a
Basically yeah it tries to create one in a random tmp location. Not always a problem the pattern which is widely used in nf-core to solve this works well to remove annoying warnings and reduce any issues
So I did some more digging on this because I was unsatisfied with my conclusion. Anyway turns out that retaining
HOME=$HOME
even with
--no-home
is a singularity/apptainer behaviour (a dumb one imo) and that possibly
nextflow
should consider using
--home $PWD
as well as
--no-home
?
j
I can see the reasoning for why apptainer chose their defaults (like the home behavior) given their target use case / audience. Environment isolation just wasn't the main goal. At least they do let you opt in to isolation though.