Skip to content

Commit 6e8cc43

Browse files
Add compatible versions for 0.6, warn for whitespace in conda and strip if present
1 parent ffa6bc9 commit 6e8cc43

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/main/java/qupath/ext/djl/ui/LaunchScriptCommand.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package qupath.ext.djl.ui;
1818

1919
import ai.djl.engine.Engine;
20+
import java.nio.file.Path;
2021
import javafx.beans.property.SimpleStringProperty;
2122
import javafx.beans.property.StringProperty;
2223
import javafx.geometry.Insets;
@@ -189,17 +190,15 @@ private DjlLaunchParamsFx() {
189190

190191
public List<String> getPyTorchVersions() {
191192
var version = Engine.getDjlVersion();
192-
switch (version) {
193-
case "0.23.0":
194-
case "0.24.0":
195-
case "0.25.0":
196-
return Arrays.asList("Default", "2.0.1", "1.13.1", "1.12.1");
197-
case "0.26.0":
198-
return Arrays.asList("Default", "2.1.1", "2.0.1", "1.13.1");
199-
default:
193+
return switch (version) {
194+
case "0.23.0", "0.24.0", "0.25.0" -> Arrays.asList("Default", "2.0.1", "1.13.1", "1.12.1");
195+
case "0.26.0" -> Arrays.asList("Default", "2.1.1", "2.0.1", "1.13.1");
196+
case "0.32.0" -> Arrays.asList("Default", "2.5.1", "2.3.1", "2.1.2", "1.13.1");
197+
default -> {
200198
// Exception here should be caught by the caller & a text field used as a prompt
201199
throw new RuntimeException("Unknown DJL version: " + version);
202-
}
200+
}
201+
};
203202
}
204203

205204
}
@@ -222,6 +221,10 @@ public static String createLaunchScript(Map<String, String> params) {
222221

223222
// Set path variable from conda, if possible
224223
String condaPath = params.remove(KEY_CONDA_PATH);
224+
if (condaPath.startsWith(" ") || condaPath.endsWith(" ")) {
225+
logger.warn("Conda path has leading or trailing white space; this is probably a mistake (removing)");
226+
condaPath = condaPath.strip();
227+
}
225228
String pathVariable = null;
226229
String cudnnPath = null;
227230
if (condaPath != null && !condaPath.isEmpty()) {
@@ -230,6 +233,11 @@ public static String createLaunchScript(Map<String, String> params) {
230233
paths.add(condaPath + File.separator + "bin");
231234
paths.add(condaPath + File.separator + "lib");
232235
paths.add(condaPath + File.separator + "lib" + File.separator + "site-packages" + File.separator + "torch" + File.separator + "lib");
236+
for (String path: paths) {
237+
if (!Files.exists(Path.of(path))) {
238+
logger.warn("Path {} does not exist", path);
239+
}
240+
}
233241
var dirCudnn = findCuDnnDir(new File(condaPath));
234242
if (dirCudnn != null)
235243
cudnnPath = dirCudnn.getAbsolutePath();

0 commit comments

Comments
 (0)