Skip to content

Commit

Permalink
Fix overlapping conda lock file (#5540)
Browse files Browse the repository at this point in the history
Signed-off-by: jorgee <[email protected]>
  • Loading branch information
jorgee authored and pditommaso committed Nov 27, 2024
1 parent eb85cda commit df66dea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ class CondaCache {
* @return the conda environment prefix {@link Path}
*/
@PackageScope
Path createLocalCondaEnv(String condaEnv) {
final prefixPath = condaPrefixPath(condaEnv)
Path createLocalCondaEnv(String condaEnv, Path prefixPath) {

if( prefixPath.isDirectory() ) {
log.debug "${binaryName} found local env for environment=$condaEnv; path=$prefixPath"
return prefixPath
Expand Down Expand Up @@ -360,17 +360,18 @@ class CondaCache {
*/
@PackageScope
DataflowVariable<Path> getLazyImagePath(String condaEnv) {

if( condaEnv in condaPrefixPaths ) {
final prefixPath = condaPrefixPath(condaEnv)
final condaEnvPath = prefixPath.toString()
if( condaEnvPath in condaPrefixPaths ) {
log.trace "${binaryName} found local environment `$condaEnv`"
return condaPrefixPaths[condaEnv]
return condaPrefixPaths[condaEnvPath]
}

synchronized (condaPrefixPaths) {
def result = condaPrefixPaths[condaEnv]
def result = condaPrefixPaths[condaEnvPath]
if( result == null ) {
result = new LazyDataflowVariable<Path>({ createLocalCondaEnv(condaEnv) })
condaPrefixPaths[condaEnv] = result
result = new LazyDataflowVariable<Path>({ createLocalCondaEnv(condaEnv, prefixPath) })
condaPrefixPaths[condaEnvPath] = result
}
else {
log.trace "${binaryName} found local cache for environment `$condaEnv` (2)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ class CondaCacheTest extends Specification {

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

when:
// the prefix directory exists ==> no mamba command is executed
def result = cache.createLocalCondaEnv(ENV)
def result = cache.createLocalCondaEnv(ENV, PREFIX)
then:
1 * cache.condaPrefixPath(ENV) >> PREFIX
0 * cache.isYamlFilePath(ENV)
0 * cache.runCommand(_)
result == PREFIX
Expand All @@ -251,9 +249,8 @@ class CondaCacheTest extends Specification {

when:
// the prefix directory exists ==> no mamba command is executed
def result = cache.createLocalCondaEnv(ENV)
def result = cache.createLocalCondaEnv(ENV, PREFIX)
then:
1 * cache.condaPrefixPath(ENV) >> PREFIX
0 * cache.isYamlFilePath(ENV)
0 * cache.runCommand(_)
result == PREFIX
Expand All @@ -278,9 +275,8 @@ class CondaCacheTest extends Specification {

when:
// the prefix directory exists ==> no mamba command is executed
def result = cache.createLocalCondaEnv(ENV)
def result = cache.createLocalCondaEnv(ENV, PREFIX)
then:
1 * cache.condaPrefixPath(ENV) >> PREFIX
0 * cache.isYamlFilePath(ENV)
0 * cache.runCommand(_)
result == PREFIX
Expand All @@ -304,9 +300,8 @@ class CondaCacheTest extends Specification {

when:
// the prefix directory exists ==> no mamba command is executed
def result = cache.createLocalCondaEnv(ENV)
def result = cache.createLocalCondaEnv(ENV, PREFIX)
then:
1 * cache.condaPrefixPath(ENV) >> PREFIX
0 * cache.isYamlFilePath(ENV)
0 * cache.runCommand(_)
result == PREFIX
Expand Down

0 comments on commit df66dea

Please sign in to comment.