Skip to content

Commit 9248c04

Browse files
authored
Fix overlapping conda lock file (#5540)
Signed-off-by: jorgee <[email protected]>
1 parent b5e31bb commit 9248c04

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

modules/nextflow/src/main/groovy/nextflow/conda/CondaCache.groovy

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ class CondaCache {
251251
* @return the conda environment prefix {@link Path}
252252
*/
253253
@PackageScope
254-
Path createLocalCondaEnv(String condaEnv) {
255-
final prefixPath = condaPrefixPath(condaEnv)
254+
Path createLocalCondaEnv(String condaEnv, Path prefixPath) {
255+
256256
if( prefixPath.isDirectory() ) {
257257
log.debug "${binaryName} found local env for environment=$condaEnv; path=$prefixPath"
258258
return prefixPath
@@ -360,17 +360,18 @@ class CondaCache {
360360
*/
361361
@PackageScope
362362
DataflowVariable<Path> getLazyImagePath(String condaEnv) {
363-
364-
if( condaEnv in condaPrefixPaths ) {
363+
final prefixPath = condaPrefixPath(condaEnv)
364+
final condaEnvPath = prefixPath.toString()
365+
if( condaEnvPath in condaPrefixPaths ) {
365366
log.trace "${binaryName} found local environment `$condaEnv`"
366-
return condaPrefixPaths[condaEnv]
367+
return condaPrefixPaths[condaEnvPath]
367368
}
368369

369370
synchronized (condaPrefixPaths) {
370-
def result = condaPrefixPaths[condaEnv]
371+
def result = condaPrefixPaths[condaEnvPath]
371372
if( result == null ) {
372-
result = new LazyDataflowVariable<Path>({ createLocalCondaEnv(condaEnv) })
373-
condaPrefixPaths[condaEnv] = result
373+
result = new LazyDataflowVariable<Path>({ createLocalCondaEnv(condaEnv, prefixPath) })
374+
condaPrefixPaths[condaEnvPath] = result
374375
}
375376
else {
376377
log.trace "${binaryName} found local cache for environment `$condaEnv` (2)"

modules/nextflow/src/test/groovy/nextflow/conda/CondaCacheTest.groovy

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,8 @@ class CondaCacheTest extends Specification {
197197

198198
when:
199199
// the prefix directory exists ==> no conda command is executed
200-
def result = cache.createLocalCondaEnv(ENV)
200+
def result = cache.createLocalCondaEnv(ENV, PREFIX)
201201
then:
202-
1 * cache.condaPrefixPath(ENV) >> PREFIX
203202
0 * cache.isYamlFilePath(ENV)
204203
0 * cache.runCommand(_)
205204
result == PREFIX
@@ -224,9 +223,8 @@ class CondaCacheTest extends Specification {
224223

225224
when:
226225
// the prefix directory exists ==> no mamba command is executed
227-
def result = cache.createLocalCondaEnv(ENV)
226+
def result = cache.createLocalCondaEnv(ENV, PREFIX)
228227
then:
229-
1 * cache.condaPrefixPath(ENV) >> PREFIX
230228
0 * cache.isYamlFilePath(ENV)
231229
0 * cache.runCommand(_)
232230
result == PREFIX
@@ -251,9 +249,8 @@ class CondaCacheTest extends Specification {
251249

252250
when:
253251
// the prefix directory exists ==> no mamba command is executed
254-
def result = cache.createLocalCondaEnv(ENV)
252+
def result = cache.createLocalCondaEnv(ENV, PREFIX)
255253
then:
256-
1 * cache.condaPrefixPath(ENV) >> PREFIX
257254
0 * cache.isYamlFilePath(ENV)
258255
0 * cache.runCommand(_)
259256
result == PREFIX
@@ -278,9 +275,8 @@ class CondaCacheTest extends Specification {
278275

279276
when:
280277
// the prefix directory exists ==> no mamba command is executed
281-
def result = cache.createLocalCondaEnv(ENV)
278+
def result = cache.createLocalCondaEnv(ENV, PREFIX)
282279
then:
283-
1 * cache.condaPrefixPath(ENV) >> PREFIX
284280
0 * cache.isYamlFilePath(ENV)
285281
0 * cache.runCommand(_)
286282
result == PREFIX
@@ -304,9 +300,8 @@ class CondaCacheTest extends Specification {
304300

305301
when:
306302
// the prefix directory exists ==> no mamba command is executed
307-
def result = cache.createLocalCondaEnv(ENV)
303+
def result = cache.createLocalCondaEnv(ENV, PREFIX)
308304
then:
309-
1 * cache.condaPrefixPath(ENV) >> PREFIX
310305
0 * cache.isYamlFilePath(ENV)
311306
0 * cache.runCommand(_)
312307
result == PREFIX

0 commit comments

Comments
 (0)