From f65f65d3af2a876c14901f73c75e9802c6bdaea8 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 15 Oct 2024 13:19:05 +0200 Subject: [PATCH] imporve the tracking to aoid race condition --- .../modelrunner/bioimageio/download/DownloadTracker.java | 3 +++ .../modelrunner/versionmanagement/DeepLearningVersion.java | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/bioimage/modelrunner/bioimageio/download/DownloadTracker.java b/src/main/java/io/bioimage/modelrunner/bioimageio/download/DownloadTracker.java index 2f0b0004..a1a67691 100644 --- a/src/main/java/io/bioimage/modelrunner/bioimageio/download/DownloadTracker.java +++ b/src/main/java/io/bioimage/modelrunner/bioimageio/download/DownloadTracker.java @@ -153,6 +153,7 @@ private DownloadTracker(String folder, TwoParameterConsumer cons this.consumer = consumer; this.remainingFiles = sizeFiles.keySet().stream().map(i -> new File(i)).collect(Collectors.toList()); this.downloadThread = thread; + this.consumer.accept(TOTAL_PROGRESS_KEY, 0.0); } @@ -526,6 +527,8 @@ public static void printProgress(Thread downloadThread, continue; } for (String kk : new String[] {select, DownloadTracker.TOTAL_PROGRESS_KEY}) { + if (kk.endsWith(EngineInstall.NBYTES_SUFFIX)) + continue; int nProgressBar = (int) (consumer.get().get(kk) * n); String progressStr = new File(kk).getName() + ": [" + ogProgressStr.substring(0, nProgressBar) + ogRemainingStr.substring(nProgressBar) diff --git a/src/main/java/io/bioimage/modelrunner/versionmanagement/DeepLearningVersion.java b/src/main/java/io/bioimage/modelrunner/versionmanagement/DeepLearningVersion.java index 719be511..004e2776 100644 --- a/src/main/java/io/bioimage/modelrunner/versionmanagement/DeepLearningVersion.java +++ b/src/main/java/io/bioimage/modelrunner/versionmanagement/DeepLearningVersion.java @@ -67,9 +67,6 @@ public class DeepLearningVersion * and implies that the user has manipulated wrongly the engines */ public static DeepLearningVersion fromFile(File engineDir) throws IOException, IllegalStateException { - if (!engineDir.isDirectory()) - throw new IOException("The file '" + engineDir.getAbsolutePath() + "' does not correspond " - + "to an existing directory."); DeepLearningVersion dlVersion = new DeepLearningVersion(); dlVersion.engineName = engineDir.getName(); dlVersion.allEnginesDir = engineDir.getParentFile().getAbsolutePath();