-
Notifications
You must be signed in to change notification settings - Fork 693
conda environments recreated on every run with Seqera Platform (-with-tower) #6140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@pditommaso why is the environment name based on the file name? I would argue it should be based on the file contents |
Don't have a precise memory, If I'm not wrong @jorgee work on this recently |
I remember it, there was a concurrency problem when a run was building the same conda environment several times. (#5485). I will review what I did. It could be related to this issue |
I have reviewed the issue that was creating the issue. Before #5489, the Conda cache map had the file conda environment file (url, path or string) as key and the |
@jorgee can you make a PR? then we'll see if we can avoid the race condition |
I have created a PR #6166 that works in both cases caching the environment when using the cachedir, and not raising the |
Testing the PR I have seen another issue. When I run two workflows at the same time that create the same conda environment. The workflow that starts first works well.
However, the workflow started a bit later detects and waits. But once the other has finished, it tries to create the environment again and it fails.
I think Nextflow shouldn't try to create the environment again. |
From our discussion today, we can avoid this race condition with the same approach we use for task directories -- increment the conda env hash until you find a directory that doesn't exist yet. Or if you can verify that the env already exists and isn't corrupted, re-use it. |
I have reviewed the code and it is easier. If there is an error, the environment directory is removed to avoid corrupted environments. I just needed to recheck the conda environment directory, and it solved the issue. |
Bug report
Expected behavior and actual behavior
When using the conda directive for a process to point to a environment yaml file, the environment gets re-created in the cache directory on every run when using Seqera Platform.
We would expect that nextflow would use the existing conda environment in the cache directory.
This change in behaviour is due to the conda cache changes here: #5489
Steps to reproduce the problem
conda.enabled = true
conda.cacheDir = /some/path/on/the/system
NXF_ASSETS
to a location in the work directory<basepath>/work/.nextflow/pipelines/<pipeline-id>
nextflow run <pipeline> ... -with-tower <seqera-url>
Program output
Environment
Additional context
My troubleshooting has lead me to understand that Seqera Platform generates a new directory for nextflow assets for every pipeline launch. The new directory is placed in the
work/.nextflow/pipelines
directory. This directory has a new name for every pipeline launch.In my case:
/home/user/<username>/nextflow/work/.nextflow/pipelines/f1f16f92/
- Run 1/home/user/<username>/nextflow/work/.nextflow/pipelines/ee5ee5c/
- Run 2This is problematic because the
CondaCache
class computes the cached environment directory based on a hash of the full path of the environment.yml file:nextflow/modules/nextflow/src/main/groovy/nextflow/conda/CondaCache.groovy
Lines 199 to 203 in a5b7a5d
/home/user/<username>/nextflow/work/.nextflow/pipelines/f1f16f92/my-pipeline/envs/environment.yml
becomesenv-fe50773488a5e0e5-535eefbee5734a58afed514fbe57635c
Essentially there is no way for two pipeline runs in Seqera to use a cached conda environment because they will never have the same name.
I see this as an incompatibility between the way Seqera Platform uses nextflow, so I'm not 100% sure where the fix should lie.
A current workaround may be to specify conda requirements within a string (instead of file):
An alternative way (within nextflow) may be to make the generation of the conda environment hash more configurable: (ie. only take path from project root).
The text was updated successfully, but these errors were encountered: