Skip to content

Commit

Permalink
keep improving the mamba deps manager and addd TODO for bigger than and
Browse files Browse the repository at this point in the history
smaller than versions
  • Loading branch information
carlosuc3m committed Sep 9, 2024
1 parent 60eb91b commit 996e2e1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/java/io/bioimage/modelrunner/apposed/appose/Mamba.java
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,7 @@ public List<String> checkUninstalledDependenciesInEnv(String envName, List<Stri

/**
* Checks whether a package is installed in the wanted environment.
* TODO improve the logic for bigger or smaller versions
*
* @param envName
* The name of the environment of interest. Should be one of the environments of the current Mamba instance.
Expand Down Expand Up @@ -1381,26 +1382,26 @@ public boolean checkDependencyInEnv(String envName, String dependency) throws Ma
int lowInd = dependency.indexOf("<");
int minInd = Math.min(Math.min(commaInd, lowInd), highInd);
String packName = dependency.substring(0, minInd).trim();
String minV = dependency.substring(lowInd + 1, lowInd < highInd ? commaInd : dependency.length());
String maxV = dependency.substring(highInd + 1, lowInd < highInd ? dependency.length() : commaInd);
String maxV = dependency.substring(lowInd + 1, lowInd < highInd ? commaInd : dependency.length());
String minV = dependency.substring(highInd + 2, lowInd < highInd ? dependency.length() : commaInd);
return checkDependencyInEnv(envName, packName, minV, null, false) && checkDependencyInEnv(envName, packName, null, maxV, true);
} else if (dependency.contains(">") && dependency.contains("<=") && dependency.contains(",")) {
int commaInd = dependency.indexOf(",");
int highInd = dependency.indexOf(">");
int lowInd = dependency.indexOf("<=");
int minInd = Math.min(Math.min(commaInd, lowInd), highInd);
String packName = dependency.substring(0, minInd).trim();
String minV = dependency.substring(lowInd + 1, lowInd < highInd ? commaInd : dependency.length());
String maxV = dependency.substring(highInd + 1, lowInd < highInd ? dependency.length() : commaInd);
String maxV = dependency.substring(lowInd + 2, lowInd < highInd ? commaInd : dependency.length());
String minV = dependency.substring(highInd + 1, lowInd < highInd ? dependency.length() : commaInd);
return checkDependencyInEnv(envName, packName, minV, null, true) && checkDependencyInEnv(envName, packName, null, maxV, false);
} else if (dependency.contains(">") && dependency.contains("<") && dependency.contains(",")) {
int commaInd = dependency.indexOf(",");
int highInd = dependency.indexOf(">");
int lowInd = dependency.indexOf("<");
int minInd = Math.min(Math.min(commaInd, lowInd), highInd);
String packName = dependency.substring(0, minInd).trim();
String minV = dependency.substring(lowInd + 1, lowInd < highInd ? commaInd : dependency.length());
String maxV = dependency.substring(highInd + 1, lowInd < highInd ? dependency.length() : commaInd);
String maxV = dependency.substring(lowInd + 1, lowInd < highInd ? commaInd : dependency.length());
String minV = dependency.substring(highInd + 1, lowInd < highInd ? dependency.length() : commaInd);
return checkDependencyInEnv(envName, packName, minV, maxV, true);
} else if (dependency.contains(">")) {
int ind = dependency.indexOf(">");
Expand Down

0 comments on commit 996e2e1

Please sign in to comment.