diff --git a/src/main/java/io/bioimage/modelrunner/bioimageio/description/weights/ModelWeight.java b/src/main/java/io/bioimage/modelrunner/bioimageio/description/weights/ModelWeight.java index a8ceee37..fcf40516 100644 --- a/src/main/java/io/bioimage/modelrunner/bioimageio/description/weights/ModelWeight.java +++ b/src/main/java/io/bioimage/modelrunner/bioimageio/description/weights/ModelWeight.java @@ -209,9 +209,9 @@ private Map addCpuOrGpu(Map suffixes){ List copiesOfVersion = new ArrayList(); try { InstalledEngines installed = InstalledEngines.buildEnginesFinder(); - List downloadedVersions = installed.getDownloadedPythonVersionsForEngine(engine); + List downloadedVersions = installed.getDownloadedPythonVersionsForFramework(engine); String executionVersion = VersionStringUtils.getMostCompatibleEngineVersion(trainingVersion, downloadedVersions, engine); - copiesOfVersion = installed.getDownloadedForEngine(engine) + copiesOfVersion = installed.getDownloadedForFramework(engine) .stream().filter(v -> v.getPythonVersion().equals(executionVersion)).collect(Collectors.toList()); } catch (IOException e) { e.printStackTrace(); @@ -247,7 +247,7 @@ private String findLocalEngine(String version, String trainingVersion) { List downloadedVersions = new ArrayList(); try { InstalledEngines installed = InstalledEngines.buildEnginesFinder(); - downloadedVersions = installed.getDownloadedPythonVersionsForEngine(engine); + downloadedVersions = installed.getDownloadedPythonVersionsForFramework(engine); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/io/bioimage/modelrunner/engine/EngineInfo.java b/src/main/java/io/bioimage/modelrunner/engine/EngineInfo.java index f4da408b..0b520bdf 100644 --- a/src/main/java/io/bioimage/modelrunner/engine/EngineInfo.java +++ b/src/main/java/io/bioimage/modelrunner/engine/EngineInfo.java @@ -629,10 +629,10 @@ public static EngineInfo defineCompatibleDLEngineCPU( String framework, String v String jarsDirectory ) throws IOException, IllegalArgumentException { InstalledEngines manager = InstalledEngines.buildEnginesFinder(jarsDirectory); - String compatibleVersion = manager.getMostCompatibleVersionForEngine(framework, version); + String compatibleVersion = manager.getMostCompatibleVersionForFramework(framework, version); if (compatibleVersion == null) return null; - List vv = manager.getDownloadedForVersionedEngine(framework, compatibleVersion); + List vv = manager.getDownloadedForVersionedFramework(framework, compatibleVersion); boolean gpu = vv.stream().filter(v -> v.getGPU()).findFirst().orElse(null) != null; return EngineInfo.defineDLEngine(framework, compatibleVersion, true, gpu, jarsDirectory); } @@ -791,10 +791,10 @@ public static EngineInfo defineCompatibleDLEngineWithRdfYamlWeights(WeightFormat String engine = weight.getWeightsFormat(); String version = weight.getTrainingVersion(); InstalledEngines manager = InstalledEngines.buildEnginesFinder(enginesDir); - compatibleVersion = manager.getMostCompatibleVersionForEngine(engine, version); + compatibleVersion = manager.getMostCompatibleVersionForFramework(engine, version); if (compatibleVersion == null) return null; - List vv = manager.getDownloadedForVersionedEngine(engine, compatibleVersion); + List vv = manager.getDownloadedForVersionedFramework(engine, compatibleVersion); boolean gpu = vv.stream().filter(v -> v.getGPU()).findFirst().orElse(null) != null; return EngineInfo.defineDLEngine(engine, compatibleVersion, true, gpu, enginesDir); } @@ -845,7 +845,7 @@ public static EngineInfo defineExactDLEngineWithRdfYamlWeights(WeightFormat weig InstalledEngines manager = InstalledEngines.buildEnginesFinder(enginesDir); if (version == null) return null; - List vv = manager.getDownloadedForVersionedEngine(engine, version); + List vv = manager.getDownloadedForVersionedFramework(engine, version); if (vv.size() == 0) return null; boolean gpu = vv.stream().filter(v -> v.getGPU()).findFirst().orElse(null) != null; diff --git a/src/main/java/io/bioimage/modelrunner/engine/installation/EngineManagement.java b/src/main/java/io/bioimage/modelrunner/engine/installation/EngineManagement.java index 305264b8..0573a93d 100644 --- a/src/main/java/io/bioimage/modelrunner/engine/installation/EngineManagement.java +++ b/src/main/java/io/bioimage/modelrunner/engine/installation/EngineManagement.java @@ -657,7 +657,7 @@ public static boolean installEngineForWeightsInDir(WeightFormat ww, String engin InstalledEngines manager = InstalledEngines.buildEnginesFinder(enginesDir); String engine = ww.getWeightsFormat(); String version = ww.getTrainingVersion(); - List vs = manager.getDownloadedForVersionedEngine(engine, version); + List vs = manager.getDownloadedForVersionedFramework(engine, version); if (vs.size() != 0) return true; if (AvailableEngines.isEngineSupportedInOS(engine, version, true, true)) { diff --git a/src/main/java/io/bioimage/modelrunner/versionmanagement/InstalledEngines.java b/src/main/java/io/bioimage/modelrunner/versionmanagement/InstalledEngines.java index b7418e60..3cf28704 100644 --- a/src/main/java/io/bioimage/modelrunner/versionmanagement/InstalledEngines.java +++ b/src/main/java/io/bioimage/modelrunner/versionmanagement/InstalledEngines.java @@ -144,14 +144,14 @@ public static List getAll(String enginesPath) * Creates a list containing only downloaded Deep Learning versions compatible with * the current system and corresponding to the engine of interest * - * @param engine + * @param framework * name of the engine as defined with the engine tag at: * https://raw.githubusercontent.com/bioimage-io/model-runner-java/main/src/main/resources/availableDLVersions.json * for example tensorflow, pytorch, onnx * @return The available versions instance. */ - public List getDownloadedForEngine(String engine) { - String searchEngine = AvailableEngines.getSupportedVersionsEngineTag(engine); + public List getDownloadedForFramework(String framework) { + String searchEngine = AvailableEngines.getSupportedVersionsEngineTag(framework); if (searchEngine == null) return new ArrayList(); return getDownloadedForOS().stream() @@ -163,7 +163,7 @@ public List getDownloadedForEngine(String engine) { * Creates a list containing only downloaded Deep Learning versions compatible with * the current system, corresponding to the engine of interest and corresponding version * - * @param engine + * @param framework * name of the engine as defined with the engine tag at: * https://raw.githubusercontent.com/bioimage-io/model-runner-java/main/src/main/resources/availableDLVersions.json * for example tensorflow, pytorch, onnx @@ -171,8 +171,8 @@ public List getDownloadedForEngine(String engine) { * version of interest of the engine * @return The available versions instance. */ - public List getDownloadedForVersionedEngine(String engine, String version) { - String searchEngine = AvailableEngines.getSupportedVersionsEngineTag(engine); + public List getDownloadedForVersionedFramework(String framework, String version) { + String searchEngine = AvailableEngines.getSupportedVersionsEngineTag(framework); if (searchEngine == null) return new ArrayList(); return getDownloadedForOS().stream() @@ -187,15 +187,15 @@ public List getDownloadedForVersionedEngine(String engine, * * @param enginesPath * path to where the engines are stored - * @param engine + * @param framework * name of the engine as defined with the engine tag at: * https://raw.githubusercontent.com/bioimage-io/model-runner-java/main/src/main/resources/availableDLVersions.json * for example tensorflow, pytorch, onnx * @return The available versions instance. */ - public static List getDownloadedForEngine(String enginesPath, String engine) { + public static List getDownloadedForFramework(String enginesPath, String framework) { try{ - return buildEnginesFinder(enginesPath).getDownloadedForEngine(engine); + return buildEnginesFinder(enginesPath).getDownloadedForFramework(framework); } catch (IOException ex) { return new ArrayList(); } @@ -238,12 +238,12 @@ public static List getDownloadedForOS(String enginesPath) { * Return a list of all the downloaded Python versions of the corresponding engine * are installed in the local machine * - * @param engine + * @param framework * the engine of interest * @return the list of deep learning versions for the given engine */ - public List getDownloadedPythonVersionsForEngine(String engine) { - return getDownloadedForEngine(engine).stream() + public List getDownloadedPythonVersionsForFramework(String framework) { + return getDownloadedForFramework(framework).stream() .map(DeepLearningVersion::getPythonVersion).collect(Collectors.toList()); } @@ -253,13 +253,13 @@ public List getDownloadedPythonVersionsForEngine(String engine) { * * @param enginesPath * path to where the engines are stored - * @param engine + * @param framework * the engine of interest * @return the list of deep learning versions for the given engine */ - public static List getDownloadedPythonVersionsForEngine(String enginesPath, String engine) { + public static List getDownloadedPythonVersionsForFramework(String enginesPath, String framework) { try{ - return buildEnginesFinder(enginesPath).getDownloadedPythonVersionsForEngine(engine); + return buildEnginesFinder(enginesPath).getDownloadedPythonVersionsForFramework(framework); } catch (IOException ex) { return new ArrayList(); } @@ -290,7 +290,7 @@ public static void setEnginesDirectory(String dir) throws IOException { * For a specific Deep Learning framework, specified by the parameter * engine, and a specific version of interest, return the closest existing * version among the installed ones for the DL framework - * @param engine + * @param framework * the engine of interest * Deep Learning framework (tensorflow, pytorch, onnx...) as defined with the engine tag * at https://raw.githubusercontent.com/bioimage-io/model-runner-java/main/src/main/resources/availableDLVersions.json @@ -298,16 +298,16 @@ public static void setEnginesDirectory(String dir) throws IOException { * the version of interest * @return the closest version to the version provided for the engine provided */ - public String getMostCompatibleVersionForEngine(String engine, String version) { - List downloadedVersions = getDownloadedPythonVersionsForEngine(engine); - return VersionStringUtils.getMostCompatibleEngineVersion(version, downloadedVersions, engine); + public String getMostCompatibleVersionForFramework(String framework, String version) { + List downloadedVersions = getDownloadedPythonVersionsForFramework(framework); + return VersionStringUtils.getMostCompatibleEngineVersion(version, downloadedVersions, framework); } /** * For a specific Deep Learning framework, specified by the parameter * engine, and a specific version of interest, return the closest existing * version among the installed ones for the DL framework - * @param engine + * @param framework * the engine of interest * Deep Learning framework (tensorflow, pytorch, onnx...) as defined with the engine tag * at https://raw.githubusercontent.com/bioimage-io/model-runner-java/main/src/main/resources/availableDLVersions.json @@ -317,11 +317,11 @@ public String getMostCompatibleVersionForEngine(String engine, String version) { * path to where the engines are stored * @return the closest version to the version provided for the engine provided */ - public static String getMostCompatibleVersionForEngine(String engine, String version, String enginesDir) { + public static String getMostCompatibleVersionForFramework(String framework, String version, String enginesDir) { try { InstalledEngines installed = InstalledEngines.buildEnginesFinder(enginesDir); - List downloadedVersions = installed.getDownloadedPythonVersionsForEngine(engine); - return VersionStringUtils.getMostCompatibleEngineVersion(version, downloadedVersions, engine); + List downloadedVersions = installed.getDownloadedPythonVersionsForFramework(framework); + return VersionStringUtils.getMostCompatibleEngineVersion(version, downloadedVersions, framework); } catch (IOException e) { return null; } @@ -331,7 +331,7 @@ public static String getMostCompatibleVersionForEngine(String engine, String ver * Returns a list of all the installed engine versions that are compatible * with the versioned engine provided in the input parameters. * - * @param engine + * @param framework * name of the DL framework of interest * @param version * original version we are looking for compatibles @@ -340,12 +340,12 @@ public static String getMostCompatibleVersionForEngine(String engine, String ver * @return a list of all the string versions compatible * with the provided versioned engine */ - public static List getOrderedListOfCompatibleVesionsForEngine(String engine, + public static List getOrderedListOfCompatibleVesionsForFramework(String framework, String version, String enginesDir) { try { InstalledEngines installed = InstalledEngines.buildEnginesFinder(enginesDir); - List downloadedVersions = installed.getDownloadedPythonVersionsForEngine(engine); - return VersionStringUtils.getCompatibleEngineVersionsInOrder(version, downloadedVersions, engine); + List downloadedVersions = installed.getDownloadedPythonVersionsForFramework(framework); + return VersionStringUtils.getCompatibleEngineVersionsInOrder(version, downloadedVersions, framework); } catch (IOException e) { return null; } @@ -353,14 +353,14 @@ public static List getOrderedListOfCompatibleVesionsForEngine(String eng /** * Check whether the engine version of interest is installed or not - * @param engine + * @param framework * DL framework of interest * @param version * version of the DL framework * @return true if it is installed and false otherwise */ - public boolean checkEngineVersionInstalled(String engine, String version) { - List downloadedVersions = getDownloadedPythonVersionsForEngine(engine); + public boolean checkFrameworkVersionInstalled(String framework, String version) { + List downloadedVersions = getDownloadedPythonVersionsForFramework(framework); String v = downloadedVersions.stream() .filter(vv -> vv.equals(version)).findFirst().orElse(null); return v != null; @@ -368,7 +368,7 @@ public boolean checkEngineVersionInstalled(String engine, String version) { /** * Check whether the engine version of interest is installed or not - * @param engine + * @param framework * DL framework of interest * @param version * version of the DL framework @@ -376,10 +376,10 @@ public boolean checkEngineVersionInstalled(String engine, String version) { * directory where all the engines are located * @return true if it is installed and false otherwise */ - public static boolean checkEngineVersionInstalled(String engine, String version, String enginesDir) { + public static boolean checkFrameworkVersionInstalled(String framework, String version, String enginesDir) { try { InstalledEngines installed = InstalledEngines.buildEnginesFinder(enginesDir); - return installed.checkEngineVersionInstalled(engine, version); + return installed.checkFrameworkVersionInstalled(framework, version); } catch (IOException e) { return false; } @@ -395,7 +395,7 @@ public static boolean checkEngineVersionInstalled(String engine, String version, * the resulting list of engines will contain both engines that support and do not support GPU. * * - * @param engine + * @param framework * the name of the DL framework. Can be null. * @param version * the version of the DL framework in Python. Can be null. @@ -410,14 +410,14 @@ public static boolean checkEngineVersionInstalled(String engine, String version, * minimum Java version that the engine needs to work. Can be null. * @return a list containing a list of installed engiens satisfying the constraints */ - public List checkEngineWithArgsInstalled(String engine, + public List checkEngineWithArgsInstalled(String framework, String version, Boolean cpu, Boolean gpu, Boolean rosetta, Integer minJavaVersion) { String searchEngine; - if (engine != null) - searchEngine = AvailableEngines.getSupportedVersionsEngineTag(engine); + if (framework != null) + searchEngine = AvailableEngines.getSupportedVersionsEngineTag(framework); else searchEngine = null; - if (searchEngine == null && engine != null) + if (searchEngine == null && framework != null) return new ArrayList(); List filtered = getDownloadedForOS().stream().filter(vv ->{ if (searchEngine != null && !vv.getFramework().toLowerCase().equals(searchEngine)) @@ -448,7 +448,7 @@ else if (rosetta != null && rosetta == true && vv.getRosetta() != rosetta) * * The ONLY PARAMETER THAT CANNOT BE NULL IS: enginesDir * - * @param engine + * @param framework * the name of the DL framework. Can be null. * @param version * the version of the DL framework in Python. Can be null. @@ -465,13 +465,13 @@ else if (rosetta != null && rosetta == true && vv.getRosetta() != rosetta) * the directory where all the engines are stored. CANNOT BE NULL. * @return a list containing a list of installed engiens satisfying the constraints */ - public static List checkEngineWithArgsInstalled(String engine, + public static List checkEngineWithArgsInstalled(String framework, String version, Boolean cpu, Boolean gpu, Boolean rosetta, Integer minJavaVersion, String enginesDir) { Objects.requireNonNull(enginesDir); try { InstalledEngines installed = InstalledEngines.buildEnginesFinder(enginesDir); - return installed.checkEngineWithArgsInstalled(engine, version, + return installed.checkEngineWithArgsInstalled(framework, version, cpu, gpu, rosetta, minJavaVersion); } catch (IOException e) { return new ArrayList(); @@ -490,7 +490,7 @@ public static List checkEngineWithArgsInstalled(String engi * the resulting list of engines will contain both engines that support and do not support GPU. * * - * @param engine + * @param framework * the name of the DL framework. Can be null. * @param version * the version of the DL framework in Python. Can be null. @@ -500,11 +500,11 @@ public static List checkEngineWithArgsInstalled(String engi * whether it supports running on GPU or not. Can be null. * @return a list containing a list of installed engiens satisfying the constraints */ - public List checkEngineWithArgsInstalledForOS(String engine, + public List checkEngineWithArgsInstalledForOS(String framework, String version, Boolean cpu, Boolean gpu) { int javaVersion = PlatformDetection.getJavaVersion(); boolean rosetta = new PlatformDetection().isUsingRosseta(); - return checkEngineWithArgsInstalled(engine, version, cpu, gpu, + return checkEngineWithArgsInstalled(framework, version, cpu, gpu, rosetta, javaVersion); } @@ -521,7 +521,7 @@ public List checkEngineWithArgsInstalledForOS(String engine * * The ONLY PARAMETER THAT CANNOT BE NULL IS: enginesDir * - * @param engine + * @param framework * the name of the DL framework. Can be null. * @param version * the version of the DL framework in Python. Can be null. @@ -533,12 +533,12 @@ public List checkEngineWithArgsInstalledForOS(String engine * the directory where all the engines are stored. CANNOT BE NULL. * @return a list containing a list of installed engiens satisfying the constraints */ - public static List checkEngineWithArgsInstalledForOS(String engine, + public static List checkEngineWithArgsInstalledForOS(String framework, String version, Boolean cpu, Boolean gpu, String enginesDir) { Objects.requireNonNull(enginesDir); try { InstalledEngines installed = InstalledEngines.buildEnginesFinder(enginesDir); - return installed.checkEngineWithArgsInstalledForOS(engine, version, + return installed.checkEngineWithArgsInstalledForOS(framework, version, cpu, gpu); } catch (IOException e) { return new ArrayList();