Awesome! Am I to understand that this PR being mer...
# scdownstream
e
Awesome! Am I to understand that this PR being merged means that we should now have cross-platform stability of testing, and I can update my own PRs with new snapshot runs after merging this in?
n
In theory yes, but I again had some issues in #270 with decontx and scar in the ambient correction workflow, as well as with seurat integration The decontx and seurat issues are most likely associated with the changes in the PR, scar is a bit weird but also not super unexpected (the module tests were already not testing hash stability, but the subworkflow tests did, so I will just make the subworkflow tests more lenient)
But I would appreciate if you could run all tests on your hardware and tell me if there are any remaining issues, as I am now very familiar with what can go wrong
e
Okay, I'll pull in the latest changes and see how it goes and get back to you
Okay, all the R scripts started failing with
Fatal error: cannot create 'R_TempDir'
on my Mac when they had worked just fine before. Any particular thing that changed in the images that might have affected this that you can think of?
Will try on my HPC as well
n
What are you using for containerization?
e
Docker
n
That's unexpected because the PR only contained changes concerning the environments of python processes and the tests, nothing regarding R scripts
e
Huh... Was anything changed with regards to file permissions or somesuch?
Okay, I think I've found a fix, which is to set the TMPDIR environment variable using
containerOptions
in each R module in
conf/modules.config
. It seems that the
/tmp
dir is owned by root, while the commonly used
runOptions
include linking host user inside the container, which makes
/tmp
unwritable by the user - I assume this is only because of the emulation happening on Apple Silicon. What made it harder to diagnose was that R for some reason tries to set the tempdir before even finishing initialising itself, meaning that any code I added to the template file was never run (so you can't set the tempdir inside the R template, since it'll never get the chance to run). Since the modules aren't using the
script:
directive we can't specifically export a new TMPDIR environment variable there either, while setting it in the module-specific options. Would love a prettier solution if you have one 😅 I'll make the rest of the modules with this change as well to make sure it works across the board.
n
Since the modules aren't using the
script:
directive we can't specifically export a new TMPDIR environment variable there either
I don't think this is true, all the modules in the pipeline use the
script
directive (in combination with a template). An example of how to set env variables properly in python scripts is here
e
Your example shows how to set environment variables inside Python, which works just fine because of how Python uses those variables, but this does not work for R, where the tempdir is set before any script is run.
Though I can certainly be wrong with not being able to set environment variables in the script part before using the template - do you know how to do this with Groovy?
n
I think the nextflow beforeScript is made for this
🎓 1
e
Oh, cool, didn't know about that! I try it out and see
👍 1
Though thinking about it, I wonder what's the most appropriate... The issue here is specifically using containers, so setting
containerOptions
could be more apt. What do you think?
Also, using
beforeScript 'export TMPDIR=.'
doesn't seem to work
n
Hmm I think it's generally good if all that the processes are doing stays within the workdir, even though theoretically outside locations are writable So I think it's fair to change the tempdir to a place within the workdir even in situations where this would not be technically necessary
Maybe it does not work because of this
When the process is containerized (using the container directive), the
beforeScript
will be executed in the container only if the executor is container-native (e.g. cloud batch executors, Kubernetes). Otherwise, the
beforeScript
will be executed outside the container.
e
Right, so then I'll stick with the container options solution, though I do agree with your point regarding placing the tempdir inside the working directory
n
If you implement it like this, do you think it will be compatible across all container execution options? From what I get in the docs, it will be applied to whatever is used (docker/singularity/apptainer, or one of the more exotic ones) and I am not sure the way this needs to be written is cross-compatible
e
Well, I would think that since the
containerOptions
is a Nextflow thing it will indeed be applied to all container technologies, but since this is just setting an environment variable to point to the working directory, I'd guess that it was fine? I'm not a proper software engineer though, so if you have other ideas I'm happy for another solution.
This is what it is currently:
containerOptions = '--env TMPDIR=.'
inside the affected modules in
conf/modules.config
n
What I'm a bit scared of is that some containerization engines that I am super unfamiliar with (Sarus, Charliecloud, whatever) could have a different convention for setting env variables and thus fail with this setup
e
That's fair enough, though wouldn't that the be an issue on the Nextflow side rather than the pipeline itself?
n
What we write here is passed to the container engine as-is, nextflow does not play an active role in this, it just passes it on. So I rather think that containerOptions should be something that users should use for specific runtime environments, but as a pipeline developer it might be tricky to use cleanly
But I am sure someone else has to have encountered this before
e
Okay, how would you like to proceed? Having this (or another equivalent fix) would be greatly beneficial to myself and my NBIS colleagues, since it allows us to run the pipeline on our personal computers
Would could keep the fix as-is for now and think about something else when higher priority items are cleared, for example
n
I will try if I can reproduce it on my work mac now, and then look into details after work
e
Sounds good!
n
Can you give me a single example module that I can use for reproduction?
e
celldex/fetchreferences is pretty light
n
I can't reproduce it🥲 I am on an M4 macbook air
e
Haha, of course
I have nf-test 0.9.5, but would not expect that to make a difference
n
Agreed, but I can try
Also passes
e
And I tested on the
dev
branch, same error for me
n
Hmm
Any organization- or user-level config that might interfere?
e
Nope, nothing like that. Though I nuked all my downloaded images just to test, and wouldn't you know it, it works now without the fix! I have no clue what's going on here 😂
Sorry for wasting your time 😅
n
Wow ok xD Would not have thought of this😅
No problem, but good it works now
Would still like to know if all the tests pass in your setup
e
It has happened before with emulation... Don't get me wrong, I like how most things "just work" on the Mac, but with all the changes happening with newer packages in sc/spatial fields having emulation issues...
Yes, I've been running on the HPC in parallell, but it takes some time (I can't parallelise there with nf-test), so we'll see, but I'll run locally as well
Seriously considering just getting a Linux machine at some point
n
I like the apple hardware a lot in general, but yes situations like this are super annoying (although I am not 100% sure this issue was apple-related) For me the mac is just an entrypoint to linux servers, and it does quite a good job at this However I can't run anything substantial on it, as I only got 250GB of disk space and it is constantly full This requires of course to have access to some properly useful linux server
e
No, there's also the whole "between the monitor and chair" issue possibility 😂
The HPCs we have access to are... not ideal, let's say, so I actually got my current laptop specifically to be able to run almost all analyses I do locally (which is fairly common now where I work), so I' ve got 1 TB of storage and 64 GB of RAM in an M2 MacBookPro.
And I agree, the Apple hardware is hard to beat - were I to get a Linux machine I'm fully expecting a downgrade in various areas