Skip to content

Commit

Permalink
Fix overlapping in conda enviroment creation when equivalent but diff…
Browse files Browse the repository at this point in the history
…erent relative paths

Signed-off-by: jorgee <[email protected]>
  • Loading branch information
jorgee committed Nov 25, 2024
1 parent b65fc66 commit 5462d7a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
12 changes: 10 additions & 2 deletions modules/nextflow/src/main/groovy/nextflow/conda/CondaCache.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ class CondaCache {
* The {@link DataflowVariable} which hold (and pull) the local image file
*/
@PackageScope
DataflowVariable<Path> getLazyImagePath(String condaEnv) {

DataflowVariable<Path> getLazyImagePath(String rawCondaEnv) {
def condaEnv = normalizeCondaEnv(rawCondaEnv)
if( condaEnv in condaPrefixPaths ) {
log.trace "${binaryName} found local environment `$condaEnv`"
return condaPrefixPaths[condaEnv]
Expand Down Expand Up @@ -399,4 +399,12 @@ class CondaCache {
return result
}

String normalizeCondaEnv(String rawCondaEnv) {
// Check if it's a path (as in getPrefixPath)
if( !isYamlUriPath(rawCondaEnv) && ( isYamlFilePath(rawCondaEnv) || isTextFilePath(rawCondaEnv) || rawCondaEnv.contains('/') ) ) {
final path = rawCondaEnv as Path
return path.toAbsolutePath().normalize().toString()
}
return rawCondaEnv
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -569,4 +569,21 @@ class CondaCacheTest extends Specification {
cleanup:
folder?.deleteDir()
}

def 'should normalize paths' () {

given:
def cache = new CondaCache()

expect:
cache.normalizeCondaEnv(RAW_CONDA_ENV) == EXPECTED

where:
RAW_CONDA_ENV | EXPECTED
'bwa=1.1.1' | 'bwa=1.1.1'
'http://url.com/path/env.yml' | 'http://url.com/path/env.yml'
'/path/to/../directory' | '/path/directory'
'/path/./to/file.txt' | '/path/to/file.txt'
'/path/./to/file.yml' | '/path/to/file.yml'
}
}

0 comments on commit 5462d7a

Please sign in to comment.