From 38df8e7b4066802cad38303afdf467688d67090a Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 11:51:50 +0200 Subject: [PATCH 001/150] start adding workflow for icy --- .../workflows/check_compatibility_icy.yaml | 30 ++ scripts/check_compatiblity_icy/pom.xml | 99 ++++ .../modelrunner/ci/ContinuousIntegration.java | 459 ++++++++++++++++++ .../modelrunner/ci/JavaProcessing.java | 427 ++++++++++++++++ 4 files changed, 1015 insertions(+) create mode 100644 .github/workflows/check_compatibility_icy.yaml create mode 100644 scripts/check_compatiblity_icy/pom.xml create mode 100644 scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java create mode 100644 scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml new file mode 100644 index 00000000..0d47bb84 --- /dev/null +++ b/.github/workflows/check_compatibility_icy.yaml @@ -0,0 +1,30 @@ +name: check compatibility icy + +concurrency: icy + +on: + push: + branches: + - main + paths: + - .github/workflows/check_compatibility_icy.yaml + - scripts/check_compatibility_icy.py + workflow_dispatch: + schedule: + - cron: 0 1 * * * # update compatibility once a day + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Maven Action + uses: stCarolas/setup-maven@v4.5 + with: + java-version: 11 + maven-version: 3.9.5 + - name: Build with Maven + run: | + cd scripts/check_compatiblity_icy + mvn clean install + diff --git a/scripts/check_compatiblity_icy/pom.xml b/scripts/check_compatiblity_icy/pom.xml new file mode 100644 index 00000000..8d225793 --- /dev/null +++ b/scripts/check_compatiblity_icy/pom.xml @@ -0,0 +1,99 @@ + + + 4.0.0 + + + org.scijava + pom-scijava + 37.0.0 + + + + io.bioimage + dl-modelrunner-ci + 0.0.1-SNAPSHOT + + JDLL CI + Continuous integration code for JDLL + + https://github.com/bioimage-io/pytorch-java-interface-javacpp + 2023 + + Icy Bioimage Analysis + https://icy.bioimageanalysis.org/ + + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + carlosuc3m + Carlos Javier Garcia Lopez de Haro + https://github.com/carlosuc3m + + developer + debugger + reviewer + support + maintainer + + + + + + Carlos Garcia + https://github.com/carlosuc3m + carlosuc3m + + + + + + Image.sc Forum + https://forum.image.sc/tag/bioimage-io + + + + + scm:git:https://github.com/Icy-imaging/icy-bioimage-io + scm:git:git@github.com:Icy-imaging/icy-bioimage-io + HEAD + https://github.com/Icy-imaging/icy-bioimage-io + + + GitHub Issues + https://github.com/Icy-imaging/icy-bioimage-io/issues + + + None + + + + io.bioimage.modelrunner.ci + + apache_v2 + Institut Pasteur + + 0.5.5-SNAPSHOT + + + + + scijava.public + https://maven.scijava.org/content/groups/public + + + + + + io.bioimage + dl-modelrunner + ${dl-modelrunner.version} + + + diff --git a/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java new file mode 100644 index 00000000..d0686bd3 --- /dev/null +++ b/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java @@ -0,0 +1,459 @@ +/*- + * #%L + * This project performs Continuous Integration tasks on the JDLL library + * %% + * Copyright (C) 2023 Institut Pasteur. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package io.bioimage.modelrunner.ci; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.PathMatcher; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.jar.Manifest; +import java.util.stream.Collectors; + +import io.bioimage.modelrunner.bioimageio.BioimageioRepo; +import io.bioimage.modelrunner.bioimageio.description.ModelDescriptor; +import io.bioimage.modelrunner.bioimageio.description.TransformSpec; +import io.bioimage.modelrunner.bioimageio.description.exceptions.ModelSpecsException; +import io.bioimage.modelrunner.bioimageio.description.weights.ModelWeight; +import io.bioimage.modelrunner.bioimageio.description.weights.WeightFormat; +import io.bioimage.modelrunner.engine.EngineInfo; +import io.bioimage.modelrunner.engine.installation.EngineInstall; +import io.bioimage.modelrunner.model.Model; +import io.bioimage.modelrunner.numpy.DecodeNumpy; +import io.bioimage.modelrunner.tensor.Tensor; +import io.bioimage.modelrunner.utils.Constants; +import io.bioimage.modelrunner.utils.YAMLUtils; +import net.imglib2.Cursor; +import net.imglib2.RandomAccessibleInterval; +import net.imglib2.loops.LoopBuilder; +import net.imglib2.type.NativeType; +import net.imglib2.type.numeric.RealType; +import net.imglib2.type.numeric.real.FloatType; +import net.imglib2.view.Views; + +/** + * + */ +public class ContinuousIntegration { + + private static Map downloadedModelsCorrectly = new HashMap(); + private static Map downloadedModelsIncorrectly = new HashMap(); + + public static void main(String[] args) throws IOException { + + //String pendingMatrix = args[1]; + + Path currentDir = Paths.get(ContinuousIntegration.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent(); + Path rdfDir = currentDir.resolve("../bioimageio-gh-pages/rdfs").normalize(); + + // Create a matcher for the pattern 'rdf.yaml' + runTests(rdfDir, "**", "**", Paths.get("test_summaries"), null); + } + + + public static void runTests(Path rdfDir, String resourceID, String versionID, Path summariesDir, String postfix) throws IOException { + LinkedHashMap summaryDefaults = new LinkedHashMap(); + postfix = getJDLLVersion(); + summaryDefaults.put("JDLL_VERSION", postfix); + + PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + resourceID + File.separator + versionID + File.separator + Constants.RDF_FNAME); + + List rdfFiles = Files.walk(rdfDir).filter(matcher::matches).collect(Collectors.toList()); + EngineInstall installer = EngineInstall.createInstaller(); + installer.basicEngineInstallation(); + + for (Path rdfPath : rdfFiles) { + String testName = "Reproduce ouptuts with JDLL " + postfix; + String error = null; + String status = null; + String traceback = null; + + Map rdf = new LinkedHashMap(); + try { + rdf = YAMLUtils.load(rdfPath.toAbsolutePath().toString()); + } catch (Exception ex) { + error = "Unable to load " + Constants.RDF_FNAME + ": " + ex.toString(); + status = "failed"; + traceback = stackTrace(ex); + ex.printStackTrace(); + } + + Object rdID = rdf.get("id"); + Object type = rdf.get("type"); + Object weightFormats = rdf.get("weights"); + if (rdID == null || !(rdID instanceof String)) { + System.out.println("Invalid RDF. Missing/Invalid 'id' in rdf: " + rdfPath.toString()); + } else if (type == null || !(type instanceof String) || !((String) type).equals("model")) { + status = "skipped"; + error = "not a model RDF"; + } else if (weightFormats == null || !(weightFormats instanceof Map)) { + status = "failed"; + error = "Missing weights dictionary for " + rdID; + traceback = weightFormats.toString(); + } + ModelWeight weights = null; + try { + weights = ModelWeight.build((Map) weightFormats); + } catch (Exception ex) { + status = "failed"; + error = "Missing/Invalid weight formats for " + rdID; + traceback = stackTrace(ex); + } + + if (weights != null && weights.gettAllSupportedWeightObjects().size() == 0) { + status = "failed"; + error = "Missing/Invalid weight formats. No supported weigths found for " + rdID; + } + + if (status != null) { + List summary = new ArrayList(); + Map summaryMap = new LinkedHashMap(); + summaryMap.put("name", testName); + summaryMap.put("status", status); + summaryMap.put("error", error); + summaryMap.put("source_name", rdfPath.toAbsolutePath().toString()); + summaryMap.put("traceback", traceback); + summaryMap.putAll(summaryDefaults); + summary.add(summaryMap); + + writeSummaries(summariesDir.toAbsolutePath() + File.separator + rdID + File.separator + "test_summary_" + postfix + ".yaml", summary); + continue; + } + + Map summariesPerWeightFormat = new LinkedHashMap(); + + for (WeightFormat ww : weights.gettAllSupportedWeightObjects()) { + List summariesWeightFormat = new ArrayList(); + Map summaryWeightFormat = new LinkedHashMap(); + try { + summariesWeightFormat = testResource(rdfPath.toAbsolutePath().toString(), ww, 4, "model"); + } catch (Exception ex) { + ex.printStackTrace(); + summaryWeightFormat.put("name", testName); + summaryWeightFormat.put("status", "failed"); + summaryWeightFormat.put("error", "unable to perform tests"); + summaryWeightFormat.put("traceback", stackTrace(ex)); + summaryWeightFormat.put("source_name", rdfPath.toAbsolutePath().toString()); + summaryWeightFormat.putAll(summaryDefaults); + summariesWeightFormat.add(summaryWeightFormat); + } + summariesPerWeightFormat.put(ww.getFramework(), summariesWeightFormat); + } + + List passedReproducedSummaries = new ArrayList(); + List failedReproducedSummaries = new ArrayList(); + List otherSummaries = new ArrayList(); + List seenTests = new ArrayList(); + + for (Entry entry : summariesPerWeightFormat.entrySet()) { + String wf = entry.getKey(); + List> s = (List>) entry.getValue(); + for (Map ss : s) { + boolean isOther = !ss.get("name").equals("reproduce test outputs from test inputs"); + if (isOther && seenTests.contains(ss.toString())) { + continue; + } + ss.put("name", ss.get("name") + " (" + wf + ")"); + if (isOther) { + seenTests.add(ss.toString()); + otherSummaries.add(ss); + continue; + } + if (status != null && status.equals("passed")) passedReproducedSummaries.add(ss); + else failedReproducedSummaries.add(ss); + } + } + + List chosenSummaries = new ArrayList(); + chosenSummaries.addAll(passedReproducedSummaries); + chosenSummaries.addAll(failedReproducedSummaries); + chosenSummaries.addAll(otherSummaries); + + writeSummaries(summariesDir.toAbsolutePath() + File.separator + rdID + File.separator + "test_summary_" + postfix + ".yaml", chosenSummaries); + } + } + + private static void writeSummaries(String summariesPath, List summaries) throws IOException { + Path path = Paths.get(summariesPath).getParent(); + if (path != null && !Files.exists(path)) + Files.createDirectories(path); + YAMLUtils.writeYamlFile(summariesPath, summaries); + } + + /** + * Code to automatically get the version of JDLL being used + * @return the JDLL version being used + */ + public static String getJDLLVersion() { + String version = "UNKNOWN"; + try (InputStream manifestStream = Tensor.class.getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF")) { + if (manifestStream != null) { + Manifest manifest = new Manifest(manifestStream); + java.util.jar.Attributes attrs = manifest.getMainAttributes(); + version = attrs.getValue("Implementation-Version"); + } + } catch (Exception e) { + } + return version; + } + + private static List testResource(String rdf, WeightFormat weightFormat, int decimal, String expectedType) { + String error = null; + String traceback = null; + ModelDescriptor rd = null; + try { + rd = ModelDescriptor.readFromLocalFile(rdf, false); + } catch (ModelSpecsException e) { + error = "unable to read rdf.yaml file"; + traceback = stackTrace(e); + } + + List tests = new ArrayList(); + Map loadTest = new LinkedHashMap(); + loadTest.put("name", "load resource description"); + loadTest.put("status", error == null ? "passed" : "failed"); + loadTest.put("error", error); + loadTest.put("source_name", rdf); + loadTest.put("traceback", traceback); + loadTest.put("JDLL_VERSION", getJDLLVersion()); + + tests.add(loadTest); + + if (rd != null) + tests.add(testExpectedResourceType(rd, expectedType)); + if (rd != null && rd.getType().equals("model")) { + tests.add(testModelDownload(rd)); + tests.add(testModelInference(rd, weightFormat, decimal)); + } + return tests; + } + + private static Map testExpectedResourceType(ModelDescriptor rd, String type) { + boolean yes = rd.getType().equals(type); + Map typeTest = new LinkedHashMap(); + typeTest.put("name", "has expected resource type"); + typeTest.put("status", yes ? "passed" : "failed"); + typeTest.put("error", yes ? null : "expected type was " + type + " but found " + rd.getType()); + typeTest.put("source_name", rd.getName()); + typeTest.put("traceback", null); + typeTest.put("JDLL_VERSION", getJDLLVersion()); + return typeTest; + } + + private static Map testModelDownload(ModelDescriptor rd) { + String error = null; + if (downloadedModelsCorrectly.keySet().contains(rd.getName())) { + rd.addModelPath(Paths.get(downloadedModelsCorrectly.get(rd.getName()))); + } else if (downloadedModelsIncorrectly.keySet().contains(rd.getName())) { + error = downloadedModelsIncorrectly.get(rd.getName()); + } else { + error = downloadModel(rd); + } + Map downloadTest = new LinkedHashMap(); + downloadTest.put("name", "JDLL is able to download model"); + downloadTest.put("status", error == null ? "passed" : "failed"); + downloadTest.put("error", error == null ? null : "unable to download model"); + downloadTest.put("traceback", error); + downloadTest.put("source_name", rd.getName()); + downloadTest.put("JDLL_VERSION", getJDLLVersion()); + return downloadTest; + } + + private static String downloadModel(ModelDescriptor rd) { + String error = null; + try { + BioimageioRepo br = BioimageioRepo.connect(); + String folder = br.downloadByName(rd.getName(), "models"); + rd.addModelPath(Paths.get(folder)); + downloadedModelsCorrectly.put(rd.getName(), folder); + } catch (Exception ex) { + error = stackTrace(ex); + downloadedModelsIncorrectly.put(rd.getName(), error); + } + return error; + } + + private static < T extends RealType< T > & NativeType< T > > + Map testModelInference(ModelDescriptor rd, WeightFormat ww, int decimal) { + System.out.println(rd.getName()); + System.out.println(ww.getFramework()); + Map inferTest = new LinkedHashMap(); + inferTest.put("name", "reproduce test inputs from test outptus for " + ww.getFramework()); + inferTest.put("source_name", rd.getName()); + inferTest.put("JDLL_VERSION", getJDLLVersion()); + if (rd.getModelPath() == null) { + inferTest.put("status", "failed"); + inferTest.put("error", "model was not correctly downloaded"); + return inferTest; + } + if (rd.getInputTensors().size() != rd.getTestInputs().size()) { + inferTest.put("status", "failed"); + inferTest.put("error", "the number of test inputs should be the same as the number of inputs," + + rd.getInputTensors().size() + " vs " + rd.getTestInputs().size()); + return inferTest; + } else if (rd.getOutputTensors().size() != rd.getTestOutputs().size()) { + inferTest.put("status", "failed"); + inferTest.put("error", "the number of test outputs should be the same as the number of outputs" + + rd.getOutputTensors().size() + " vs " + rd.getTestOutputs().size()); + return inferTest; + } + + List> inps = new ArrayList>(); + List> outs = new ArrayList>(); + for (int i = 0; i < rd.getInputTensors().size(); i ++) { + RandomAccessibleInterval rai; + try { + rai = DecodeNumpy.retrieveImgLib2FromNpy(rd.getTestInputs().get(i).getLocalPath().toAbsolutePath().toString()); + } catch (Exception e) { + return failInferenceTest(rd.getName(), "unable to open test input: " + rd.getTestInputs().get(i).getString(), stackTrace(e)); + } + Tensor inputTensor = Tensor.build(rd.getInputTensors().get(i).getName(), rd.getInputTensors().get(i).getAxesOrder(), rai); + if (rd.getInputTensors().get(i).getPreprocessing().size() > 0) { + TransformSpec transform = rd.getInputTensors().get(i).getPreprocessing().get(0); + JavaProcessing preproc; + try { + preproc = JavaProcessing.definePreprocessing(transform.getName(), transform.getKwargs()); + } catch (Exception e) { + e.printStackTrace(); + return failInferenceTest(rd.getName(), "pre-processing transformation not supported by JDLL: " + transform.getName(), stackTrace(e)); + } + inputTensor = preproc.execute(rd.getInputTensors().get(i), inputTensor); + } + inps.add(inputTensor); + } + for (int i = 0; i < rd.getOutputTensors().size(); i ++) { + Tensor outputTensor = Tensor.buildEmptyTensor(rd.getOutputTensors().get(i).getName(), rd.getOutputTensors().get(i).getAxesOrder()); + outs.add(outputTensor); + } + EngineInfo engineInfo; + try { + engineInfo = EngineInfo.defineCompatibleDLEngineWithRdfYamlWeights(ww); + } catch (Exception e) { + e.printStackTrace(); + return failInferenceTest(rd.getName(), "selected weights not supported by JDLL: " + ww.getFramework(), stackTrace(e)); + } + Model model; + try { + model = Model.createDeepLearningModel(rd.getModelPath(), rd.getModelPath() + File.separator + ww.getSourceFileName(), engineInfo); + model.loadModel(); + } catch (Exception e) { + e.printStackTrace(); + return failInferenceTest(rd.getName(), "unable to instantiate/load model", stackTrace(e)); + } + try { + model.runModel(inps, outs); + } catch (Exception e) { + e.printStackTrace(); + return failInferenceTest(rd.getName(), "unable to run model", stackTrace(e)); + } + + List maxDif = new ArrayList(); + for (int i = 0; i < rd.getOutputTensors().size(); i ++) { + Tensor tt = (Tensor) outs.get(i); + if (rd.getOutputTensors().get(i).getPostprocessing().size() > 0) { + TransformSpec transform = rd.getOutputTensors().get(i).getPostprocessing().get(0); + if (transform.getName().equals("python")) continue; + JavaProcessing preproc; + try { + preproc = JavaProcessing.definePreprocessing(transform.getName(), transform.getKwargs()); + } catch (Exception e) { + e.printStackTrace(); + return failInferenceTest(rd.getName(), "post-processing transformation not supported by JDLL: " + transform.getName(), stackTrace(e)); + } + tt = preproc.execute(rd.getInputTensors().get(i), tt); + } + RandomAccessibleInterval rai; + try { + rai = DecodeNumpy.retrieveImgLib2FromNpy(rd.getTestOutputs().get(i).getLocalPath().toAbsolutePath().toString()); + } catch (Exception e) { + e.printStackTrace(); + return failInferenceTest(rd.getName(), "unable to open test output: " + rd.getTestOutputs().get(i).getString(), stackTrace(e)); + } + LoopBuilder.setImages( tt.getData(), rai ) + .multiThreaded().forEachPixel( ( j, o ) -> o.set( (T) new FloatType(o.getRealFloat() - j.getRealFloat())) ); + double diff = computeMaxDiff(rai); + if (diff > Math.pow(10, -decimal)) + return failInferenceTest(rd.getName(), "output number " + i + " produces a very different result, " + + "the max difference is bigger than " + Math.pow(10, -decimal), null); + maxDif.add(computeMaxDiff(rai)); + } + + + Map typeTest = new LinkedHashMap(); + typeTest.put("name", "reproduce test outputs from test inputs"); + typeTest.put("status", "passed"); + typeTest.put("error", null); + typeTest.put("source_name", rd.getName()); + typeTest.put("traceback", null); + typeTest.put("JDLL_VERSION", getJDLLVersion()); + return typeTest; + } + + private static Map failInferenceTest(String sourceName, String error, String tb) { + Map typeTest = new LinkedHashMap(); + typeTest.put("name", "reproduce test outputs from test inputs"); + typeTest.put("status", "failed"); + typeTest.put("error", error); + typeTest.put("source_name", sourceName); + typeTest.put("traceback", tb); + typeTest.put("JDLL_VERSION", getJDLLVersion()); + return typeTest; + } + + + public static < T extends RealType< T > & NativeType< T > > double computeMaxDiff(final RandomAccessibleInterval< T > input) { + Cursor iterator = Views.iterable(input).cursor(); + T type = iterator.next(); + T min = type.copy(); + T max = type.copy(); + while ( iterator.hasNext() ) + { + type = iterator.next(); + if ( type.compareTo( min ) < 0 ) + min.set( type ); + if ( type.compareTo( max ) > 0 ) + max.set( type ); + } + return Math.max(-min.getRealDouble(), min.getRealDouble()); + } + + /** Dumps the given exception, including stack trace, to a string. + * + * @param t + * the given exception {@link Throwable} + * @return the String containing the whole exception trace + */ + public static String stackTrace(Throwable t) { + StringWriter sw = new StringWriter(); + t.printStackTrace(new PrintWriter(sw)); + return sw.toString(); + } +} diff --git a/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java b/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java new file mode 100644 index 00000000..24e05b34 --- /dev/null +++ b/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java @@ -0,0 +1,427 @@ +package io.bioimage.modelrunner.ci; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import io.bioimage.modelrunner.bioimageio.description.TensorSpec; +import io.bioimage.modelrunner.tensor.Tensor; + +import net.imglib2.RandomAccessibleInterval; +import net.imglib2.type.NativeType; +import net.imglib2.type.Type; +import net.imglib2.type.numeric.RealType; + +/** + * Class that handles the Java pre-processing transformations. + * The transformations can be either custom designed by the developer or + * coming from the Bioimage.io Java library + * and the tensors produced by them + * + * @author Carlos Garcia Lopez de Haro + * + */ +public class JavaProcessing { + /** + * Transformation as specified in the rdf.yaml + */ + private String rdfSpec; + /** + * String containing the name of the method that runs JAva pre-processing + */ + private String javaMethodName; + /** + * String referring to the BioImage.io class that contains the specified transformations + */ + private String javaClassName; + /** + * Class that contains the pre-processing + */ + private Class transformationClass; + /** + * Arguments used for the Java method + */ + private Map args; + /** + * Name of the tensor that is going to be pre-processed + */ + private String tensorName; + /** + * Specs of the tensor that is going to be pre-processed + */ + private TensorSpec tensorSpec; + /** + * INDArray containing all the information of the input tensor to which this + * pre-processing transformation corresponds + */ + private Tensor tensor; + /** + * Package where the BioImage.io transformations are. + */ + private static final String BIOIMAGEIO_TRANSFORMATIONS_PACKAGE = "io.bioimage.modelrunner.transformations."; + /** + * Name of the standard method used by the BioImage.io transformations to call the + * pre-processing routine + */ + private static String bioImageIoExecutionMethodName = "apply"; + + /** + * Create pre-processing object that contains the path to a pre-processing protocol file + * @param javaMethod + * file that contains the Icy protocols to run pre-processing + * @param args + * args of the pre-processing specified in the rdf.yaml + * @throws ClassNotFoundException if the pre-processing transformation is not found in the classpath + */ + private JavaProcessing(String javaMethod, Map args) throws ClassNotFoundException { + this.rdfSpec = javaMethod; + this.args = args; + checkMethodExists(); + } + + /** + * Create a Java pre-processing object + * @param methodName + * name of the Java method for pre-processing + * @param args + * arguments of the Java method + * @return result of runnning Java pre-processing on the tensor + * @throws ClassNotFoundException if the pre-processing transformation is not found + */ + public static JavaProcessing definePreprocessing(String methodName, Map args) throws ClassNotFoundException { + return new JavaProcessing(methodName, args); + } + + /** + * Executes the Java pre-processing transformation specified + * on the rdf.yaml on the input map with the corresponding tensor name + * @param tensorSpec + * specs of the tensor where pre-processing is going to be executed + * @param inputMap + * map containing the inputs of the model + * @return a Map with the results of pre-processing the input tensor containing + * the inputs provided in the input map too. + * @throws IllegalArgumentException if the tensor that the pre-processing refers to is not found + */ + public Tensor execute(TensorSpec tensorSpec, Tensor input) + throws IllegalArgumentException { + this.tensorSpec = tensorSpec; + this.tensorName = tensorSpec.getName(); + this.tensor = input;; + LinkedHashMap resultsMap = executeJavaTransformation(); + return (Tensor) resultsMap.get(tensor.getName()); + } + + /** + * Fill the args map with variables provided by the input map. + * This is done to allow several pre- and post-processing that can be + * executed one after another + * @param inputsMap + * the provided map with different inputs + */ + private void fillArgs(Map inputsMap) { + // TODO decide whether to use a key word when one of the inputs to pre + // processing has to be given by the previous pre-processing or + // the arg should just be null + for (String kk : this.args.keySet()) { + if (this.args.get(kk) == null && inputsMap.get(kk) != null) { + this.args.put(kk, inputsMap.get(kk)); + } + } + } + + /** + * Method that adds the tensor to the input dictionary as a NDArray. + * NDArrays are the objects used by Java pre-processings so they can + * be shared among different Java softwares + * @param inputMap + * map of input tensors for the model + * @throws IllegalArgumentException if the tensor that the pre-processing refers to is not found + */ + private < T extends RealType< T > & NativeType< T > > void addTensorToInputs(Map inputMap) throws IllegalArgumentException { + Object inputTensor = inputMap.get(this.tensorName); + if (inputTensor == null) { + throw new IllegalArgumentException("There should be an input tensor called '" + + tensorName + "', but no object referring to it has been found."); + } + + if (inputTensor instanceof RandomAccessibleInterval) { + this.tensor = Tensor.build(tensorSpec.getName(), tensorSpec.getAxesOrder(), (RandomAccessibleInterval) inputTensor); + } else if (inputTensor instanceof Tensor) { + this.tensor = ((Tensor) inputTensor); + } + } + + /** + * Method used to convert Strings in using snake case (snake_case) into camel + * case with the first letter as upper case (CamelCase) + * @param str + * the String to be converted + * @return String converted into camel case with first upper + */ + public static String snakeCaseToCamelCaseFirstCap(String str) { + while(str.contains("_")) { + str = str.replaceFirst("_[a-z]", String.valueOf(Character.toUpperCase(str.charAt(str.indexOf("_") + 1)))); + } + str = str.substring(0, 1).toUpperCase() + str.substring(1); + return str; + } + + /** + * Method that checks if the pre-processing transformations specified in the + * rdf,yaml exist in the classpath + * @throws ClassNotFoundException if the transformations are not found in the classpath + */ + private void checkMethodExists() throws ClassNotFoundException { + if (rdfSpec.contains(".") && !rdfSpec.contains("::")) { + javaClassName = rdfSpec; + javaMethodName = bioImageIoExecutionMethodName; + findClassInClassPath(); + } else if (rdfSpec.contains(".") && rdfSpec.contains("::")) { + javaClassName = rdfSpec.substring(0, rdfSpec.indexOf("::")); + javaMethodName = rdfSpec.substring(rdfSpec.indexOf("::") + 2); + findClassInClassPath(); + } else { + findMethodInBioImageIo(); + } + } + + /** + * Tries to find a given class in the classpath + * @throws ClassNotFoundException if the class does not exist in the classpath + */ + private void findClassInClassPath() throws ClassNotFoundException { + Class.forName(this.javaClassName, false, JavaProcessing.class.getClassLoader()); + } + + /** + * Find of the transformation exists in the BioImage.io Java Core + * @throws ClassNotFoundException if the BioImage.io transformation does not exist + */ + private void findMethodInBioImageIo() throws ClassNotFoundException { + this.javaMethodName = snakeCaseToCamelCaseFirstCap(this.rdfSpec) + "Transformation"; + this.javaClassName = BIOIMAGEIO_TRANSFORMATIONS_PACKAGE + this.javaMethodName; + findClassInClassPath(); + this.javaMethodName = bioImageIoExecutionMethodName; + } + + /** + * Execute the transformation form the BioImage.io defined in the rdf.yaml + * @throws IllegalArgumentException if the transformation is not correctly defined, + * does not exist or is missing any argument + */ + private LinkedHashMap executeJavaTransformation() throws IllegalArgumentException { + try { + return runJavaTransformationWithArgs(); + + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException("Processing method '" + this.rdfSpec +"' not found" + + " in the BioImage.io Java Core Transformations or in the Java Classpath: " + + "https://github.com/bioimage-io/model-runner-java/tree/nd4j/src/main/java/org/bioimageanalysis/icy/deeplearning/transformations" + + ". " + System.lineSeparator() + e.getCause()); + } catch (InstantiationException e) { + e.printStackTrace(); + throw new IllegalArgumentException("Processing method '" + this.rdfSpec +"' failed" + + " due to an error instantiating the class that defines the transformation (" + + this.javaClassName + "). Go to the following link to see valid transformations:" + + "https://github.com/bioimage-io/core-bioimage-io-java/tree/master/src/main/java/io/bioimage/specification/transformation" + + ". " + System.lineSeparator() + e.getCause()); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new IllegalArgumentException("Processing method '" + this.rdfSpec +"' failed" + + " throwing an IllegalAccessException." + + " Go to the following link to see valid transformations:" + + "https://github.com/bioimage-io/core-bioimage-io-java/tree/master/src/main/java/io/bioimage/specification/transformation" + + ". " + System.lineSeparator() + e.getCause()); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new IllegalArgumentException("Processing method '" + this.rdfSpec +"' failed" + + " throwing an InvocationTargetException." + + " Go to the following link to see valid transformations:" + + "https://github.com/bioimage-io/core-bioimage-io-java/tree/master/src/main/java/io/bioimage/specification/transformation" + + ". " + System.lineSeparator() + System.lineSeparator() + e.getCause()); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + throw new IllegalArgumentException("Processing method '" + this.rdfSpec +"' failed" + + " because the method needed to call the transformation (" + this.javaMethodName + + ") was not found in the transformation class (" + + this.javaClassName + "). Go to the following link to see valid transformations:" + + "https://github.com/bioimage-io/core-bioimage-io-java/tree/master/src/main/java/io/bioimage/specification/transformation" + + ". " + System.lineSeparator() + e.getCause()); + } catch (SecurityException e) { + e.printStackTrace(); + throw new IllegalArgumentException("Processing method '" + this.rdfSpec +"' failed" + + " throwing an SecurityException." + + " Go to the following link to see valid transformations:" + + "https://github.com/bioimage-io/core-bioimage-io-java/tree/master/src/main/java/io/bioimage/specification/transformation" + + ". " + System.lineSeparator() + e.getCause()); + } + } + + /** + * Run the transformation from the Java transformation class + * @throws IllegalAccessException if the method or class cannot be accessed with reflection + * @throws InstantiationException if there is an error instantiating the transformation class + * @throws InvocationTargetException if there is any error invoking the methods + * @throws IllegalArgumentException if any of the arguments provided with reflection is illegal + * @throws SecurityException if there is any security breach + * @throws NoSuchMethodException if the method tried to run does not exist + * @throws ClassNotFoundException if the class referenced for the transformation does not exist + */ + private LinkedHashMap runJavaTransformationWithArgs() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException { + this.transformationClass = getClass().getClassLoader().loadClass(this.javaClassName); + Method[] publicMethods = this.transformationClass.getMethods(); + Method transformationMethod = null; + for (Method mm : publicMethods) { + if (mm.getName().equals(this.javaMethodName)) { + transformationMethod = mm; + break; + } + } + if (transformationMethod == null) + throw new IllegalArgumentException("The pre-processing transformation class does not contain" + + "the method '" + this.javaMethodName + "' needed to call the transformation."); + // Check that the arguments specified in the rdf.yaml are of the corect type + return executeMethodWithArgs(transformationMethod); + } + + /** + * + * @param mm + * @return + * @throws InstantiationException if there is any error instantiating the class + * @throws if it is illegal to instantiate the class or to call the method + * @throws IllegalArgumentException if any of the arguments for the method is wrong + * @throws InvocationTargetException if the target of the method is incorrectly captured + * @throws SecurityException if there is any security violation + * @throws NoSuchMethodException if the constructor with the needed argument does not exist + */ + private > LinkedHashMap executeMethodWithArgs(Method mm) throws InstantiationException, + IllegalAccessException, + IllegalArgumentException, + InvocationTargetException, NoSuchMethodException, SecurityException { + + + LinkedHashMap resultsMap = new LinkedHashMap(); + Object instance = createInstanceWitArgs(); + + if (mm.getReturnType().equals(Void.TYPE)) { + mm.invoke(instance, tensor); + resultsMap.put(tensorName, tensor); + } else { + Object returnObject = mm.invoke(instance, tensor); + // Depending on what the output is, do one thing or another + if ((returnObject instanceof HashMap) || (returnObject instanceof HashMap)) { + // If the output is a HashMap, assume the pre-processing already provides + // the inputs map of the model + resultsMap = (LinkedHashMap) returnObject; + } else if (returnObject instanceof RandomAccessibleInterval) { + resultsMap.put(tensorName, (RandomAccessibleInterval) returnObject); + } else if (returnObject instanceof Tensor) { + resultsMap.put(tensorName, (Tensor) returnObject); + } else { + throw new IllegalArgumentException("The processing transformation '" + + rdfSpec + "' corresponding to tensor '" + tensorName + + "' outputs an object whose Type is not supported as" + + " an output for transformations in DeepIcy. The supported " + + " Types are Icy Sequences, Icy Tensors, NDArrays and Maps or" + + " HashMaps."); + } + } + return resultsMap; + } + + /** + * + * @return + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InvocationTargetException + * @throws InstantiationException + * @throws NoSuchMethodException + * @throws SecurityException + */ + public Object createInstanceWitArgs() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException, SecurityException { + // The instance of the pre-processing transformation should be initialized + // with the corresponding input tensor + Object transformationObject = transformationClass.getConstructor().newInstance(); + for (String arg : this.args.keySet()) { + setArg(transformationObject, arg); + } + return transformationObject; + } + + /** + * Set the argument in the processing trasnformation instance + * @param instance + * instance of the processing trasnformation + * @param argName + * name of the argument + * @throws IllegalArgumentException if no method is found for the given argument + * @throws InvocationTargetExceptionif there is any error invoking the method + * @throws IllegalAccessException if it is illegal to access the method + */ + public void setArg(Object instance, String argName) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { + String mName = getArgumentSetterName(argName); + Method mm = checkArgType(argName, mName); + mm.invoke(instance, args.get(argName)); + } + + /** + * Get the setter that the Java transformation class uses to set the argument of the + * pre-processing. The setter has to be named as the argument but in CamelCase with the + * first letter in upper case and preceded by set. For example: min_distance -> setMinDistance + * @param argName + * the name of the argument + * @return the method name + * @throws IllegalArgumentException if no method is found for the given argument + */ + public String getArgumentSetterName(String argName) throws IllegalArgumentException { + String mName = "set" + snakeCaseToCamelCaseFirstCap(argName); + // Check that the method exists + Method[] methods = transformationClass.getMethods(); + for (Method mm : methods) { + if (mm.getName().equals(mName)) + return mName; + } + throw new IllegalArgumentException("Setter for argument '" + argName + "' of the processing " + + "transformation '" + rdfSpec + "' of tensor '" + tensorName + + "' not found in the Java transformation class '" + this.javaClassName + "'. " + + "A method called '" + mName + "' should be present."); + } + + /** + * Method that checks that the type of the arguments provided in the rdf.yaml is correct. + * It also returns the setter method to set the argument + * + * @param mm + * the method that executes the pre-processing transformation + * @return the method used to provide the argument to the instance + * @throws IllegalArgumentException if any of the arguments' type is not correct + */ + private Method checkArgType(String argName, String mName) throws IllegalArgumentException { + Object arg = this.args.get(argName); + Method[] methods = this.transformationClass.getMethods(); + List possibleMethods = new ArrayList(); + for (Method mm : methods) { + if (mm.getName().equals(mName)) + possibleMethods.add(mm); + } + if (possibleMethods.size() == 0) + getArgumentSetterName(argName); + for (Method mm : possibleMethods) { + Parameter[] pps = mm.getParameters(); + if (pps.length != 1) { + continue; + } + if (pps[0].getType() == Object.class) + return mm; + } + throw new IllegalArgumentException("Setter '" + mName + "' should have only one input parameter with type Object.class."); + } +} From fb0477c7f03b4c3a845616b48bc540a238ae7753 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 11:54:31 +0200 Subject: [PATCH 002/150] update jdll version --- scripts/check_compatiblity_icy/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_compatiblity_icy/pom.xml b/scripts/check_compatiblity_icy/pom.xml index 8d225793..84582259 100644 --- a/scripts/check_compatiblity_icy/pom.xml +++ b/scripts/check_compatiblity_icy/pom.xml @@ -79,7 +79,7 @@ apache_v2 Institut Pasteur - 0.5.5-SNAPSHOT + 0.5.8-SNAPSHOT From 298bfc126f76cc5760c895ed7ddd57152d5b9953 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 11:55:58 +0200 Subject: [PATCH 003/150] listen to folder to trigger workflow --- .github/workflows/check_compatibility_icy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 0d47bb84..7cdadd97 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -8,7 +8,7 @@ on: - main paths: - .github/workflows/check_compatibility_icy.yaml - - scripts/check_compatibility_icy.py + - scripts/check_compatibility_icy workflow_dispatch: schedule: - cron: 0 1 * * * # update compatibility once a day From 0ce6e423a1d781186d384753d8bb45e8d97db02f Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 16:02:04 +0200 Subject: [PATCH 004/150] add class to download engines, different for Icy and DIJ --- .github/workflows/build.yaml | 2 +- .../workflows/generate_collection_json.yaml | 4 +- scripts/check_compatiblity_icy/.gitignore | 16 +++ .../modelrunner/ci/DownloadEngines.java | 106 ++++++++++++++++++ .../ci/EngineInstallationProgress.java | 87 ++++++++++++++ 5 files changed, 212 insertions(+), 3 deletions(-) create mode 100644 scripts/check_compatiblity_icy/.gitignore create mode 100644 scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java create mode 100644 scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/EngineInstallationProgress.java diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b495c54e..06785c30 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,6 @@ name: test backoffice and build docs -on: push +#on: push concurrency: test diff --git a/.github/workflows/generate_collection_json.yaml b/.github/workflows/generate_collection_json.yaml index a38d7c4a..653e724c 100644 --- a/.github/workflows/generate_collection_json.yaml +++ b/.github/workflows/generate_collection_json.yaml @@ -3,8 +3,8 @@ run-name: generate collection on: workflow_dispatch: - push: - branches: [main] + #push: + #branches: [main] concurrency: generate-collection-json diff --git a/scripts/check_compatiblity_icy/.gitignore b/scripts/check_compatiblity_icy/.gitignore new file mode 100644 index 00000000..7aa8b531 --- /dev/null +++ b/scripts/check_compatiblity_icy/.gitignore @@ -0,0 +1,16 @@ +/engines/ +/models/ + +# maven specific files +/target/ + +# eclipse specific files +/.settings/ +.classpath +.project + +# intellij specific files +.idea + +# miscellaneous +*.swp diff --git a/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java b/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java new file mode 100644 index 00000000..68f0b82b --- /dev/null +++ b/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java @@ -0,0 +1,106 @@ +/*- + * #%L + * This project performs Continuous Integration tasks on the JDLL library + * %% + * Copyright (C) 2023 Institut Pasteur. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package io.bioimage.modelrunner.ci; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.PathMatcher; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.jar.Manifest; +import java.util.stream.Collectors; + +import io.bioimage.modelrunner.bioimageio.BioimageioRepo; +import io.bioimage.modelrunner.bioimageio.description.ModelDescriptor; +import io.bioimage.modelrunner.bioimageio.description.TransformSpec; +import io.bioimage.modelrunner.bioimageio.description.exceptions.ModelSpecsException; +import io.bioimage.modelrunner.bioimageio.description.weights.ModelWeight; +import io.bioimage.modelrunner.bioimageio.description.weights.WeightFormat; +import io.bioimage.modelrunner.bioimageio.download.DownloadTracker; +import io.bioimage.modelrunner.bioimageio.download.DownloadTracker.TwoParameterConsumer; +import io.bioimage.modelrunner.engine.EngineInfo; +import io.bioimage.modelrunner.engine.installation.EngineInstall; +import io.bioimage.modelrunner.model.Model; +import io.bioimage.modelrunner.numpy.DecodeNumpy; +import io.bioimage.modelrunner.tensor.Tensor; +import io.bioimage.modelrunner.utils.Constants; +import io.bioimage.modelrunner.utils.YAMLUtils; +import io.bioimage.modelrunner.versionmanagement.InstalledEngines; +import net.imglib2.Cursor; +import net.imglib2.RandomAccessibleInterval; +import net.imglib2.loops.LoopBuilder; +import net.imglib2.type.NativeType; +import net.imglib2.type.numeric.RealType; +import net.imglib2.type.numeric.real.FloatType; +import net.imglib2.view.Views; + +/** + * + */ +public class DownloadEngines { + + public static final String DEEPIMAGEJ_TAG = "deepimagej"; + + public static final String ICY_TAG = "icy"; + /** + * Current directory + */ + private static final String CWD = new File("").getAbsolutePath(); + /** + * Directory where the engine will be downloaded, if you want to download it + * into another folder, please change it. + */ + private static final String ENGINES_DIR = new File(CWD, "engines").getAbsolutePath(); + + public static void main(String[] args) throws IOException, InterruptedException { + if (args[0].equals(DEEPIMAGEJ_TAG)) { + EngineInstall engineManager = EngineInstall.createInstaller(ENGINES_DIR); + Map> consumers = + new LinkedHashMap>(); + Thread checkAndInstallMissingEngines = new Thread(() -> { + consumers.putAll(engineManager.getBasicEnginesProgress()); + engineManager.basicEngineInstallation(); + }); + System.out.println("[DEBUG] Checking and installing missing engines"); + checkAndInstallMissingEngines.start(); + + String backup = ""; + EngineInstallationProgress installerInfo = new EngineInstallationProgress(); + while (!engineManager.isInstallationFinished()) { + Thread.sleep(300); + if (consumers.keySet().size() != 0) { + String progress = installerInfo.basicEnginesInstallationProgress(consumers); + System.out.println(progress); + } + } + } + } +} diff --git a/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/EngineInstallationProgress.java b/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/EngineInstallationProgress.java new file mode 100644 index 00000000..20503c56 --- /dev/null +++ b/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/EngineInstallationProgress.java @@ -0,0 +1,87 @@ +package io.bioimage.modelrunner.ci; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import io.bioimage.modelrunner.bioimageio.download.DownloadTracker; +import io.bioimage.modelrunner.bioimageio.download.DownloadTracker.TwoParameterConsumer; +import io.bioimage.modelrunner.utils.Log; + +public class EngineInstallationProgress { + + private static String TOTAL_PROGRESS_STRING = ""; + private static String TOTAL_REMAINING_STRING = ""; + private static int N_BINS = 10; + + private HashMap timesMap = new HashMap(); + + static { + for (int i = 0; i < N_BINS; i ++) { + TOTAL_PROGRESS_STRING += "#"; + TOTAL_REMAINING_STRING += "."; + } + } + + /** + * Create a String that summarizes the information about the download of the + * engines specifies by the parameter 'basicEng' and the real time information + * about the download contained in the consumer + * @param consumers + * @return + */ + public String basicEnginesInstallationProgress( + Map> consumers) { + + String progress = ""; + for (Entry> entry : consumers.entrySet()) { + TwoParameterConsumer consumer = entry.getValue(); + double totalProgress = consumer.get().keySet().contains(DownloadTracker.TOTAL_PROGRESS_KEY) ? + consumer.get().get(DownloadTracker.TOTAL_PROGRESS_KEY) : 0.0; + if (totalProgress == 0.0) + continue; + if (!this.timesMap.keySet().contains(entry.getKey())) + timesMap.put(entry.getKey(), Log.gct()); + String timeKey = timesMap.get(entry.getKey()); + progress += System.lineSeparator(); + progress += " - " + timeKey + " -- " + new File(entry.getKey()).getName(); + + progress += " " + getProgressPerc(totalProgress) + System.lineSeparator(); + for (Entry fEntry : consumer.get().entrySet()) { + if (fEntry.getKey().equals(DownloadTracker.TOTAL_PROGRESS_KEY)) + continue; + if (!this.timesMap.keySet().contains(fEntry.getKey())) + timesMap.put(fEntry.getKey(), Log.gct()); + String timeKey2 = timesMap.get(fEntry.getKey()); + progress += " -- " + timeKey2 + " -- " + new File(fEntry.getKey()).getName(); + progress += " " + getProgressPerc(fEntry.getValue()) + System.lineSeparator(); + + } + } + if (!progress.equals("") || consumers.keySet().size() == 0) + return progress; + for (Entry> entry : consumers.entrySet()) { + if (!this.timesMap.keySet().contains(entry.getKey())) + timesMap.put(entry.getKey(), Log.gct()); + String timeKey = timesMap.get(entry.getKey()); + progress += System.lineSeparator(); + progress += " - " + timeKey + " -- Installing: " + new File(entry.getKey()).getName(); + progress += " " + getProgressPerc(0) + System.lineSeparator(); + break; + } + return progress; + } + + private static String getProgressPerc(double progress) { + String progressStr = "[" + Math.round(progress * 100) + "%]"; + return progressStr; + } + + private static String getProgressBar(double progress) { + int nProgressBar = (int) (progress * N_BINS); + String progressStr = "[" + TOTAL_PROGRESS_STRING.substring(0, nProgressBar) + + TOTAL_REMAINING_STRING.substring(nProgressBar) + "] " + Math.round(progress * 100) + "%"; + return progressStr; + } +} From 5aeb5c442c08f3b95f19d7f7a8d7ee148913c4e8 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 16:31:34 +0200 Subject: [PATCH 005/150] download engines from action --- .github/workflows/check_compatibility_icy.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 7cdadd97..be4cb233 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -26,5 +26,8 @@ jobs: - name: Build with Maven run: | cd scripts/check_compatiblity_icy - mvn clean install + mvn clean compile org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration + - name: Build with Maven + run: | + java -cp target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej From 4acdc03e20971c1c67fa82baf54f6a8b9cac5640 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 16:34:53 +0200 Subject: [PATCH 006/150] install first --- .../workflows/check_compatibility_icy.yaml | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index be4cb233..45deb0c0 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -26,8 +26,28 @@ jobs: - name: Build with Maven run: | cd scripts/check_compatiblity_icy - mvn clean compile org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - - name: Build with Maven + mvn clean install + mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration + - name: Download engines run: | java -cp target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej + + run: + runs-on: ubuntu-latest + needs: setup + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + with: + repository: bioimage-io/collection-bioimage-io + ref: gh-pages + path: bioimageio-gh-pages + - name: Download JDLL engines + run: + - name: test with ilastik ${{ matrix.v }} + shell: bash -l {0} + run: python scripts/check_compatibility_ilastik.py ${{ matrix.v }} \ No newline at end of file From 4dbed35654770ce284eb624c88c999a53ec74b7b Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 16:39:11 +0200 Subject: [PATCH 007/150] correct error in syntax --- .github/workflows/check_compatibility_icy.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 45deb0c0..20150b19 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -26,7 +26,6 @@ jobs: - name: Build with Maven run: | cd scripts/check_compatiblity_icy - mvn clean install mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Download engines run: | From be38fa1224b044c6830f8d45a70e08656ab8acbc Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 16:40:06 +0200 Subject: [PATCH 008/150] remove problematic code --- .../workflows/check_compatibility_icy.yaml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 20150b19..3ef1e8e0 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -31,22 +31,3 @@ jobs: run: | java -cp target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej - - run: - runs-on: ubuntu-latest - needs: setup - strategy: - fail-fast: false - - steps: - - uses: actions/checkout@v3 - - uses: actions/checkout@v3 - with: - repository: bioimage-io/collection-bioimage-io - ref: gh-pages - path: bioimageio-gh-pages - - name: Download JDLL engines - run: - - name: test with ilastik ${{ matrix.v }} - shell: bash -l {0} - run: python scripts/check_compatibility_ilastik.py ${{ matrix.v }} \ No newline at end of file From f8145d1b8c581fcc5b4f9195120420ba44902bfc Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 16:47:54 +0200 Subject: [PATCH 009/150] check the directory --- .github/workflows/check_compatibility_icy.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 3ef1e8e0..07c64dea 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -29,5 +29,6 @@ jobs: mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Download engines run: | + pwd java -cp target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej From cfccb6b3101899248097d7b12d1df2c06a444972 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 16:49:09 +0200 Subject: [PATCH 010/150] correct directory --- .github/workflows/check_compatibility_icy.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 07c64dea..2f0cf0e3 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -29,6 +29,5 @@ jobs: mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Download engines run: | - pwd - java -cp target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej + java -cp scripts/check_compatiblity_icy/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej From 0a4b3e4dc8fb8602a59aaedf89049cb6decd6be9 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 16:52:54 +0200 Subject: [PATCH 011/150] remove unnecessary classes for logging --- .../modelrunner/ci/DownloadEngines.java | 54 +----------- .../ci/EngineInstallationProgress.java | 87 ------------------- 2 files changed, 1 insertion(+), 140 deletions(-) delete mode 100644 scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/EngineInstallationProgress.java diff --git a/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java b/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java index 68f0b82b..406eb05b 100644 --- a/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java +++ b/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java @@ -21,46 +21,11 @@ import java.io.File; import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.PathMatcher; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; -import java.util.Map.Entry; -import java.util.jar.Manifest; -import java.util.stream.Collectors; -import io.bioimage.modelrunner.bioimageio.BioimageioRepo; -import io.bioimage.modelrunner.bioimageio.description.ModelDescriptor; -import io.bioimage.modelrunner.bioimageio.description.TransformSpec; -import io.bioimage.modelrunner.bioimageio.description.exceptions.ModelSpecsException; -import io.bioimage.modelrunner.bioimageio.description.weights.ModelWeight; -import io.bioimage.modelrunner.bioimageio.description.weights.WeightFormat; -import io.bioimage.modelrunner.bioimageio.download.DownloadTracker; import io.bioimage.modelrunner.bioimageio.download.DownloadTracker.TwoParameterConsumer; -import io.bioimage.modelrunner.engine.EngineInfo; import io.bioimage.modelrunner.engine.installation.EngineInstall; -import io.bioimage.modelrunner.model.Model; -import io.bioimage.modelrunner.numpy.DecodeNumpy; -import io.bioimage.modelrunner.tensor.Tensor; -import io.bioimage.modelrunner.utils.Constants; -import io.bioimage.modelrunner.utils.YAMLUtils; -import io.bioimage.modelrunner.versionmanagement.InstalledEngines; -import net.imglib2.Cursor; -import net.imglib2.RandomAccessibleInterval; -import net.imglib2.loops.LoopBuilder; -import net.imglib2.type.NativeType; -import net.imglib2.type.numeric.RealType; -import net.imglib2.type.numeric.real.FloatType; -import net.imglib2.view.Views; /** * @@ -83,24 +48,7 @@ public class DownloadEngines { public static void main(String[] args) throws IOException, InterruptedException { if (args[0].equals(DEEPIMAGEJ_TAG)) { EngineInstall engineManager = EngineInstall.createInstaller(ENGINES_DIR); - Map> consumers = - new LinkedHashMap>(); - Thread checkAndInstallMissingEngines = new Thread(() -> { - consumers.putAll(engineManager.getBasicEnginesProgress()); - engineManager.basicEngineInstallation(); - }); - System.out.println("[DEBUG] Checking and installing missing engines"); - checkAndInstallMissingEngines.start(); - - String backup = ""; - EngineInstallationProgress installerInfo = new EngineInstallationProgress(); - while (!engineManager.isInstallationFinished()) { - Thread.sleep(300); - if (consumers.keySet().size() != 0) { - String progress = installerInfo.basicEnginesInstallationProgress(consumers); - System.out.println(progress); - } - } + engineManager.basicEngineInstallation(); } } } diff --git a/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/EngineInstallationProgress.java b/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/EngineInstallationProgress.java deleted file mode 100644 index 20503c56..00000000 --- a/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/EngineInstallationProgress.java +++ /dev/null @@ -1,87 +0,0 @@ -package io.bioimage.modelrunner.ci; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import io.bioimage.modelrunner.bioimageio.download.DownloadTracker; -import io.bioimage.modelrunner.bioimageio.download.DownloadTracker.TwoParameterConsumer; -import io.bioimage.modelrunner.utils.Log; - -public class EngineInstallationProgress { - - private static String TOTAL_PROGRESS_STRING = ""; - private static String TOTAL_REMAINING_STRING = ""; - private static int N_BINS = 10; - - private HashMap timesMap = new HashMap(); - - static { - for (int i = 0; i < N_BINS; i ++) { - TOTAL_PROGRESS_STRING += "#"; - TOTAL_REMAINING_STRING += "."; - } - } - - /** - * Create a String that summarizes the information about the download of the - * engines specifies by the parameter 'basicEng' and the real time information - * about the download contained in the consumer - * @param consumers - * @return - */ - public String basicEnginesInstallationProgress( - Map> consumers) { - - String progress = ""; - for (Entry> entry : consumers.entrySet()) { - TwoParameterConsumer consumer = entry.getValue(); - double totalProgress = consumer.get().keySet().contains(DownloadTracker.TOTAL_PROGRESS_KEY) ? - consumer.get().get(DownloadTracker.TOTAL_PROGRESS_KEY) : 0.0; - if (totalProgress == 0.0) - continue; - if (!this.timesMap.keySet().contains(entry.getKey())) - timesMap.put(entry.getKey(), Log.gct()); - String timeKey = timesMap.get(entry.getKey()); - progress += System.lineSeparator(); - progress += " - " + timeKey + " -- " + new File(entry.getKey()).getName(); - - progress += " " + getProgressPerc(totalProgress) + System.lineSeparator(); - for (Entry fEntry : consumer.get().entrySet()) { - if (fEntry.getKey().equals(DownloadTracker.TOTAL_PROGRESS_KEY)) - continue; - if (!this.timesMap.keySet().contains(fEntry.getKey())) - timesMap.put(fEntry.getKey(), Log.gct()); - String timeKey2 = timesMap.get(fEntry.getKey()); - progress += " -- " + timeKey2 + " -- " + new File(fEntry.getKey()).getName(); - progress += " " + getProgressPerc(fEntry.getValue()) + System.lineSeparator(); - - } - } - if (!progress.equals("") || consumers.keySet().size() == 0) - return progress; - for (Entry> entry : consumers.entrySet()) { - if (!this.timesMap.keySet().contains(entry.getKey())) - timesMap.put(entry.getKey(), Log.gct()); - String timeKey = timesMap.get(entry.getKey()); - progress += System.lineSeparator(); - progress += " - " + timeKey + " -- Installing: " + new File(entry.getKey()).getName(); - progress += " " + getProgressPerc(0) + System.lineSeparator(); - break; - } - return progress; - } - - private static String getProgressPerc(double progress) { - String progressStr = "[" + Math.round(progress * 100) + "%]"; - return progressStr; - } - - private static String getProgressBar(double progress) { - int nProgressBar = (int) (progress * N_BINS); - String progressStr = "[" + TOTAL_PROGRESS_STRING.substring(0, nProgressBar) - + TOTAL_REMAINING_STRING.substring(nProgressBar) + "] " + Math.round(progress * 100) + "%"; - return progressStr; - } -} From 6ed26510db9195db9e0bc697e994ed40887b0287 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 16:54:26 +0200 Subject: [PATCH 012/150] do not trigger build --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 06785c30..0295e9af 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,6 @@ name: test backoffice and build docs -#on: push +on: #push concurrency: test From af205f67e0ef31f7d033524272ebe93201f8551e Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 16:55:35 +0200 Subject: [PATCH 013/150] avoid triggering it while developping --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0295e9af..7c04c648 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,6 @@ name: test backoffice and build docs -on: #push +on: pull concurrency: test From fbc24c17ed270fe0d1e91f6b177ae2a9f2cd8a82 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 16:56:36 +0200 Subject: [PATCH 014/150] correct name of folder --- .github/workflows/check_compatibility_icy.yaml | 2 +- .../.gitignore | 0 .../{check_compatiblity_icy => check_compatibility_icy}/pom.xml | 0 .../java/io/bioimage/modelrunner/ci/ContinuousIntegration.java | 0 .../main/java/io/bioimage/modelrunner/ci/DownloadEngines.java | 0 .../main/java/io/bioimage/modelrunner/ci/JavaProcessing.java | 0 6 files changed, 1 insertion(+), 1 deletion(-) rename scripts/{check_compatiblity_icy => check_compatibility_icy}/.gitignore (100%) rename scripts/{check_compatiblity_icy => check_compatibility_icy}/pom.xml (100%) rename scripts/{check_compatiblity_icy => check_compatibility_icy}/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java (100%) rename scripts/{check_compatiblity_icy => check_compatibility_icy}/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java (100%) rename scripts/{check_compatiblity_icy => check_compatibility_icy}/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java (100%) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 2f0cf0e3..ca810d8a 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -29,5 +29,5 @@ jobs: mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Download engines run: | - java -cp scripts/check_compatiblity_icy/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej + java -cp scripts/check_compatibility_icy/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej diff --git a/scripts/check_compatiblity_icy/.gitignore b/scripts/check_compatibility_icy/.gitignore similarity index 100% rename from scripts/check_compatiblity_icy/.gitignore rename to scripts/check_compatibility_icy/.gitignore diff --git a/scripts/check_compatiblity_icy/pom.xml b/scripts/check_compatibility_icy/pom.xml similarity index 100% rename from scripts/check_compatiblity_icy/pom.xml rename to scripts/check_compatibility_icy/pom.xml diff --git a/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java similarity index 100% rename from scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java rename to scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java diff --git a/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java b/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java similarity index 100% rename from scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java rename to scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java diff --git a/scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java b/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java similarity index 100% rename from scripts/check_compatiblity_icy/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java rename to scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java From 10268b9d11e7f69789708e315fcdf6a6c3176840 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 16:57:59 +0200 Subject: [PATCH 015/150] correct dir name --- .github/workflows/build.yaml | 4 +++- .github/workflows/check_compatibility_icy.yaml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7c04c648..9f4afe1a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,8 @@ name: test backoffice and build docs -on: pull +on: + branches: + - doesnt-exist concurrency: test diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index ca810d8a..6e310135 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -25,7 +25,7 @@ jobs: maven-version: 3.9.5 - name: Build with Maven run: | - cd scripts/check_compatiblity_icy + cd scripts/check_compatibility_icy mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Download engines run: | From a9b76be4698b88f3e6f0aa7c90a4cabfa8495fed Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 17:06:07 +0200 Subject: [PATCH 016/150] add useful prints --- .../java/io/bioimage/modelrunner/ci/DownloadEngines.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java b/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java index 406eb05b..fdd6bb95 100644 --- a/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java +++ b/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java @@ -21,14 +21,14 @@ import java.io.File; import java.io.IOException; -import java.util.LinkedHashMap; -import java.util.Map; -import io.bioimage.modelrunner.bioimageio.download.DownloadTracker.TwoParameterConsumer; import io.bioimage.modelrunner.engine.installation.EngineInstall; +import io.bioimage.modelrunner.versionmanagement.InstalledEngines; /** + * Class to install the engines that a DIJ or Icy distribution would install * + * @author Carlos Javier GArcia Lopez de Haro */ public class DownloadEngines { @@ -49,6 +49,8 @@ public static void main(String[] args) throws IOException, InterruptedException if (args[0].equals(DEEPIMAGEJ_TAG)) { EngineInstall engineManager = EngineInstall.createInstaller(ENGINES_DIR); engineManager.basicEngineInstallation(); + //InstalledEngines.buildEnginesFinder(ENGINES_DIR).getDownloadedForOS().stream().map(i -> i.toString()) + System.out.println(InstalledEngines.buildEnginesFinder(ENGINES_DIR).getDownloadedForOS()); } } } From 0bf128ace3aede49741624dc50a7e5bd9048ea95 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 17:16:39 +0200 Subject: [PATCH 017/150] ensure the change happens on every subfodler --- .github/workflows/check_compatibility_icy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 6e310135..d3227fbf 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -8,7 +8,7 @@ on: - main paths: - .github/workflows/check_compatibility_icy.yaml - - scripts/check_compatibility_icy + - scripts/check_compatibility_icy/**/* workflow_dispatch: schedule: - cron: 0 1 * * * # update compatibility once a day From 305374efb414c5c09837f908180ff14f3923b6e1 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 18:34:51 +0200 Subject: [PATCH 018/150] add job that runs models --- .../workflows/check_compatibility_icy.yaml | 11 +++ scripts/check_compatibility_icy.py | 78 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 scripts/check_compatibility_icy.py diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index d3227fbf..558db612 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -18,6 +18,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + with: + repository: bioimage-io/collection-bioimage-io + ref: gh-pages + path: bioimageio-gh-pages - name: Setup Maven Action uses: stCarolas/setup-maven@v4.5 with: @@ -30,4 +35,10 @@ jobs: - name: Download engines run: | java -cp scripts/check_compatibility_icy/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej + run: + runs-on: ubuntu-lastest + steps: + - name: Run models + run: | + java -cp scripts/check_compatibility_icy/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.ContinuousIntegration diff --git a/scripts/check_compatibility_icy.py b/scripts/check_compatibility_icy.py new file mode 100644 index 00000000..e23a2ff9 --- /dev/null +++ b/scripts/check_compatibility_icy.py @@ -0,0 +1,78 @@ +import argparse + +import bioimageio.core +from loguru import logger +from ruyaml import YAML + +from bioimageio_collection_backoffice.db_structure.compatibility import ( + CompatiblityReport, +) +from bioimageio_collection_backoffice.remote_collection import Record, RemoteCollection +from bioimageio_collection_backoffice.s3_client import Client + +if bioimageio.core.__version__.startswith("0.5."): + from bioimageio.core import test_resource as test_model +else: + from bioimageio.core import test_model + +yaml = YAML(typ="safe") + + +def check_compatibility_icy_impl( + record: Record, + tool: str, +): + report_path = record.get_compatibility_report_path(tool) + if list(record.client.ls(report_path)): + return + + rdf_data = record.client.load_file(record.rdf_path) + assert rdf_data is not None + rdf = yaml.load(rdf_data) + assert isinstance(rdf, dict) + if rdf.get("type") != "model": + return CompatiblityReport( + tool=tool, + status="not-applicable", + error=None, + details="only 'model' resources can be used in icy.", + ) + + # produce test summaries for each weight format + summary = test_model(record.client.get_file_url(record.rdf_path)) + + return CompatiblityReport( + tool=tool, + status=summary.status, + error=None if summary.status == "passed" else summary.format(), + details=summary, + links=["icy/icy"], + ) + + +def check_compatibility_icy( + icy_version: str, +): + """preliminary icy check + + only checks if test outputs are reproduced for onnx, torchscript, or pytorch_state_dict weights. + + """ + collection = RemoteCollection(Client()) + for record in collection.get_published_versions(): + try: + report = check_compatibility_icy_impl( + record, f"icy{icy_version}" + ) + except Exception as e: + logger.error(f"failed to check '{record.id}': {e}") + else: + if report is not None: + record.set_compatibility_report(report) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + _ = parser.add_argument("icy_version") + + check_compatibility_icy(parser.parse_args().icy_version) From 4bb3619e7b20e92b954947b91d90d1c74f3ffe38 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 18:38:37 +0200 Subject: [PATCH 019/150] needs previous run --- .github/workflows/check_compatibility_icy.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 558db612..532843f7 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -16,6 +16,9 @@ on: jobs: setup: runs-on: ubuntu-latest + needs: setup + strategy: + fail-fast: false steps: - uses: actions/checkout@v3 - uses: actions/checkout@v3 From 41d53e3621bd77943effd4038fd3114c1472378f Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 18:39:15 +0200 Subject: [PATCH 020/150] correct where to put needs --- .github/workflows/check_compatibility_icy.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 532843f7..4b780413 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -16,9 +16,6 @@ on: jobs: setup: runs-on: ubuntu-latest - needs: setup - strategy: - fail-fast: false steps: - uses: actions/checkout@v3 - uses: actions/checkout@v3 @@ -40,6 +37,9 @@ jobs: java -cp scripts/check_compatibility_icy/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej run: runs-on: ubuntu-lastest + needs: setup + strategy: + fail-fast: false steps: - name: Run models run: | From 132dfa7c81a7ff7c0c6cc3df4da7bb0628c36310 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 18:42:30 +0200 Subject: [PATCH 021/150] just a single job --- .github/workflows/check_compatibility_icy.yaml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 4b780413..d79a9199 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -14,8 +14,10 @@ on: - cron: 0 1 * * * # update compatibility once a day jobs: - setup: + run: runs-on: ubuntu-latest + strategy: + fail-fast: false steps: - uses: actions/checkout@v3 - uses: actions/checkout@v3 @@ -35,12 +37,6 @@ jobs: - name: Download engines run: | java -cp scripts/check_compatibility_icy/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej - run: - runs-on: ubuntu-lastest - needs: setup - strategy: - fail-fast: false - steps: - name: Run models run: | java -cp scripts/check_compatibility_icy/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.ContinuousIntegration From 239b1d63f88a95c85cbf1d1081e2f9a2a09d92ef Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 19:20:44 +0200 Subject: [PATCH 022/150] update jdll version --- scripts/check_compatibility_icy/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_compatibility_icy/pom.xml b/scripts/check_compatibility_icy/pom.xml index 84582259..cf80c081 100644 --- a/scripts/check_compatibility_icy/pom.xml +++ b/scripts/check_compatibility_icy/pom.xml @@ -79,7 +79,7 @@ apache_v2 Institut Pasteur - 0.5.8-SNAPSHOT + 0.5.8 From d4aad658e219f19b37345d61214d01574a21d150 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 13 Jun 2024 19:25:01 +0200 Subject: [PATCH 023/150] do two directories back --- .../java/io/bioimage/modelrunner/ci/ContinuousIntegration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java index d0686bd3..87b41e58 100644 --- a/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java +++ b/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java @@ -72,7 +72,7 @@ public static void main(String[] args) throws IOException { //String pendingMatrix = args[1]; Path currentDir = Paths.get(ContinuousIntegration.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent(); - Path rdfDir = currentDir.resolve("../bioimageio-gh-pages/rdfs").normalize(); + Path rdfDir = currentDir.resolve("../../../bioimageio-gh-pages/rdfs").normalize(); // Create a matcher for the pattern 'rdf.yaml' runTests(rdfDir, "**", "**", Paths.get("test_summaries"), null); From b9a57fb9638076aeeadddb4b592c946fc48a54ef Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 19 Jun 2024 19:05:45 +0200 Subject: [PATCH 024/150] check the artifacts that are produced --- .github/workflows/check_compatibility_icy.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index d79a9199..510c9902 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -40,4 +40,12 @@ jobs: - name: Run models run: | java -cp scripts/check_compatibility_icy/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.ContinuousIntegration + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + path: test_summaries + - name: Setup Maven Action + run: | + ls + ls test_summaries From ed329cc4920d85e24f9280a85765538cdc5dcfe2 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 25 Jun 2024 19:41:07 +0200 Subject: [PATCH 025/150] add part to upload changesusing python (python script still missing) --- .../workflows/check_compatibility_icy.yaml | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 510c9902..9ac347ff 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -44,8 +44,20 @@ jobs: uses: actions/upload-artifact@v3 with: path: test_summaries - - name: Setup Maven Action - run: | - ls - ls test_summaries + + + sendreport: + runs-on: ubuntu-latest + needs: run + steps: + - uses: actions/checkout@v3 + + - name: Get test results + uses: actions/upload-artifact@v3 + with: + path: test_summaries + + - name: test with ilastik ${{ matrix.v }} + shell: bash -l {0} + run: python scripts/upload_reports_java.py deepimagej From 03c8b8efaaeb9a2e2157db15f158fe96ea655d10 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 26 Jun 2024 14:16:37 +0200 Subject: [PATCH 026/150] start creating the python code to upload dij and icy tests --- .github/workflows/check_compatibility_icy.yaml | 9 ++++++--- ...y_icy.py => check_compatibility_java_software.py} | 12 ++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) rename scripts/{check_compatibility_icy.py => check_compatibility_java_software.py} (81%) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 9ac347ff..466941d3 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -53,11 +53,14 @@ jobs: - uses: actions/checkout@v3 - name: Get test results - uses: actions/upload-artifact@v3 + uses: actions/download-artifact@v3 with: path: test_summaries - - name: test with ilastik ${{ matrix.v }} + - name: check path + run: ls test_summaries + + - name: test with Java software ${{ matrix.v }} shell: bash -l {0} - run: python scripts/upload_reports_java.py deepimagej + run: python scripts/check_compatibility_java_software.py deepimagej 3.0.1 test_summaries diff --git a/scripts/check_compatibility_icy.py b/scripts/check_compatibility_java_software.py similarity index 81% rename from scripts/check_compatibility_icy.py rename to scripts/check_compatibility_java_software.py index e23a2ff9..aa4cf917 100644 --- a/scripts/check_compatibility_icy.py +++ b/scripts/check_compatibility_java_software.py @@ -51,7 +51,9 @@ def check_compatibility_icy_impl( def check_compatibility_icy( - icy_version: str, + software_name: str, + version: str, + summaries_dir: str = "test_summaries", ): """preliminary icy check @@ -62,7 +64,7 @@ def check_compatibility_icy( for record in collection.get_published_versions(): try: report = check_compatibility_icy_impl( - record, f"icy{icy_version}" + record, f"{software_name}{version}" ) except Exception as e: logger.error(f"failed to check '{record.id}': {e}") @@ -73,6 +75,8 @@ def check_compatibility_icy( if __name__ == "__main__": parser = argparse.ArgumentParser() - _ = parser.add_argument("icy_version") + _ = parser.add_argument("software_name") + _ = parser.add_argument("version") + _ = parser.add_argument("--summaries_dir", default="test_summaries", help="Directory path where summaries are stored.") - check_compatibility_icy(parser.parse_args().icy_version) + check_compatibility_icy(parser.parse_args().software_name, parser.parse_args().version, parser.parse_args().summaries_dir) From f2877b3fb9ea86b5c1fe6d7f58e7d0afead040ae Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 2 Jul 2024 19:27:22 +0200 Subject: [PATCH 027/150] keep working towards convergence of CI --- .../workflows/check_compatibility_icy.yaml | 5 +- scripts/check_compatibility_java_software.py | 133 ++++++++++++++++-- 2 files changed, 120 insertions(+), 18 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 466941d3..fdfb2517 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -57,10 +57,7 @@ jobs: with: path: test_summaries - - name: check path - run: ls test_summaries - - name: test with Java software ${{ matrix.v }} shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py deepimagej 3.0.1 test_summaries + run: python scripts/check_compatibility_java_software.py deepimagej 3.0.1 test_summaries/artifact diff --git a/scripts/check_compatibility_java_software.py b/scripts/check_compatibility_java_software.py index aa4cf917..041de6ff 100644 --- a/scripts/check_compatibility_java_software.py +++ b/scripts/check_compatibility_java_software.py @@ -1,8 +1,12 @@ import argparse +from typing import List, Dict, Any +import os + +import requests import bioimageio.core from loguru import logger -from ruyaml import YAML +from ruyaml import YAML, YAMLError from bioimageio_collection_backoffice.db_structure.compatibility import ( CompatiblityReport, @@ -15,13 +19,112 @@ else: from bioimageio.core import test_model +MAIN_TEST_NAME = "reproduce test outputs from test inputs" + yaml = YAML(typ="safe") -def check_compatibility_icy_impl( +def find_java_summaries(directory: str) -> List[str]: + """Walks through a directory and its subdirectories to find all YAML files.""" + yaml_files: List[str] = [] + # Walk through all directories and files in the specified directory + for root, _, files in os.walk(directory): + for file in files: + # Check if the file ends with .yaml or .yml + if file.endswith('.yaml') or file.endswith('.yml'): + # Create the full path to the file + full_path = os.path.join(root, file) + # Append the full path to the list of YAML files + yaml_files.append(full_path) + return yaml_files + + + +def read_yaml_from_url(url: str): + """Fetch and parse a YAML file from a specified URL. + + Args: + url (str): The URL of the YAML file. + + Returns: + dict: Parsed YAML data as a dictionary. + """ + response = requests.get(url) + response.raise_for_status() + + yaml=YAML(typ="safe") + data = yaml.load(response.text) + return data + + +def get_tests_from_summaries(rdf: str, path_to_summaries: str) -> Dict[str, str]: + summary = {} + try: + rdf_yaml = read_yaml_from_url(rdf) + except requests.RequestException as e: + summary["status"] = "failed" + summary["error"] = "Unable to access rdf.yaml file" + summary["details"] = str(e) + return summary + except YAMLError as e: + summary["status"] = "failed" + summary["error"] = "Unable to read rdf.yaml file" + summary["details"] = str(e) + return summary + + id = rdf_yaml["id"] + rdf_path = os.path.join(path_to_summaries, id) + test_files = os.listdir(rdf_path) + + if len(test_files) == 0: + summary["status"] = "failed" + summary["error"] = "No tests executed" + summary["details"] = "The model tests were not executed or the test files could not be located" + return summary + elif len(test_files) > 1: + raise Exception("Unexpected number of tests (" + str(len(test_files)) + ") found in the folder of interest") + + summaries_yaml = None + + try: + summaries_yaml=YAML(typ='safe') # default, if not specfied, is 'rt' (round-trip) + summaries_yaml.load(test_files[0]) + except YAMLError as e: + summary["status"] = "failed" + summary["error"] = "Unable to read the test results yaml file" + summary["details"] = str(e) + + summary = find_passed_test(summaries_yaml) + + return summary + + +def find_passed_test(summaries_yaml: List[Dict[Any, Any]]) -> Dict[Any, Any]: + summary = {} + for elem in summaries_yaml: + if not isinstance(elem, dict): + summary["status"] = "failed" + summary["error"] = "Invalid test output format" + summary["details"] = "Expected a list of dictionaries, but received an improperly formatted element." + return summary + + if elem.get("status") == "passed" and elem.get("name") != None and elem.get("name").contains(MAIN_TEST_NAME): + return elem + elif elem.get("status") != "passed" and elem.get("name") != None and elem.get("name").contains(MAIN_TEST_NAME): + summary["status"] = elem.get("status") + summary["error"] = elem.get("error") + summary["details"] = elem.get("traceback") + return summary + + + +def check_compatibility_java_software_impl( record: Record, - tool: str, + software_name: str, + version: str, + summaries_dir: str = "test_summaries/artifact", ): + tool = f"{software_name}{version}" report_path = record.get_compatibility_report_path(tool) if list(record.client.ls(report_path)): return @@ -37,20 +140,22 @@ def check_compatibility_icy_impl( error=None, details="only 'model' resources can be used in icy.", ) - + + #summaries = find_java_summaries(summaries_dir) + summary = get_tests_from_summaries(record.client.get_file_url(record.rdf_path), summaries_dir) # produce test summaries for each weight format - summary = test_model(record.client.get_file_url(record.rdf_path)) + # TODO check what it produces summary = test_model(record.client.get_file_url(record.rdf_path)) return CompatiblityReport( tool=tool, - status=summary.status, - error=None if summary.status == "passed" else summary.format(), - details=summary, - links=["icy/icy"], + status=summary["status"], + error=None if summary["status"] == "passed" else summary["error"], + details=summary["details"], + links=["{software_name}/{software_name}"], ) -def check_compatibility_icy( +def check_compatibility_java_software( software_name: str, version: str, summaries_dir: str = "test_summaries", @@ -63,8 +168,8 @@ def check_compatibility_icy( collection = RemoteCollection(Client()) for record in collection.get_published_versions(): try: - report = check_compatibility_icy_impl( - record, f"{software_name}{version}" + report = check_compatibility_java_software_impl( + record, software_name, version, summaries_dir ) except Exception as e: logger.error(f"failed to check '{record.id}': {e}") @@ -77,6 +182,6 @@ def check_compatibility_icy( parser = argparse.ArgumentParser() _ = parser.add_argument("software_name") _ = parser.add_argument("version") - _ = parser.add_argument("--summaries_dir", default="test_summaries", help="Directory path where summaries are stored.") + _ = parser.add_argument("--summaries_dir", default="test_summaries/artifact", help="Directory path where summaries are stored.") - check_compatibility_icy(parser.parse_args().software_name, parser.parse_args().version, parser.parse_args().summaries_dir) + check_compatibility_java_software(parser.parse_args().software_name, parser.parse_args().version, parser.parse_args().summaries_dir) From 6a705db1eae3be8dc96578d2eb311e1bfe1d1bf1 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 2 Jul 2024 19:36:19 +0200 Subject: [PATCH 028/150] separate the tests for icy and deepimagej --- .../check_compatibility_deepimagej.yaml | 63 +++++++++++++++++++ .../workflows/check_compatibility_icy.yaml | 10 +-- .../.gitignore | 0 .../pom.xml | 0 .../modelrunner/ci/ContinuousIntegration.java | 0 .../modelrunner/ci/DownloadEngines.java | 0 .../modelrunner/ci/JavaProcessing.java | 0 7 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/check_compatibility_deepimagej.yaml rename scripts/{check_compatibility_icy => check_compatibility_java_software}/.gitignore (100%) rename scripts/{check_compatibility_icy => check_compatibility_java_software}/pom.xml (100%) rename scripts/{check_compatibility_icy => check_compatibility_java_software}/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java (100%) rename scripts/{check_compatibility_icy => check_compatibility_java_software}/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java (100%) rename scripts/{check_compatibility_icy => check_compatibility_java_software}/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java (100%) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml new file mode 100644 index 00000000..24c608a4 --- /dev/null +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -0,0 +1,63 @@ +name: check compatibility deepimagej + +concurrency: deepimagej + +on: + push: + branches: + - main + paths: + - .github/workflows/check_compatibility_deepimagej.yaml + - scripts/check_compatibility_java_software/**/* + workflow_dispatch: + schedule: + - cron: 0 1 * * * # update compatibility once a day + +jobs: + run: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + with: + repository: bioimage-io/collection-bioimage-io + ref: gh-pages + path: bioimageio-gh-pages + - name: Setup Maven Action + uses: stCarolas/setup-maven@v4.5 + with: + java-version: 11 + maven-version: 3.9.5 + - name: Build with Maven + run: | + cd scripts/check_compatibility_java_software + mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration + - name: Download engines + run: | + java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej + - name: Run models + run: | + java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.ContinuousIntegration + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + path: test_summaries + + + sendreport: + runs-on: ubuntu-latest + needs: run + steps: + - uses: actions/checkout@v3 + + - name: Get test results + uses: actions/download-artifact@v3 + with: + path: test_summaries + + - name: test with Java software ${{ matrix.v }} + shell: bash -l {0} + run: python scripts/check_compatibility_java_software.py deepimagej 3.0.1 test_summaries/artifact + diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index fdfb2517..71b8c13f 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -8,7 +8,7 @@ on: - main paths: - .github/workflows/check_compatibility_icy.yaml - - scripts/check_compatibility_icy/**/* + - scripts/check_compatibility_java_software/**/* workflow_dispatch: schedule: - cron: 0 1 * * * # update compatibility once a day @@ -32,14 +32,14 @@ jobs: maven-version: 3.9.5 - name: Build with Maven run: | - cd scripts/check_compatibility_icy + cd scripts/check_compatibility_java_software mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Download engines run: | - java -cp scripts/check_compatibility_icy/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej + java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines icy - name: Run models run: | - java -cp scripts/check_compatibility_icy/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.ContinuousIntegration + java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.ContinuousIntegration - name: Upload artifacts uses: actions/upload-artifact@v3 with: @@ -59,5 +59,5 @@ jobs: - name: test with Java software ${{ matrix.v }} shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py deepimagej 3.0.1 test_summaries/artifact + run: python scripts/check_compatibility_java_software.py icy 3.0.1 test_summaries/artifact diff --git a/scripts/check_compatibility_icy/.gitignore b/scripts/check_compatibility_java_software/.gitignore similarity index 100% rename from scripts/check_compatibility_icy/.gitignore rename to scripts/check_compatibility_java_software/.gitignore diff --git a/scripts/check_compatibility_icy/pom.xml b/scripts/check_compatibility_java_software/pom.xml similarity index 100% rename from scripts/check_compatibility_icy/pom.xml rename to scripts/check_compatibility_java_software/pom.xml diff --git a/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java similarity index 100% rename from scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java rename to scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java diff --git a/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java similarity index 100% rename from scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java rename to scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java diff --git a/scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java similarity index 100% rename from scripts/check_compatibility_icy/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java rename to scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java From 82fd7b668f6a9d303fa1594e89215b4a5d9b979f Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 2 Jul 2024 20:14:10 +0200 Subject: [PATCH 029/150] install every engine for Icy --- .../java/io/bioimage/modelrunner/ci/DownloadEngines.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java index fdd6bb95..4774c5b8 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java @@ -21,8 +21,11 @@ import java.io.File; import java.io.IOException; +import java.util.List; import io.bioimage.modelrunner.engine.installation.EngineInstall; +import io.bioimage.modelrunner.versionmanagement.AvailableEngines; +import io.bioimage.modelrunner.versionmanagement.DeepLearningVersion; import io.bioimage.modelrunner.versionmanagement.InstalledEngines; /** @@ -51,6 +54,12 @@ public static void main(String[] args) throws IOException, InterruptedException engineManager.basicEngineInstallation(); //InstalledEngines.buildEnginesFinder(ENGINES_DIR).getDownloadedForOS().stream().map(i -> i.toString()) System.out.println(InstalledEngines.buildEnginesFinder(ENGINES_DIR).getDownloadedForOS()); + } else if (args[0].equals(ICY_TAG)) { + List allEngines = AvailableEngines.getForCurrentOS(); + for (DeepLearningVersion engine : allEngines) { + EngineInstall.installEngineInDir(engine, ENGINES_DIR); + } + System.out.println(InstalledEngines.buildEnginesFinder(ENGINES_DIR).getDownloadedForOS()); } } } From 41c2c7907b2bf8ce9738b426550906cfdf6b9383 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 3 Jul 2024 12:48:46 +0200 Subject: [PATCH 030/150] do not fail when an engine is not properly installed --- .../io/bioimage/modelrunner/ci/DownloadEngines.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java index 4774c5b8..7f371c4b 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java @@ -48,7 +48,7 @@ public class DownloadEngines { */ private static final String ENGINES_DIR = new File(CWD, "engines").getAbsolutePath(); - public static void main(String[] args) throws IOException, InterruptedException { + public static void main(String[] args) throws IOException { if (args[0].equals(DEEPIMAGEJ_TAG)) { EngineInstall engineManager = EngineInstall.createInstaller(ENGINES_DIR); engineManager.basicEngineInstallation(); @@ -57,7 +57,13 @@ public static void main(String[] args) throws IOException, InterruptedException } else if (args[0].equals(ICY_TAG)) { List allEngines = AvailableEngines.getForCurrentOS(); for (DeepLearningVersion engine : allEngines) { - EngineInstall.installEngineInDir(engine, ENGINES_DIR); + try { + EngineInstall.installEngineInDir(engine, ENGINES_DIR); + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } } System.out.println(InstalledEngines.buildEnginesFinder(ENGINES_DIR).getDownloadedForOS()); } From 313145e44688b3c24cdca7470d48b479c6ef218c Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 3 Jul 2024 12:51:50 +0200 Subject: [PATCH 031/150] remove bioimage.io python deps --- scripts/check_compatibility_java_software.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/check_compatibility_java_software.py b/scripts/check_compatibility_java_software.py index 041de6ff..7b7f26f9 100644 --- a/scripts/check_compatibility_java_software.py +++ b/scripts/check_compatibility_java_software.py @@ -4,7 +4,6 @@ import requests -import bioimageio.core from loguru import logger from ruyaml import YAML, YAMLError @@ -14,11 +13,6 @@ from bioimageio_collection_backoffice.remote_collection import Record, RemoteCollection from bioimageio_collection_backoffice.s3_client import Client -if bioimageio.core.__version__.startswith("0.5."): - from bioimageio.core import test_resource as test_model -else: - from bioimageio.core import test_model - MAIN_TEST_NAME = "reproduce test outputs from test inputs" yaml = YAML(typ="safe") @@ -174,6 +168,7 @@ def check_compatibility_java_software( except Exception as e: logger.error(f"failed to check '{record.id}': {e}") else: + print(report) if report is not None: record.set_compatibility_report(report) From 3d332bf365059162fbf71dcdf1f141b43c68e6b3 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 3 Jul 2024 14:55:35 +0200 Subject: [PATCH 032/150] correct code to make the results depend on software and version --- .../modelrunner/ci/ContinuousIntegration.java | 61 ++++++++----------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java index 87b41e58..97981d9d 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java @@ -1,6 +1,6 @@ /*- * #%L - * This project performs Continuous Integration tasks on the JDLL library + * This project performs Continuous Integration tasks on java software based on JDLL * %% * Copyright (C) 2023 Institut Pasteur. * %% @@ -67,22 +67,26 @@ public class ContinuousIntegration { private static Map downloadedModelsCorrectly = new HashMap(); private static Map downloadedModelsIncorrectly = new HashMap(); + private static String version; + + private static String software; + public static void main(String[] args) throws IOException { - - //String pendingMatrix = args[1]; + + software = args[0]; + version = args[1]; Path currentDir = Paths.get(ContinuousIntegration.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent(); Path rdfDir = currentDir.resolve("../../../bioimageio-gh-pages/rdfs").normalize(); // Create a matcher for the pattern 'rdf.yaml' - runTests(rdfDir, "**", "**", Paths.get("test_summaries"), null); + runTests(rdfDir, "**", "**", Paths.get("test_summaries")); } - public static void runTests(Path rdfDir, String resourceID, String versionID, Path summariesDir, String postfix) throws IOException { + public static void runTests(Path rdfDir, String resourceID, String versionID, Path summariesDir) throws IOException { LinkedHashMap summaryDefaults = new LinkedHashMap(); - postfix = getJDLLVersion(); - summaryDefaults.put("JDLL_VERSION", postfix); + summaryDefaults.put(software, version); PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + resourceID + File.separator + versionID + File.separator + Constants.RDF_FNAME); @@ -91,7 +95,7 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa installer.basicEngineInstallation(); for (Path rdfPath : rdfFiles) { - String testName = "Reproduce ouptuts with JDLL " + postfix; + String testName = "Reproduce ouptuts with " + software + " " + version; String error = null; String status = null; String traceback = null; @@ -144,7 +148,7 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa summaryMap.putAll(summaryDefaults); summary.add(summaryMap); - writeSummaries(summariesDir.toAbsolutePath() + File.separator + rdID + File.separator + "test_summary_" + postfix + ".yaml", summary); + writeSummaries(summariesDir.toAbsolutePath() + File.separator + rdID + File.separator + "test_summary_" + version + ".yaml", summary); continue; } @@ -197,7 +201,7 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa chosenSummaries.addAll(failedReproducedSummaries); chosenSummaries.addAll(otherSummaries); - writeSummaries(summariesDir.toAbsolutePath() + File.separator + rdID + File.separator + "test_summary_" + postfix + ".yaml", chosenSummaries); + writeSummaries(summariesDir.toAbsolutePath() + File.separator + rdID + File.separator + "test_summary_" + version + ".yaml", chosenSummaries); } } @@ -208,23 +212,6 @@ private static void writeSummaries(String summariesPath, List summaries) YAMLUtils.writeYamlFile(summariesPath, summaries); } - /** - * Code to automatically get the version of JDLL being used - * @return the JDLL version being used - */ - public static String getJDLLVersion() { - String version = "UNKNOWN"; - try (InputStream manifestStream = Tensor.class.getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF")) { - if (manifestStream != null) { - Manifest manifest = new Manifest(manifestStream); - java.util.jar.Attributes attrs = manifest.getMainAttributes(); - version = attrs.getValue("Implementation-Version"); - } - } catch (Exception e) { - } - return version; - } - private static List testResource(String rdf, WeightFormat weightFormat, int decimal, String expectedType) { String error = null; String traceback = null; @@ -243,7 +230,7 @@ private static List testResource(String rdf, WeightFormat weightFormat, loadTest.put("error", error); loadTest.put("source_name", rdf); loadTest.put("traceback", traceback); - loadTest.put("JDLL_VERSION", getJDLLVersion()); + loadTest.put(software, version); tests.add(loadTest); @@ -264,7 +251,7 @@ private static Map testExpectedResourceType(ModelDescriptor rd, typeTest.put("error", yes ? null : "expected type was " + type + " but found " + rd.getType()); typeTest.put("source_name", rd.getName()); typeTest.put("traceback", null); - typeTest.put("JDLL_VERSION", getJDLLVersion()); + typeTest.put(software, version); return typeTest; } @@ -278,12 +265,12 @@ private static Map testModelDownload(ModelDescriptor rd) { error = downloadModel(rd); } Map downloadTest = new LinkedHashMap(); - downloadTest.put("name", "JDLL is able to download model"); + downloadTest.put("name", software + " is able to download model"); downloadTest.put("status", error == null ? "passed" : "failed"); downloadTest.put("error", error == null ? null : "unable to download model"); downloadTest.put("traceback", error); downloadTest.put("source_name", rd.getName()); - downloadTest.put("JDLL_VERSION", getJDLLVersion()); + downloadTest.put(software, version); return downloadTest; } @@ -308,7 +295,7 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int Map inferTest = new LinkedHashMap(); inferTest.put("name", "reproduce test inputs from test outptus for " + ww.getFramework()); inferTest.put("source_name", rd.getName()); - inferTest.put("JDLL_VERSION", getJDLLVersion()); + inferTest.put(software, version); if (rd.getModelPath() == null) { inferTest.put("status", "failed"); inferTest.put("error", "model was not correctly downloaded"); @@ -343,7 +330,7 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int preproc = JavaProcessing.definePreprocessing(transform.getName(), transform.getKwargs()); } catch (Exception e) { e.printStackTrace(); - return failInferenceTest(rd.getName(), "pre-processing transformation not supported by JDLL: " + transform.getName(), stackTrace(e)); + return failInferenceTest(rd.getName(), "pre-processing transformation not supported by " + software + ": " + transform.getName(), stackTrace(e)); } inputTensor = preproc.execute(rd.getInputTensors().get(i), inputTensor); } @@ -358,7 +345,7 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int engineInfo = EngineInfo.defineCompatibleDLEngineWithRdfYamlWeights(ww); } catch (Exception e) { e.printStackTrace(); - return failInferenceTest(rd.getName(), "selected weights not supported by JDLL: " + ww.getFramework(), stackTrace(e)); + return failInferenceTest(rd.getName(), "selected weights not supported by " + software + ": " + ww.getFramework(), stackTrace(e)); } Model model; try { @@ -386,7 +373,7 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int preproc = JavaProcessing.definePreprocessing(transform.getName(), transform.getKwargs()); } catch (Exception e) { e.printStackTrace(); - return failInferenceTest(rd.getName(), "post-processing transformation not supported by JDLL: " + transform.getName(), stackTrace(e)); + return failInferenceTest(rd.getName(), "post-processing transformation not supported by " + software + ": " + transform.getName(), stackTrace(e)); } tt = preproc.execute(rd.getInputTensors().get(i), tt); } @@ -413,7 +400,7 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int typeTest.put("error", null); typeTest.put("source_name", rd.getName()); typeTest.put("traceback", null); - typeTest.put("JDLL_VERSION", getJDLLVersion()); + typeTest.put(software, version); return typeTest; } @@ -424,7 +411,7 @@ private static Map failInferenceTest(String sourceName, String e typeTest.put("error", error); typeTest.put("source_name", sourceName); typeTest.put("traceback", tb); - typeTest.put("JDLL_VERSION", getJDLLVersion()); + typeTest.put(software, version); return typeTest; } From 39a9fd329aaec70ab81855683980d3793a810470 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 4 Jul 2024 14:57:54 +0200 Subject: [PATCH 033/150] renew the way tests are created --- .../modelrunner/ci/ContinuousIntegration.java | 81 +++++++++++-------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java index 97981d9d..5ef96098 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java @@ -51,6 +51,7 @@ import io.bioimage.modelrunner.tensor.Tensor; import io.bioimage.modelrunner.utils.Constants; import io.bioimage.modelrunner.utils.YAMLUtils; +import io.bioimage.modelrunner.versionmanagement.AvailableEngines; import net.imglib2.Cursor; import net.imglib2.RandomAccessibleInterval; import net.imglib2.loops.LoopBuilder; @@ -70,6 +71,7 @@ public class ContinuousIntegration { private static String version; private static String software; + private static final String TEST_NAME = "reproduce test outputs from test inputs"; public static void main(String[] args) throws IOException { @@ -85,8 +87,6 @@ public static void main(String[] args) throws IOException { public static void runTests(Path rdfDir, String resourceID, String versionID, Path summariesDir) throws IOException { - LinkedHashMap summaryDefaults = new LinkedHashMap(); - summaryDefaults.put(software, version); PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + resourceID + File.separator + versionID + File.separator + Constants.RDF_FNAME); @@ -95,60 +95,51 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa installer.basicEngineInstallation(); for (Path rdfPath : rdfFiles) { - String testName = "Reproduce ouptuts with " + software + " " + version; - String error = null; - String status = null; - String traceback = null; + System.out.println(""); + System.out.println(""); + System.out.println(rdfPath); Map rdf = new LinkedHashMap(); try { rdf = YAMLUtils.load(rdfPath.toAbsolutePath().toString()); } catch (Exception ex) { - error = "Unable to load " + Constants.RDF_FNAME + ": " + ex.toString(); - status = "failed"; - traceback = stackTrace(ex); ex.printStackTrace(); + continue; } Object rdID = rdf.get("id"); + String summariesPath = summariesDir.toAbsolutePath() + File.separator + + (rdID != null ? rdID : "") + File.separator + "test_summary_" + software + "_" + version + ".yaml"; Object type = rdf.get("type"); Object weightFormats = rdf.get("weights"); if (rdID == null || !(rdID instanceof String)) { - System.out.println("Invalid RDF. Missing/Invalid 'id' in rdf: " + rdfPath.toString()); + new Exception(rdfPath.toAbsolutePath().toString() + " is missing ID field").printStackTrace(); + continue; } else if (type == null || !(type instanceof String) || !((String) type).equals("model")) { - status = "skipped"; - error = "not a model RDF"; + Map summary = create(rdfPath, TEST_NAME, "not-applicable", null, null, "not a model"); + writeSummary(summariesPath, summary); + continue; } else if (weightFormats == null || !(weightFormats instanceof Map)) { - status = "failed"; - error = "Missing weights dictionary for " + rdID; - traceback = weightFormats.toString(); + Map summary = create(rdfPath, TEST_NAME, + "failed", "Missing weights dictionary for " + rdID, null, weightFormats.toString()); + writeSummary(summariesPath, summary); + continue; } ModelWeight weights = null; try { weights = ModelWeight.build((Map) weightFormats); } catch (Exception ex) { - status = "failed"; - error = "Missing/Invalid weight formats for " + rdID; - traceback = stackTrace(ex); + Map summary = create(rdfPath, TEST_NAME, + "failed", "Missing/Invalid weight formats for " + rdID, stackTrace(ex), "Unable to read weight formats"); + writeSummary(summariesPath, summary); + continue; } if (weights != null && weights.gettAllSupportedWeightObjects().size() == 0) { - status = "failed"; - error = "Missing/Invalid weight formats. No supported weigths found for " + rdID; - } - - if (status != null) { - List summary = new ArrayList(); - Map summaryMap = new LinkedHashMap(); - summaryMap.put("name", testName); - summaryMap.put("status", status); - summaryMap.put("error", error); - summaryMap.put("source_name", rdfPath.toAbsolutePath().toString()); - summaryMap.put("traceback", traceback); - summaryMap.putAll(summaryDefaults); - summary.add(summaryMap); - - writeSummaries(summariesDir.toAbsolutePath() + File.separator + rdID + File.separator + "test_summary_" + version + ".yaml", summary); + Map summary = create(rdfPath, TEST_NAME, + "failed", "Unsupported model weights", null, "The model weights belong to a Deep Learning " + + "framework not supported by " + software + "_" + version + "."); + writeSummary(summariesPath, summary); continue; } @@ -205,6 +196,19 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa } } + private static Map create(Path rdfPath, String testName, String status, String error, + String tb, String details) { + Map summaryMap = new LinkedHashMap(); + summaryMap.put("name", testName); + summaryMap.put("status", status); + summaryMap.put("error", error); + summaryMap.put("source_name", rdfPath.toAbsolutePath().toString()); + summaryMap.put("traceback", tb); + summaryMap.put("details", details); + summaryMap.put(software, version);; + return summaryMap; + } + private static void writeSummaries(String summariesPath, List summaries) throws IOException { Path path = Paths.get(summariesPath).getParent(); if (path != null && !Files.exists(path)) @@ -212,6 +216,15 @@ private static void writeSummaries(String summariesPath, List summaries) YAMLUtils.writeYamlFile(summariesPath, summaries); } + private static void writeSummary(String summariesPath, Map summary) throws IOException { + List summaries = new ArrayList(); + summaries.add(summary); + Path path = Paths.get(summariesPath).getParent(); + if (path != null && !Files.exists(path)) + Files.createDirectories(path); + YAMLUtils.writeYamlFile(summariesPath, summaries); + } + private static List testResource(String rdf, WeightFormat weightFormat, int decimal, String expectedType) { String error = null; String traceback = null; From 9c8380d499ed0f7cbef334b8efb6e4ec924fa55d Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 4 Jul 2024 15:44:37 +0200 Subject: [PATCH 034/150] keep improving the java part of testing --- .../modelrunner/ci/ContinuousIntegration.java | 101 +++++------------- 1 file changed, 25 insertions(+), 76 deletions(-) diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java index 5ef96098..12e97fcc 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java @@ -149,50 +149,17 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa List summariesWeightFormat = new ArrayList(); Map summaryWeightFormat = new LinkedHashMap(); try { - summariesWeightFormat = testResource(rdfPath.toAbsolutePath().toString(), ww, 4, "model"); + summaryWeightFormat = testResource(rdfPath.toAbsolutePath().toString(), ww, 4, "model"); } catch (Exception ex) { ex.printStackTrace(); - summaryWeightFormat.put("name", testName); - summaryWeightFormat.put("status", "failed"); - summaryWeightFormat.put("error", "unable to perform tests"); - summaryWeightFormat.put("traceback", stackTrace(ex)); - summaryWeightFormat.put("source_name", rdfPath.toAbsolutePath().toString()); - summaryWeightFormat.putAll(summaryDefaults); - summariesWeightFormat.add(summaryWeightFormat); + summaryWeightFormat = create(rdfPath, TEST_NAME + " " + ww.getFramework(), "failed", "exception thrown during testing", + stackTrace(ex), "test was interrupted by an exception while testing" + ww.getFramework() + " weigths"); + } summariesPerWeightFormat.put(ww.getFramework(), summariesWeightFormat); } - - List passedReproducedSummaries = new ArrayList(); - List failedReproducedSummaries = new ArrayList(); - List otherSummaries = new ArrayList(); - List seenTests = new ArrayList(); - - for (Entry entry : summariesPerWeightFormat.entrySet()) { - String wf = entry.getKey(); - List> s = (List>) entry.getValue(); - for (Map ss : s) { - boolean isOther = !ss.get("name").equals("reproduce test outputs from test inputs"); - if (isOther && seenTests.contains(ss.toString())) { - continue; - } - ss.put("name", ss.get("name") + " (" + wf + ")"); - if (isOther) { - seenTests.add(ss.toString()); - otherSummaries.add(ss); - continue; - } - if (status != null && status.equals("passed")) passedReproducedSummaries.add(ss); - else failedReproducedSummaries.add(ss); - } - } - List chosenSummaries = new ArrayList(); - chosenSummaries.addAll(passedReproducedSummaries); - chosenSummaries.addAll(failedReproducedSummaries); - chosenSummaries.addAll(otherSummaries); - - writeSummaries(summariesDir.toAbsolutePath() + File.separator + rdID + File.separator + "test_summary_" + version + ".yaml", chosenSummaries); + writeSummary(summariesDir.toAbsolutePath() + File.separator + rdID + File.separator + "test_summary_" + version + ".yaml", chosenSummaries); } } @@ -225,50 +192,36 @@ private static void writeSummary(String summariesPath, Map summa YAMLUtils.writeYamlFile(summariesPath, summaries); } - private static List testResource(String rdf, WeightFormat weightFormat, int decimal, String expectedType) { - String error = null; - String traceback = null; + private static Map testResource(String rdf, WeightFormat weightFormat, int decimal, String expectedType) { ModelDescriptor rd = null; try { rd = ModelDescriptor.readFromLocalFile(rdf, false); } catch (ModelSpecsException e) { - error = "unable to read rdf.yaml file"; - traceback = stackTrace(e); + Map summary = create(Paths.get(rdf), TEST_NAME, + "failed", "Unable to parse specs from rdf.yaml file", stackTrace(e), + software + "_" + version + " is unable to read the specs from the rdf.yaml file. Spec version" + + " might not be compatible with the software version."); + return summary; } - - List tests = new ArrayList(); - Map loadTest = new LinkedHashMap(); - loadTest.put("name", "load resource description"); - loadTest.put("status", error == null ? "passed" : "failed"); - loadTest.put("error", error); - loadTest.put("source_name", rdf); - loadTest.put("traceback", traceback); - loadTest.put(software, version); - tests.add(loadTest); + Map test1 = testExpectedResourceType(rd, expectedType); + if (test1.get("status").equals("failed")) return test1; - if (rd != null) - tests.add(testExpectedResourceType(rd, expectedType)); - if (rd != null && rd.getType().equals("model")) { - tests.add(testModelDownload(rd)); - tests.add(testModelInference(rd, weightFormat, decimal)); - } - return tests; + Map test2 = testModelDownload(rd); + if (test2.get("status").equals("failed")) return test2; + + return testModelInference(rd, weightFormat, decimal); } private static Map testExpectedResourceType(ModelDescriptor rd, String type) { boolean yes = rd.getType().equals(type); - Map typeTest = new LinkedHashMap(); - typeTest.put("name", "has expected resource type"); - typeTest.put("status", yes ? "passed" : "failed"); - typeTest.put("error", yes ? null : "expected type was " + type + " but found " + rd.getType()); - typeTest.put("source_name", rd.getName()); - typeTest.put("traceback", null); - typeTest.put(software, version); - return typeTest; + Path path = Paths.get(rd.getModelPath() + File.separator + Constants.RDF_FNAME); + return create(path, TEST_NAME, yes ? "passed" : "failed", + yes ? null : "expected type was " + type + " but found " + rd.getType(), null, null); } private static Map testModelDownload(ModelDescriptor rd) { + Path path = Paths.get(rd.getModelPath() + File.separator + Constants.RDF_FNAME); String error = null; if (downloadedModelsCorrectly.keySet().contains(rd.getName())) { rd.addModelPath(Paths.get(downloadedModelsCorrectly.get(rd.getName()))); @@ -277,14 +230,10 @@ private static Map testModelDownload(ModelDescriptor rd) { } else { error = downloadModel(rd); } - Map downloadTest = new LinkedHashMap(); - downloadTest.put("name", software + " is able to download model"); - downloadTest.put("status", error == null ? "passed" : "failed"); - downloadTest.put("error", error == null ? null : "unable to download model"); - downloadTest.put("traceback", error); - downloadTest.put("source_name", rd.getName()); - downloadTest.put(software, version); - return downloadTest; + + return create(path, TEST_NAME, error == null ? "passed" : "failed", + error == null ? null : software + " unable to download model", + error, error); } private static String downloadModel(ModelDescriptor rd) { From 346fbe84ee812707ba6626885a2b5d3b7c6882a1 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 4 Jul 2024 17:17:58 +0200 Subject: [PATCH 035/150] stabilize java part --- .../modelrunner/ci/ContinuousIntegration.java | 79 ++++++++----------- .../modelrunner/ci/DownloadEngines.java | 8 +- .../java/io/bioimage/modelrunner/ci/Tags.java | 9 +++ 3 files changed, 42 insertions(+), 54 deletions(-) create mode 100644 scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/Tags.java diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java index 12e97fcc..be56181b 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java @@ -21,7 +21,6 @@ import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.PrintWriter; import java.io.StringWriter; import java.nio.file.FileSystems; @@ -34,8 +33,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; -import java.util.jar.Manifest; import java.util.stream.Collectors; import io.bioimage.modelrunner.bioimageio.BioimageioRepo; @@ -51,7 +48,6 @@ import io.bioimage.modelrunner.tensor.Tensor; import io.bioimage.modelrunner.utils.Constants; import io.bioimage.modelrunner.utils.YAMLUtils; -import io.bioimage.modelrunner.versionmanagement.AvailableEngines; import net.imglib2.Cursor; import net.imglib2.RandomAccessibleInterval; import net.imglib2.loops.LoopBuilder; @@ -116,11 +112,11 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa new Exception(rdfPath.toAbsolutePath().toString() + " is missing ID field").printStackTrace(); continue; } else if (type == null || !(type instanceof String) || !((String) type).equals("model")) { - Map summary = create(rdfPath, TEST_NAME, "not-applicable", null, null, "not a model"); + Map summary = create(rdfPath, "not-applicable", null, null, "not a model"); writeSummary(summariesPath, summary); continue; } else if (weightFormats == null || !(weightFormats instanceof Map)) { - Map summary = create(rdfPath, TEST_NAME, + Map summary = create(rdfPath, "failed", "Missing weights dictionary for " + rdID, null, weightFormats.toString()); writeSummary(summariesPath, summary); continue; @@ -129,21 +125,20 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa try { weights = ModelWeight.build((Map) weightFormats); } catch (Exception ex) { - Map summary = create(rdfPath, TEST_NAME, + Map summary = create(rdfPath, "failed", "Missing/Invalid weight formats for " + rdID, stackTrace(ex), "Unable to read weight formats"); writeSummary(summariesPath, summary); continue; } if (weights != null && weights.gettAllSupportedWeightObjects().size() == 0) { - Map summary = create(rdfPath, TEST_NAME, + Map summary = create(rdfPath, "failed", "Unsupported model weights", null, "The model weights belong to a Deep Learning " + "framework not supported by " + software + "_" + version + "."); writeSummary(summariesPath, summary); continue; } - Map summariesPerWeightFormat = new LinkedHashMap(); for (WeightFormat ww : weights.gettAllSupportedWeightObjects()) { List summariesWeightFormat = new ArrayList(); @@ -152,21 +147,21 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa summaryWeightFormat = testResource(rdfPath.toAbsolutePath().toString(), ww, 4, "model"); } catch (Exception ex) { ex.printStackTrace(); - summaryWeightFormat = create(rdfPath, TEST_NAME + " " + ww.getFramework(), "failed", "exception thrown during testing", + summaryWeightFormat = create(rdfPath, "failed", "exception thrown during testing", stackTrace(ex), "test was interrupted by an exception while testing" + ww.getFramework() + " weigths"); - } - summariesPerWeightFormat.put(ww.getFramework(), summariesWeightFormat); + summariesPath = summariesDir.toAbsolutePath() + File.separator + + rdID + File.separator + "test_summary_" + software + "_" + version + ".yaml"; + writeSummary(summariesPath, summaryWeightFormat); } - writeSummary(summariesDir.toAbsolutePath() + File.separator + rdID + File.separator + "test_summary_" + version + ".yaml", chosenSummaries); } } - private static Map create(Path rdfPath, String testName, String status, String error, + private static Map create(Path rdfPath, String status, String error, String tb, String details) { Map summaryMap = new LinkedHashMap(); - summaryMap.put("name", testName); + summaryMap.put("name", TEST_NAME); summaryMap.put("status", status); summaryMap.put("error", error); summaryMap.put("source_name", rdfPath.toAbsolutePath().toString()); @@ -197,7 +192,7 @@ private static Map testResource(String rdf, WeightFormat weight try { rd = ModelDescriptor.readFromLocalFile(rdf, false); } catch (ModelSpecsException e) { - Map summary = create(Paths.get(rdf), TEST_NAME, + Map summary = create(Paths.get(rdf), "failed", "Unable to parse specs from rdf.yaml file", stackTrace(e), software + "_" + version + " is unable to read the specs from the rdf.yaml file. Spec version" + " might not be compatible with the software version."); @@ -216,7 +211,7 @@ private static Map testResource(String rdf, WeightFormat weight private static Map testExpectedResourceType(ModelDescriptor rd, String type) { boolean yes = rd.getType().equals(type); Path path = Paths.get(rd.getModelPath() + File.separator + Constants.RDF_FNAME); - return create(path, TEST_NAME, yes ? "passed" : "failed", + return create(path, yes ? "passed" : "failed", yes ? null : "expected type was " + type + " but found " + rd.getType(), null, null); } @@ -231,7 +226,7 @@ private static Map testModelDownload(ModelDescriptor rd) { error = downloadModel(rd); } - return create(path, TEST_NAME, error == null ? "passed" : "failed", + return create(path, error == null ? "passed" : "failed", error == null ? null : software + " unable to download model", error, error); } @@ -259,20 +254,23 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int inferTest.put("source_name", rd.getName()); inferTest.put(software, version); if (rd.getModelPath() == null) { - inferTest.put("status", "failed"); - inferTest.put("error", "model was not correctly downloaded"); - return inferTest; + return create(null, "failed", + "model was not correctly downloaded", null, null); } - if (rd.getInputTensors().size() != rd.getTestInputs().size()) { - inferTest.put("status", "failed"); - inferTest.put("error", "the number of test inputs should be the same as the number of inputs," - + rd.getInputTensors().size() + " vs " + rd.getTestInputs().size()); - return inferTest; + if (software.equals(Tags.DEEPIMAGEJ) && rd.getInputTensors().size() != 1) { + return create(null, "failed", + software + " only supports models with 1 (one) input", null, software + " only supports models " + + "with 1 input and this model has " + rd.getInputTensors().size()); + } else if (rd.getInputTensors().size() != rd.getTestInputs().size()) { + return create(null, "failed", + "the number of test inputs should be the same as the number of model inputs", null, + "the number of test inputs should be the same as the number of model inputs," + + rd.getInputTensors().size() + " vs " + rd.getTestInputs().size()); } else if (rd.getOutputTensors().size() != rd.getTestOutputs().size()) { - inferTest.put("status", "failed"); - inferTest.put("error", "the number of test outputs should be the same as the number of outputs" - + rd.getOutputTensors().size() + " vs " + rd.getTestOutputs().size()); - return inferTest; + return create(null, "failed", + "the number of test outputs should be the same as the number of model outputs", null, + "the number of test outputs should be the same as the number of model outputs," + + rd.getInputTensors().size() + " vs " + rd.getTestInputs().size()); } List> inps = new ArrayList>(); @@ -351,30 +349,15 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int double diff = computeMaxDiff(rai); if (diff > Math.pow(10, -decimal)) return failInferenceTest(rd.getName(), "output number " + i + " produces a very different result, " - + "the max difference is bigger than " + Math.pow(10, -decimal), null); + + "the max difference is " + diff +", bigger than max alllowed " + Math.pow(10, -decimal), null); maxDif.add(computeMaxDiff(rai)); } - - Map typeTest = new LinkedHashMap(); - typeTest.put("name", "reproduce test outputs from test inputs"); - typeTest.put("status", "passed"); - typeTest.put("error", null); - typeTest.put("source_name", rd.getName()); - typeTest.put("traceback", null); - typeTest.put(software, version); - return typeTest; + return create(null, "passed", null, null, null); } private static Map failInferenceTest(String sourceName, String error, String tb) { - Map typeTest = new LinkedHashMap(); - typeTest.put("name", "reproduce test outputs from test inputs"); - typeTest.put("status", "failed"); - typeTest.put("error", error); - typeTest.put("source_name", sourceName); - typeTest.put("traceback", tb); - typeTest.put(software, version); - return typeTest; + return create(Paths.get(sourceName), "failed", error, tb, tb); } diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java index 7f371c4b..4c8085ac 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java @@ -34,10 +34,6 @@ * @author Carlos Javier GArcia Lopez de Haro */ public class DownloadEngines { - - public static final String DEEPIMAGEJ_TAG = "deepimagej"; - - public static final String ICY_TAG = "icy"; /** * Current directory */ @@ -49,12 +45,12 @@ public class DownloadEngines { private static final String ENGINES_DIR = new File(CWD, "engines").getAbsolutePath(); public static void main(String[] args) throws IOException { - if (args[0].equals(DEEPIMAGEJ_TAG)) { + if (args[0].equals(Tags.DEEPIMAGEJ)) { EngineInstall engineManager = EngineInstall.createInstaller(ENGINES_DIR); engineManager.basicEngineInstallation(); //InstalledEngines.buildEnginesFinder(ENGINES_DIR).getDownloadedForOS().stream().map(i -> i.toString()) System.out.println(InstalledEngines.buildEnginesFinder(ENGINES_DIR).getDownloadedForOS()); - } else if (args[0].equals(ICY_TAG)) { + } else if (args[0].equals(Tags.ICY)) { List allEngines = AvailableEngines.getForCurrentOS(); for (DeepLearningVersion engine : allEngines) { try { diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/Tags.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/Tags.java new file mode 100644 index 00000000..41b6f3d5 --- /dev/null +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/Tags.java @@ -0,0 +1,9 @@ +package io.bioimage.modelrunner.ci; + +public class Tags { + + protected static final String DEEPIMAGEJ = "deepimagej"; + + protected static final String ICY = "icy"; + +} From 8da01d5c01ba75c7fa6cba5ad27569cda585cc32 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 4 Jul 2024 17:55:43 +0200 Subject: [PATCH 036/150] create script to retrieve the dij and icy versions --- scripts/get_java_software_versions.py | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 scripts/get_java_software_versions.py diff --git a/scripts/get_java_software_versions.py b/scripts/get_java_software_versions.py new file mode 100644 index 00000000..9dbfe69a --- /dev/null +++ b/scripts/get_java_software_versions.py @@ -0,0 +1,58 @@ +import requests +from bs4 import BeautifulSoup +import re +import datetime + +DEEPIMAGEJ_UPDATE_SITE_URL = "https://sites.imagej.net/DeepImageJ/plugins/" +DEEPIMAGEJ_PATTERN = r"DeepImageJ-(\d+\.\d+\.\d+)\.jar-(\d{14})" + +def get_deepimagej_versions(): + response = requests.get(DEEPIMAGEJ_UPDATE_SITE_URL) + soup = BeautifulSoup(response.content, 'html.parser') + links = soup.find_all('a') + files = [] + for link in links: + href = link.get('href') + if href.contains('.jar') and href.lower().contains('deepimagej'): + files.append(href) + + +def get_dij_version_and_date(filename: str): + match = re.search(DEEPIMAGEJ_PATTERN, filename) + + version_dic = {} + if match: + version = match.group(1) + date = match.group(2) + version_dic["vv"] = version + version_dic["ts"] = datetime.datetime(int(date[:4]), int(date[4:6]), int(date[6:8])).timestamp() + else: + version_dic["vv"] = None + version_dic["ts"] = None + return version + + + + + + +# Parse the HTML content + + +# Find all links on the page +links = soup.find_all('a') + +# Extract file details +files = [] +for link in links: + href = link.get('href') + if href.endswith('.jar'): # Filter for jar files + file_info = { + 'name': href, + 'url': url + href + } + files.append(file_info) + +# Display the list of files +for file in files: + print(f"Name: {file['name']}, URL: {file['url']}") \ No newline at end of file From 027e1d781da2a626f05b25c026feffd906a06b5d Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 4 Jul 2024 22:21:57 +0200 Subject: [PATCH 037/150] keep iterating --- scripts/get_java_software_versions.py | 56 ++++++++++++++++----------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/scripts/get_java_software_versions.py b/scripts/get_java_software_versions.py index 9dbfe69a..6417ef70 100644 --- a/scripts/get_java_software_versions.py +++ b/scripts/get_java_software_versions.py @@ -2,25 +2,51 @@ from bs4 import BeautifulSoup import re import datetime +from typing import Dict, Any +from packaging.version import Version DEEPIMAGEJ_UPDATE_SITE_URL = "https://sites.imagej.net/DeepImageJ/plugins/" DEEPIMAGEJ_PATTERN = r"DeepImageJ-(\d+\.\d+\.\d+)\.jar-(\d{14})" +MINIMUM_DIJ_VERSION = Version("3.0.0") + + +def download_file(url: str, local_filename: str): + with requests.get(url, stream=True) as response: + response.raise_for_status() + with open(local_filename, 'wb') as file: + for chunk in response.iter_content(chunk_size=8192): + _ = file.write(chunk) + +def find_associated_jdll_version(): + return None + def get_deepimagej_versions(): response = requests.get(DEEPIMAGEJ_UPDATE_SITE_URL) soup = BeautifulSoup(response.content, 'html.parser') links = soup.find_all('a') - files = [] + v_dic: Dict[str, Any] = {} + v_dic_rev: Dict[str, str] = {} for link in links: href = link.get('href') - if href.contains('.jar') and href.lower().contains('deepimagej'): - files.append(href) + if '.jar' in href and 'deepimagej' in href.lower(): + tmp_dic = get_dij_version_and_date(href) + if Version(tmp_dic["vv"]) < MINIMUM_DIJ_VERSION: + continue + if tmp_dic["vv"] not in v_dic_rev.keys(): + v_dic_rev[tmp_dic["vv"]] = tmp_dic["ts"] + v_dic[href] = tmp_dic + elif tmp_dic["ts"] > v_dic_rev[tmp_dic["vv"]]: + v_dic[href] = tmp_dic + v_dic_rev[tmp_dic["vv"]] = tmp_dic["ts"] + find_associated_jdll_version() + -def get_dij_version_and_date(filename: str): +def get_dij_version_and_date(filename: str) -> Dict[str, Any]: match = re.search(DEEPIMAGEJ_PATTERN, filename) - version_dic = {} + version_dic: Dict[str, Any] = {} if match: version = match.group(1) date = match.group(2) @@ -29,7 +55,7 @@ def get_dij_version_and_date(filename: str): else: version_dic["vv"] = None version_dic["ts"] = None - return version + return version_dic @@ -39,20 +65,4 @@ def get_dij_version_and_date(filename: str): # Parse the HTML content -# Find all links on the page -links = soup.find_all('a') - -# Extract file details -files = [] -for link in links: - href = link.get('href') - if href.endswith('.jar'): # Filter for jar files - file_info = { - 'name': href, - 'url': url + href - } - files.append(file_info) - -# Display the list of files -for file in files: - print(f"Name: {file['name']}, URL: {file['url']}") \ No newline at end of file +get_deepimagej_versions() \ No newline at end of file From 2964cb645a4b57c05e2631f45e48b29fb1746b8a Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 13:01:33 +0200 Subject: [PATCH 038/150] add code to understand JDLL and java software versions tested --- .gitignore | 1 + scripts/get_java_software_versions.py | 87 ++++++++++++++++++++++++--- 2 files changed, 79 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 671d4066..8d1ea1e1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ __pycache__/ *.egg-info/ docs/ *.pyc +TEMP/ diff --git a/scripts/get_java_software_versions.py b/scripts/get_java_software_versions.py index 6417ef70..f304a036 100644 --- a/scripts/get_java_software_versions.py +++ b/scripts/get_java_software_versions.py @@ -2,14 +2,29 @@ from bs4 import BeautifulSoup import re import datetime -from typing import Dict, Any +from typing import Dict, Any, List from packaging.version import Version +from pathlib import Path +import os +import zipfile +import xml.etree.ElementTree as ET DEEPIMAGEJ_UPDATE_SITE_URL = "https://sites.imagej.net/DeepImageJ/plugins/" DEEPIMAGEJ_PATTERN = r"DeepImageJ-(\d+\.\d+\.\d+)\.jar-(\d{14})" +DIJ_POM_FILE = 'META-INF/maven/io.github.deepimagej/DeepImageJ_/pom.xml' MINIMUM_DIJ_VERSION = Version("3.0.0") +ICY_POM_FILE = '' + + +TEMP_PATH = os.path.abspath("TEMP") + +JDLL_GROUP_ID = "io.bioimage" + +JDLL_ARTIFACT_ID = "dl-modelrunner" + + def download_file(url: str, local_filename: str): with requests.get(url, stream=True) as response: response.raise_for_status() @@ -17,19 +32,72 @@ def download_file(url: str, local_filename: str): for chunk in response.iter_content(chunk_size=8192): _ = file.write(chunk) -def find_associated_jdll_version(): - return None + +def get_version_from_pomxml(content: str) -> str: + root = ET.fromstring(content) + namespace = "{http://maven.apache.org/POM/4.0.0}" + + version = "" + for dependency in root.findall(f".//{namespace}dependency"): + group_id = dependency.find(f"{namespace}groupId") + artifact_id = dependency.find(f"{namespace}artifactId") + if group_id is not None and artifact_id is not None: + if group_id.text == JDLL_GROUP_ID and artifact_id.text == JDLL_ARTIFACT_ID: + version = dependency.find(f"{namespace}version").text + break + if version == "": + raise FileNotFoundError("JDLL version not founf in pom.xml") + + return version + + +def read_file_in_jar(jar_file_path: str, file_name: str) -> str: + with zipfile.ZipFile(jar_file_path, 'r') as jar: + if file_name in jar.namelist(): + with jar.open(file_name) as file: + content = file.read().decode('utf-8') + return content + else: + raise FileNotFoundError(f"{file_name} not found in the JAR file") -def get_deepimagej_versions(): + +def find_associated_jdll_version(link: str) -> str: + Path(TEMP_PATH).mkdir(parents=True, exist_ok=True) + fname = os.path.join(TEMP_PATH, link.split("/")[-1]) + download_file(link, fname) + if "deepimagej" in link.lower(): + return get_version_from_pomxml(read_file_in_jar(fname, DIJ_POM_FILE)) + else: + return get_version_from_pomxml(read_file_in_jar(fname, ICY_POM_FILE)) + + +def parse_links() -> List[Any]: response = requests.get(DEEPIMAGEJ_UPDATE_SITE_URL) soup = BeautifulSoup(response.content, 'html.parser') links = soup.find_all('a') + return links + + + +def get_deepimagej_versions() -> Dict[str, str]: + """ + Retrieves deepImageJ versions and their associated JDLL versions. + + This method parses available links, filters for relevant deepImageJ JAR files, + and extracts their versions and timestamps. It then associates each unique deepImageJ + version with the corresponding JDLL version deom the deepImageJ pom.xml file. + + Returns: + Dict[str, str]: A dictionary where each key is a deepImageJ version and the value + is the associated JDLL version. + """ + links = parse_links() v_dic: Dict[str, Any] = {} v_dic_rev: Dict[str, str] = {} for link in links: href = link.get('href') - if '.jar' in href and 'deepimagej' in href.lower(): + if '.jar' in href and 'deepimagej' in href.lower() and 'deepimagej_' not in href.lower(): tmp_dic = get_dij_version_and_date(href) if Version(tmp_dic["vv"]) < MINIMUM_DIJ_VERSION: continue @@ -39,7 +107,11 @@ def get_deepimagej_versions(): elif tmp_dic["ts"] > v_dic_rev[tmp_dic["vv"]]: v_dic[href] = tmp_dic v_dic_rev[tmp_dic["vv"]] = tmp_dic["ts"] - find_associated_jdll_version() + assoc_dict: Dict[str, str] = {} + for kk in v_dic.keys(): + jdll_v = find_associated_jdll_version(DEEPIMAGEJ_UPDATE_SITE_URL + kk) + assoc_dict[v_dic[kk]["vv"]] = jdll_v + return assoc_dict @@ -62,7 +134,4 @@ def get_dij_version_and_date(filename: str) -> Dict[str, Any]: -# Parse the HTML content - - get_deepimagej_versions() \ No newline at end of file From 950b1c9fd4cd0f72cc95833c1ce46dee515fc766 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 13:21:58 +0200 Subject: [PATCH 039/150] print version so github action can use it --- scripts/get_java_software_versions.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/scripts/get_java_software_versions.py b/scripts/get_java_software_versions.py index f304a036..0b76c671 100644 --- a/scripts/get_java_software_versions.py +++ b/scripts/get_java_software_versions.py @@ -1,3 +1,4 @@ +import argparse import requests from bs4 import BeautifulSoup import re @@ -8,15 +9,17 @@ import os import zipfile import xml.etree.ElementTree as ET +import json DEEPIMAGEJ_UPDATE_SITE_URL = "https://sites.imagej.net/DeepImageJ/plugins/" DEEPIMAGEJ_PATTERN = r"DeepImageJ-(\d+\.\d+\.\d+)\.jar-(\d{14})" DIJ_POM_FILE = 'META-INF/maven/io.github.deepimagej/DeepImageJ_/pom.xml' -MINIMUM_DIJ_VERSION = Version("3.0.0") +MINIMUM_DIJ_VERSION = Version("3.0.4") +DEEPIMAGEJ_TAG = "deepimagej" ICY_POM_FILE = '' - +ICY_TAG = "icy" TEMP_PATH = os.path.abspath("TEMP") @@ -129,9 +132,14 @@ def get_dij_version_and_date(filename: str) -> Dict[str, Any]: version_dic["ts"] = None return version_dic - - - - - -get_deepimagej_versions() \ No newline at end of file + get_deepimagej_versions() + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + _ = parser.add_argument("software_name") + if parser.parse_args().software_name == DEEPIMAGEJ_TAG: + matrix = get_deepimagej_versions() + #print(json.dumps(matrix)) + print(json.dumps({"3.0.4": "0.5.9"})) + elif parser.parse_args().software_name == ICY_TAG: + print(json.dumps({"0.0.1": "0.5.9"})) \ No newline at end of file From 632e15eb33ef08906626e7f5018507477a36e5c6 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 13:27:38 +0200 Subject: [PATCH 040/150] update actions to use new script retrieving version dict --- .../check_compatibility_deepimagej.yaml | 18 +++++++++++++++++- .github/workflows/check_compatibility_icy.yaml | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 24c608a4..2e5f2f8c 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -14,9 +14,25 @@ on: - cron: 0 1 * * * # update compatibility once a day jobs: + generate-version-dict: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-dict.outputs.matrix }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Generate dict + id: set-dict + run: | + python scripts/get_java_software_versions.py icy >> $GITHUB_OUTPUT run: + needs: generate-version-dict runs-on: ubuntu-latest strategy: + matrix: ${{fromJson(needs.generate-version-dict.outputs.matrix)}} fail-fast: false steps: - uses: actions/checkout@v3 @@ -39,7 +55,7 @@ jobs: java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej - name: Run models run: | - java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.ContinuousIntegration + java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.ContinuousIntegration deepimagej "${{ matrix.key }}" - name: Upload artifacts uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 71b8c13f..f9cfc940 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -14,9 +14,25 @@ on: - cron: 0 1 * * * # update compatibility once a day jobs: + generate-version-dict: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-dict.outputs.matrix }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Generate dict + id: set-dict + run: | + python scripts/get_java_software_versions.py icy >> $GITHUB_OUTPUT run: + needs: generate-version-dict runs-on: ubuntu-latest strategy: + matrix: ${{fromJson(needs.generate-version-dict.outputs.matrix)}} fail-fast: false steps: - uses: actions/checkout@v3 @@ -39,7 +55,7 @@ jobs: java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines icy - name: Run models run: | - java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.ContinuousIntegration + java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.ContinuousIntegration icy "${{ matrix.key }}" - name: Upload artifacts uses: actions/upload-artifact@v3 with: From 2733da66a06323f596f3362071d53d68c36a7b94 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 16:08:52 +0200 Subject: [PATCH 041/150] add installation of deps --- .github/workflows/check_compatibility_deepimagej.yaml | 2 ++ .github/workflows/check_compatibility_icy.yaml | 2 ++ scripts/get_java_software_versions.py | 1 - 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 2e5f2f8c..43d40857 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -24,6 +24,8 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.x' + - name: Install deps + run: pip install requests==2.28.2 beautifulsoup4==4.12.3 packaging==23.0 - name: Generate dict id: set-dict run: | diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index f9cfc940..c7ca28e4 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -24,6 +24,8 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.x' + - name: Install deps + run: pip install requests==2.28.2 beautifulsoup4==4.12.3 packaging==23.0 - name: Generate dict id: set-dict run: | diff --git a/scripts/get_java_software_versions.py b/scripts/get_java_software_versions.py index 0b76c671..07133331 100644 --- a/scripts/get_java_software_versions.py +++ b/scripts/get_java_software_versions.py @@ -132,7 +132,6 @@ def get_dij_version_and_date(filename: str) -> Dict[str, Any]: version_dic["ts"] = None return version_dic - get_deepimagej_versions() if __name__ == "__main__": parser = argparse.ArgumentParser() From e4a03d698ef074a4f003d70c70a65a01928b1639 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 16:30:46 +0200 Subject: [PATCH 042/150] corect small details --- scripts/get_java_software_versions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/get_java_software_versions.py b/scripts/get_java_software_versions.py index 07133331..f4e02d71 100644 --- a/scripts/get_java_software_versions.py +++ b/scripts/get_java_software_versions.py @@ -139,6 +139,6 @@ def get_dij_version_and_date(filename: str) -> Dict[str, Any]: if parser.parse_args().software_name == DEEPIMAGEJ_TAG: matrix = get_deepimagej_versions() #print(json.dumps(matrix)) - print(json.dumps({"3.0.4": "0.5.9"})) + print(f"matrix={json.dumps({"0.0.1": "0.5.9"})}") elif parser.parse_args().software_name == ICY_TAG: - print(json.dumps({"0.0.1": "0.5.9"})) \ No newline at end of file + print(f"matrix={json.dumps({"0.0.1": "0.5.9"})}") From e1e904b0a765ce3088acc1da33fb352d08d4df0f Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 16:34:40 +0200 Subject: [PATCH 043/150] add listener to another file --- .github/workflows/check_compatibility_deepimagej.yaml | 1 + .github/workflows/check_compatibility_icy.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 43d40857..f75487f4 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -8,6 +8,7 @@ on: - main paths: - .github/workflows/check_compatibility_deepimagej.yaml + - scripts/get_java_software_versions.py - scripts/check_compatibility_java_software/**/* workflow_dispatch: schedule: diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index c7ca28e4..33884d74 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -8,6 +8,7 @@ on: - main paths: - .github/workflows/check_compatibility_icy.yaml + - scripts/get_java_software_versions.py - scripts/check_compatibility_java_software/**/* workflow_dispatch: schedule: From 7af4a0036561afe1aa3bb3739daee65d67ac02b0 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 17:15:33 +0200 Subject: [PATCH 044/150] try to change something --- scripts/get_java_software_versions.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/get_java_software_versions.py b/scripts/get_java_software_versions.py index f4e02d71..cb941c47 100644 --- a/scripts/get_java_software_versions.py +++ b/scripts/get_java_software_versions.py @@ -139,6 +139,10 @@ def get_dij_version_and_date(filename: str) -> Dict[str, Any]: if parser.parse_args().software_name == DEEPIMAGEJ_TAG: matrix = get_deepimagej_versions() #print(json.dumps(matrix)) - print(f"matrix={json.dumps({"0.0.1": "0.5.9"})}") + #print(f"matrix={json.dumps({"0.0.1": "0.5.9"})}") + matrix = {"0.0.1": "0.5.9"} + print(f"matrix={json.dumps(matrix)}") elif parser.parse_args().software_name == ICY_TAG: - print(f"matrix={json.dumps({"0.0.1": "0.5.9"})}") + #print(f"matrix={json.dumps({"0.0.1": "0.5.9"})}") + matrix = {"0.0.1": "0.5.9"} + print(f"matrix={json.dumps(matrix)}") From 8f4139e4944f023cbceb7fcd55d700eaac19b715 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 17:18:45 +0200 Subject: [PATCH 045/150] debug --- .github/workflows/check_compatibility_icy.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 33884d74..a4fd08d2 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -31,12 +31,13 @@ jobs: id: set-dict run: | python scripts/get_java_software_versions.py icy >> $GITHUB_OUTPUT + - name: Debug matrix + run: echo '${{ steps.set-dict.outputs.matrix }}' run: needs: generate-version-dict runs-on: ubuntu-latest - strategy: - matrix: ${{fromJson(needs.generate-version-dict.outputs.matrix)}} - fail-fast: false + - name: Debug matrix + run: echo '${{ toJson(needs.generate-version-dict.outputs.matrix) }}' steps: - uses: actions/checkout@v3 - uses: actions/checkout@v3 From 72f985a23e138523ad0661bc35036e750ec5b11e Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 17:19:47 +0200 Subject: [PATCH 046/150] debug --- .github/workflows/check_compatibility_icy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index a4fd08d2..70d54094 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -36,9 +36,9 @@ jobs: run: needs: generate-version-dict runs-on: ubuntu-latest + steps: - name: Debug matrix run: echo '${{ toJson(needs.generate-version-dict.outputs.matrix) }}' - steps: - uses: actions/checkout@v3 - uses: actions/checkout@v3 with: From a443fa13c614e29592171c4857a9ff5d6dd43527 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 17:21:22 +0200 Subject: [PATCH 047/150] debug --- .github/workflows/check_compatibility_icy.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 70d54094..c38c4d1b 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -33,6 +33,7 @@ jobs: python scripts/get_java_software_versions.py icy >> $GITHUB_OUTPUT - name: Debug matrix run: echo '${{ steps.set-dict.outputs.matrix }}' + run: needs: generate-version-dict runs-on: ubuntu-latest From 4ce96407e0897df017738725df0f8a7489d023e1 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 17:30:00 +0200 Subject: [PATCH 048/150] try new changes --- .github/workflows/check_compatibility_icy.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index c38c4d1b..6c8559e5 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -30,16 +30,21 @@ jobs: - name: Generate dict id: set-dict run: | - python scripts/get_java_software_versions.py icy >> $GITHUB_OUTPUT + matrix_output=$(python scripts/get_java_software_versions.py icy) + echo "${matrix_output}" >> $GITHUB_ENV + matrix=$(echo "${matrix_output}" | sed 's/matrix=//') + echo "matrix=${matrix}" >> $GITHUB_OUTPUT - name: Debug matrix run: echo '${{ steps.set-dict.outputs.matrix }}' run: needs: generate-version-dict runs-on: ubuntu-latest + strategy: + matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} steps: - name: Debug matrix - run: echo '${{ toJson(needs.generate-version-dict.outputs.matrix) }}' + run: echo '${{ toJson(matrix) }}' - uses: actions/checkout@v3 - uses: actions/checkout@v3 with: From d7fd1c1c1bba73b15b2bbf634ca75c1b88b4c41f Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 17:36:07 +0200 Subject: [PATCH 049/150] try more changes --- .github/workflows/check_compatibility_icy.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 6c8559e5..e3112ce1 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -36,12 +36,13 @@ jobs: echo "matrix=${matrix}" >> $GITHUB_OUTPUT - name: Debug matrix run: echo '${{ steps.set-dict.outputs.matrix }}' - + run: needs: generate-version-dict runs-on: ubuntu-latest strategy: - matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} + matrix: + include: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} steps: - name: Debug matrix run: echo '${{ toJson(matrix) }}' @@ -71,19 +72,15 @@ jobs: with: path: test_summaries - sendreport: runs-on: ubuntu-latest needs: run steps: - uses: actions/checkout@v3 - - name: Get test results uses: actions/download-artifact@v3 with: path: test_summaries - - name: test with Java software ${{ matrix.v }} shell: bash -l {0} run: python scripts/check_compatibility_java_software.py icy 3.0.1 test_summaries/artifact - From df64bd6c7417fe552b7e7c9afaa86e554daed202 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 17:39:08 +0200 Subject: [PATCH 050/150] more changes --- .github/workflows/check_compatibility_icy.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index e3112ce1..40a9da09 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -31,9 +31,8 @@ jobs: id: set-dict run: | matrix_output=$(python scripts/get_java_software_versions.py icy) - echo "${matrix_output}" >> $GITHUB_ENV - matrix=$(echo "${matrix_output}" | sed 's/matrix=//') - echo "matrix=${matrix}" >> $GITHUB_OUTPUT + echo "matrix=${matrix_output}" >> $GITHUB_ENV + echo "${matrix_output}" >> $GITHUB_OUTPUT - name: Debug matrix run: echo '${{ steps.set-dict.outputs.matrix }}' @@ -41,8 +40,7 @@ jobs: needs: generate-version-dict runs-on: ubuntu-latest strategy: - matrix: - include: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} + matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} steps: - name: Debug matrix run: echo '${{ toJson(matrix) }}' From 1344fa533e1505008b96a6f9880bdcf6d04e953b Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 18:02:33 +0200 Subject: [PATCH 051/150] use a list of entries instead of a dict --- .github/workflows/check_compatibility_icy.yaml | 16 +++++++--------- scripts/get_java_software_versions.py | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 40a9da09..33884d74 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -30,20 +30,14 @@ jobs: - name: Generate dict id: set-dict run: | - matrix_output=$(python scripts/get_java_software_versions.py icy) - echo "matrix=${matrix_output}" >> $GITHUB_ENV - echo "${matrix_output}" >> $GITHUB_OUTPUT - - name: Debug matrix - run: echo '${{ steps.set-dict.outputs.matrix }}' - + python scripts/get_java_software_versions.py icy >> $GITHUB_OUTPUT run: needs: generate-version-dict runs-on: ubuntu-latest strategy: - matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} + matrix: ${{fromJson(needs.generate-version-dict.outputs.matrix)}} + fail-fast: false steps: - - name: Debug matrix - run: echo '${{ toJson(matrix) }}' - uses: actions/checkout@v3 - uses: actions/checkout@v3 with: @@ -70,15 +64,19 @@ jobs: with: path: test_summaries + sendreport: runs-on: ubuntu-latest needs: run steps: - uses: actions/checkout@v3 + - name: Get test results uses: actions/download-artifact@v3 with: path: test_summaries + - name: test with Java software ${{ matrix.v }} shell: bash -l {0} run: python scripts/check_compatibility_java_software.py icy 3.0.1 test_summaries/artifact + diff --git a/scripts/get_java_software_versions.py b/scripts/get_java_software_versions.py index cb941c47..7f4be3aa 100644 --- a/scripts/get_java_software_versions.py +++ b/scripts/get_java_software_versions.py @@ -140,9 +140,9 @@ def get_dij_version_and_date(filename: str) -> Dict[str, Any]: matrix = get_deepimagej_versions() #print(json.dumps(matrix)) #print(f"matrix={json.dumps({"0.0.1": "0.5.9"})}") - matrix = {"0.0.1": "0.5.9"} + matrix = [{"0.0.1": "0.5.9"}] print(f"matrix={json.dumps(matrix)}") elif parser.parse_args().software_name == ICY_TAG: #print(f"matrix={json.dumps({"0.0.1": "0.5.9"})}") - matrix = {"0.0.1": "0.5.9"} + matrix = [{"0.0.1": "0.5.9"}] print(f"matrix={json.dumps(matrix)}") From 3d29be5853d4df13366ead37d71f070d7815b2c0 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 18:06:48 +0200 Subject: [PATCH 052/150] redo map --- .github/workflows/check_compatibility_icy.yaml | 18 ++++++++++-------- scripts/get_java_software_versions.py | 9 ++++----- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 33884d74..23782f29 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -30,14 +30,20 @@ jobs: - name: Generate dict id: set-dict run: | - python scripts/get_java_software_versions.py icy >> $GITHUB_OUTPUT + matrix_output=$(python scripts/get_java_software_versions.py icy) + echo "matrix=${matrix_output}" >> $GITHUB_ENV + echo "matrix=${matrix_output}" >> $GITHUB_OUTPUT + - name: Debug matrix + run: echo '${{ steps.set-dict.outputs.matrix }}' + run: needs: generate-version-dict runs-on: ubuntu-latest strategy: - matrix: ${{fromJson(needs.generate-version-dict.outputs.matrix)}} - fail-fast: false + matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} steps: + - name: Debug matrix + run: echo '${{ toJson(matrix) }}' - uses: actions/checkout@v3 - uses: actions/checkout@v3 with: @@ -64,19 +70,15 @@ jobs: with: path: test_summaries - sendreport: runs-on: ubuntu-latest needs: run steps: - uses: actions/checkout@v3 - - name: Get test results uses: actions/download-artifact@v3 with: path: test_summaries - - - name: test with Java software ${{ matrix.v }} + - name: test with Java software ${{ matrix.value[0] }} shell: bash -l {0} run: python scripts/check_compatibility_java_software.py icy 3.0.1 test_summaries/artifact - diff --git a/scripts/get_java_software_versions.py b/scripts/get_java_software_versions.py index 7f4be3aa..33746af5 100644 --- a/scripts/get_java_software_versions.py +++ b/scripts/get_java_software_versions.py @@ -140,9 +140,8 @@ def get_dij_version_and_date(filename: str) -> Dict[str, Any]: matrix = get_deepimagej_versions() #print(json.dumps(matrix)) #print(f"matrix={json.dumps({"0.0.1": "0.5.9"})}") - matrix = [{"0.0.1": "0.5.9"}] - print(f"matrix={json.dumps(matrix)}") + matrix = {"key": ["3.0.4"], "value": ["0.5.9"]} + print(json.dumps(matrix)) elif parser.parse_args().software_name == ICY_TAG: - #print(f"matrix={json.dumps({"0.0.1": "0.5.9"})}") - matrix = [{"0.0.1": "0.5.9"}] - print(f"matrix={json.dumps(matrix)}") + matrix = {"key": ["0.0.1"], "value": ["0.5.9"]} + print(json.dumps(matrix)) From 1b016c7a252f20ac8d0a991acc98ab53040861a5 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 18:43:55 +0200 Subject: [PATCH 053/150] stabilize version management --- .../check_compatibility_deepimagej.yaml | 24 ++++++++++--------- .../workflows/check_compatibility_icy.yaml | 16 ++++++------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index f75487f4..e7036d47 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -30,13 +30,16 @@ jobs: - name: Generate dict id: set-dict run: | - python scripts/get_java_software_versions.py icy >> $GITHUB_OUTPUT + matrix_output=$(python scripts/get_java_software_versions.py deepimagej) + echo "matrix=${matrix_output}" >> $GITHUB_OUTPUT + - name: Versions matrix + run: echo '${{ steps.set-dict.outputs.matrix }}' + run: needs: generate-version-dict runs-on: ubuntu-latest strategy: - matrix: ${{fromJson(needs.generate-version-dict.outputs.matrix)}} - fail-fast: false + matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} steps: - uses: actions/checkout@v3 - uses: actions/checkout@v3 @@ -55,28 +58,27 @@ jobs: mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Download engines run: | - java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines deepimagej + jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') + java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.DownloadEngines deepimagej - name: Run models run: | - java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.ContinuousIntegration deepimagej "${{ matrix.key }}" + java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.ContinuousIntegration deepimagej ${{ matrix.key }} - name: Upload artifacts uses: actions/upload-artifact@v3 with: path: test_summaries - sendreport: runs-on: ubuntu-latest needs: run + strategy: + matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} steps: - uses: actions/checkout@v3 - - name: Get test results uses: actions/download-artifact@v3 with: path: test_summaries - - - name: test with Java software ${{ matrix.v }} + - name: Send deepimagej ${{ matrix.key }} tests shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py deepimagej 3.0.1 test_summaries/artifact - + run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries/artifact diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 23782f29..268901c4 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -31,9 +31,8 @@ jobs: id: set-dict run: | matrix_output=$(python scripts/get_java_software_versions.py icy) - echo "matrix=${matrix_output}" >> $GITHUB_ENV echo "matrix=${matrix_output}" >> $GITHUB_OUTPUT - - name: Debug matrix + - name: Versions matrix run: echo '${{ steps.set-dict.outputs.matrix }}' run: @@ -42,8 +41,6 @@ jobs: strategy: matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} steps: - - name: Debug matrix - run: echo '${{ toJson(matrix) }}' - uses: actions/checkout@v3 - uses: actions/checkout@v3 with: @@ -61,10 +58,11 @@ jobs: mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Download engines run: | - java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.DownloadEngines icy + jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') + java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.DownloadEngines icy - name: Run models run: | - java -cp scripts/check_compatibility_java_software/target/dl-modelrunner-ci-0.0.1-SNAPSHOT.jar io.bioimage.modelrunner.ci.ContinuousIntegration icy "${{ matrix.key }}" + java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.ContinuousIntegration icy ${{ matrix.key }} - name: Upload artifacts uses: actions/upload-artifact@v3 with: @@ -73,12 +71,14 @@ jobs: sendreport: runs-on: ubuntu-latest needs: run + strategy: + matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} steps: - uses: actions/checkout@v3 - name: Get test results uses: actions/download-artifact@v3 with: path: test_summaries - - name: test with Java software ${{ matrix.value[0] }} + - name: Send Icy ${{ matrix.key }} tests shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py icy 3.0.1 test_summaries/artifact + run: python scripts/check_compatibility_java_software.py icy ${{ matrix.key }} test_summaries/artifact From f03fff9d396f896b6579e9947d5c14633d9fb371 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 18:55:55 +0200 Subject: [PATCH 054/150] che k the dir --- .github/workflows/check_compatibility_deepimagej.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index e7036d47..cbc47afa 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -58,6 +58,7 @@ jobs: mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Download engines run: | + ls jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.DownloadEngines deepimagej - name: Run models From 2904eb64f94ca1037f1e37a77f1b56178a4bbcaf Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 18:57:29 +0200 Subject: [PATCH 055/150] move to the correct dir to execute java code --- .github/workflows/check_compatibility_deepimagej.yaml | 3 ++- .github/workflows/check_compatibility_icy.yaml | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index cbc47afa..0d48eb58 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -58,11 +58,12 @@ jobs: mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Download engines run: | - ls + cd scripts/check_compatibility_java_software jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.DownloadEngines deepimagej - name: Run models run: | + cd scripts/check_compatibility_java_software java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.ContinuousIntegration deepimagej ${{ matrix.key }} - name: Upload artifacts uses: actions/upload-artifact@v3 diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 268901c4..f9deaf1d 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -58,10 +58,12 @@ jobs: mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Download engines run: | + cd scripts/check_compatibility_java_software jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.DownloadEngines icy - name: Run models run: | + cd scripts/check_compatibility_java_software java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.ContinuousIntegration icy ${{ matrix.key }} - name: Upload artifacts uses: actions/upload-artifact@v3 From c832bab5b357c929b7edf58aed18f8cf9df0ff8d Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 19:02:12 +0200 Subject: [PATCH 056/150] orint jarfile --- .github/workflows/check_compatibility_icy.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index f9deaf1d..fdd7da9d 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -60,10 +60,12 @@ jobs: run: | cd scripts/check_compatibility_java_software jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') + echo "JAR file name: $jarfile" java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.DownloadEngines icy - name: Run models run: | cd scripts/check_compatibility_java_software + echo "JAR file name: $jarfile" java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.ContinuousIntegration icy ${{ matrix.key }} - name: Upload artifacts uses: actions/upload-artifact@v3 From de048243ea7ea7ce1b15dd75848cc875796b79a2 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 19:05:43 +0200 Subject: [PATCH 057/150] correct paths again --- .github/workflows/check_compatibility_deepimagej.yaml | 5 +++-- .github/workflows/check_compatibility_icy.yaml | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 0d48eb58..a70f41dd 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -56,14 +56,15 @@ jobs: run: | cd scripts/check_compatibility_java_software mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - - name: Download engines + - name: Get jar file name run: | cd scripts/check_compatibility_java_software jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') + - name: Download engines + run: | java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.DownloadEngines deepimagej - name: Run models run: | - cd scripts/check_compatibility_java_software java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.ContinuousIntegration deepimagej ${{ matrix.key }} - name: Upload artifacts uses: actions/upload-artifact@v3 diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index fdd7da9d..a0b1c26d 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -56,16 +56,15 @@ jobs: run: | cd scripts/check_compatibility_java_software mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - - name: Download engines + - name: Get jar file name run: | cd scripts/check_compatibility_java_software jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') - echo "JAR file name: $jarfile" + - name: Download engines + run: | java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.DownloadEngines icy - name: Run models run: | - cd scripts/check_compatibility_java_software - echo "JAR file name: $jarfile" java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.ContinuousIntegration icy ${{ matrix.key }} - name: Upload artifacts uses: actions/upload-artifact@v3 From 1fbc12702af70e31043f24421d3c2a6fd68054b8 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 19:07:55 +0200 Subject: [PATCH 058/150] check if jarfile persits --- .github/workflows/check_compatibility_deepimagej.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index a70f41dd..27b46c41 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -62,6 +62,7 @@ jobs: jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') - name: Download engines run: | + echo $jarfile java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.DownloadEngines deepimagej - name: Run models run: | From 8c4b5ca5a2fd324dcf5a1238048ff2c893b371ab Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 19:14:47 +0200 Subject: [PATCH 059/150] preserve jarfile name --- .github/workflows/check_compatibility_deepimagej.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 27b46c41..4bc95fb0 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -60,13 +60,13 @@ jobs: run: | cd scripts/check_compatibility_java_software jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') + echo "jarfile=$jarfile" >> $GITHUB_OUTPUT - name: Download engines run: | - echo $jarfile - java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.DownloadEngines deepimagej + java -cp "scripts/check_compatibility_java_software/target/${{ steps.get-jar.outputs.jarfile }}" io.bioimage.modelrunner.ci.DownloadEngines deepimagej - name: Run models run: | - java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.ContinuousIntegration deepimagej ${{ matrix.key }} + java -cp "scripts/check_compatibility_java_software/target/${{ steps.get-jar.outputs.jarfile }}" io.bioimage.modelrunner.ci.ContinuousIntegration deepimagej ${{ matrix.key }} - name: Upload artifacts uses: actions/upload-artifact@v3 with: From e333e6a00bfd383e9f4af1cf2b246c7962ace2b7 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 19:17:34 +0200 Subject: [PATCH 060/150] add forgotten id --- .github/workflows/check_compatibility_deepimagej.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 4bc95fb0..db7546fe 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -57,6 +57,7 @@ jobs: cd scripts/check_compatibility_java_software mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Get jar file name + id: get-jar run: | cd scripts/check_compatibility_java_software jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') From 707eb22171f2e25fd463efd9348158bee8d146c5 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 20:05:07 +0200 Subject: [PATCH 061/150] need to jobs --- .github/workflows/check_compatibility_deepimagej.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index db7546fe..be81f69a 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -75,7 +75,7 @@ jobs: sendreport: runs-on: ubuntu-latest - needs: run + needs: [generate-version-dict, run] strategy: matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} steps: From 7a8892cc4a89c2e1c7961ac8f1cd91bad46c62d5 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 20:50:57 +0200 Subject: [PATCH 062/150] install deps --- .github/workflows/check_compatibility_deepimagej.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index be81f69a..05e9230a 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -71,7 +71,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v3 with: - path: test_summaries + path: test_summaries${{ matrix.key }} sendreport: runs-on: ubuntu-latest @@ -83,7 +83,9 @@ jobs: - name: Get test results uses: actions/download-artifact@v3 with: - path: test_summaries + path: test_summaries${{ matrix.key }} + - name: Install deps + run: pip install requests==2.28.2 loguru==0.7.2 ruyaml==0.16.7 - name: Send deepimagej ${{ matrix.key }} tests shell: bash -l {0} run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries/artifact From 8a17d95ae08d64cfad9ae325e7115b81ac352070 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 23:12:12 +0200 Subject: [PATCH 063/150] correct version number --- .github/workflows/check_compatibility_deepimagej.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 05e9230a..4182919b 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -85,7 +85,7 @@ jobs: with: path: test_summaries${{ matrix.key }} - name: Install deps - run: pip install requests==2.28.2 loguru==0.7.2 ruyaml==0.16.7 + run: pip install requests==2.28.2 loguru==0.7.2 ruyaml==0.91.0 - name: Send deepimagej ${{ matrix.key }} tests shell: bash -l {0} run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries/artifact From 4cff69fa804a12b56525a1333a82ac4a86097efd Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 5 Jul 2024 23:52:35 +0200 Subject: [PATCH 064/150] update python code --- .../check_compatibility_deepimagej.yaml | 6 +-- scripts/check_compatibility_java_software.py | 42 ++++++++++--------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 4182919b..49f5b6c2 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -71,7 +71,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v3 with: - path: test_summaries${{ matrix.key }} + path: test_summaries_deepimagej_${{ matrix.key }} sendreport: runs-on: ubuntu-latest @@ -83,9 +83,9 @@ jobs: - name: Get test results uses: actions/download-artifact@v3 with: - path: test_summaries${{ matrix.key }} + path: test_summaries_deepimagej_${{ matrix.key }} - name: Install deps run: pip install requests==2.28.2 loguru==0.7.2 ruyaml==0.91.0 - name: Send deepimagej ${{ matrix.key }} tests shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries/artifact + run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries_deepimagej_{{ matrix.key }}/artifact diff --git a/scripts/check_compatibility_java_software.py b/scripts/check_compatibility_java_software.py index 7b7f26f9..ccce7ef3 100644 --- a/scripts/check_compatibility_java_software.py +++ b/scripts/check_compatibility_java_software.py @@ -13,9 +13,6 @@ from bioimageio_collection_backoffice.remote_collection import Record, RemoteCollection from bioimageio_collection_backoffice.s3_client import Client -MAIN_TEST_NAME = "reproduce test outputs from test inputs" - -yaml = YAML(typ="safe") def find_java_summaries(directory: str) -> List[str]: @@ -75,20 +72,26 @@ def get_tests_from_summaries(rdf: str, path_to_summaries: str) -> Dict[str, str] summary["error"] = "No tests executed" summary["details"] = "The model tests were not executed or the test files could not be located" return summary - elif len(test_files) > 1: - raise Exception("Unexpected number of tests (" + str(len(test_files)) + ") found in the folder of interest") summaries_yaml = None + error: str = "" + for test_file in test_files: + try: + summaries_yaml=YAML(typ='safe') # default, if not specfied, is 'rt' (round-trip) + summaries_yaml.load(test_file) + summary = find_passed_test(summaries_yaml) + if summary["status"] == "passed": + return summary + except YAMLError as e: + error += str(e) + os.linesep + continue + + if summary["status"] is not None: + return summary - try: - summaries_yaml=YAML(typ='safe') # default, if not specfied, is 'rt' (round-trip) - summaries_yaml.load(test_files[0]) - except YAMLError as e: - summary["status"] = "failed" - summary["error"] = "Unable to read the test results yaml file" - summary["details"] = str(e) - - summary = find_passed_test(summaries_yaml) + summary["status"] = "failed" + summary["error"] = "Unable to read the test results yaml file" + summary["details"] = str(error) return summary @@ -101,13 +104,12 @@ def find_passed_test(summaries_yaml: List[Dict[Any, Any]]) -> Dict[Any, Any]: summary["error"] = "Invalid test output format" summary["details"] = "Expected a list of dictionaries, but received an improperly formatted element." return summary - - if elem.get("status") == "passed" and elem.get("name") != None and elem.get("name").contains(MAIN_TEST_NAME): + elif elem.get("status") is not None: return elem - elif elem.get("status") != "passed" and elem.get("name") != None and elem.get("name").contains(MAIN_TEST_NAME): - summary["status"] = elem.get("status") - summary["error"] = elem.get("error") - summary["details"] = elem.get("traceback") + + summary["status"] = "failed" + summary["error"] = "No test contents found" + summary["details"] = "test file was empty." return summary From f397ab5e4ea48f107a7aa3baba7f4ccbddc4fb41 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 9 Jul 2024 20:12:47 +0200 Subject: [PATCH 065/150] run as modules to avoid import errors --- .github/workflows/check_compatibility_deepimagej.yaml | 2 +- .github/workflows/check_compatibility_icy.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 49f5b6c2..fd89cf15 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -88,4 +88,4 @@ jobs: run: pip install requests==2.28.2 loguru==0.7.2 ruyaml==0.91.0 - name: Send deepimagej ${{ matrix.key }} tests shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries_deepimagej_{{ matrix.key }}/artifact + run: python -m scripts.check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries_deepimagej_{{ matrix.key }}/artifact diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index a0b1c26d..7d94b3d9 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -84,4 +84,4 @@ jobs: path: test_summaries - name: Send Icy ${{ matrix.key }} tests shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py icy ${{ matrix.key }} test_summaries/artifact + run: python -m scripts.check_compatibility_java_software.py icy ${{ matrix.key }} test_summaries/artifact From 241d6dd8b37e59c825bde403ac825e643680b29d Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 00:47:56 +0200 Subject: [PATCH 066/150] check if this change eas the error --- .github/workflows/check_compatibility_deepimagej.yaml | 2 +- .github/workflows/check_compatibility_icy.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index fd89cf15..49f5b6c2 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -88,4 +88,4 @@ jobs: run: pip install requests==2.28.2 loguru==0.7.2 ruyaml==0.91.0 - name: Send deepimagej ${{ matrix.key }} tests shell: bash -l {0} - run: python -m scripts.check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries_deepimagej_{{ matrix.key }}/artifact + run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries_deepimagej_{{ matrix.key }}/artifact diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 7d94b3d9..a0b1c26d 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -84,4 +84,4 @@ jobs: path: test_summaries - name: Send Icy ${{ matrix.key }} tests shell: bash -l {0} - run: python -m scripts.check_compatibility_java_software.py icy ${{ matrix.key }} test_summaries/artifact + run: python scripts/check_compatibility_java_software.py icy ${{ matrix.key }} test_summaries/artifact From e49dbce3b053ebf73aa00840dae5c08fcde6ec7a Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 01:06:05 +0200 Subject: [PATCH 067/150] improve robustness --- .../check_compatibility_deepimagej.yaml | 11 ++++++++++- .github/workflows/check_compatibility_icy.yaml | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 49f5b6c2..6e2e5bb2 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -61,6 +61,15 @@ jobs: run: | cd scripts/check_compatibility_java_software jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') + if [ -z "$jarfile" ]; then + echo "Failed to get jar file name" + exit 1 + fi + if [ ! -f "target/$jarfile" ]; then + echo "Jar file not found: target/$jarfile" + exit 1 + fi + echo "Jar file found: target/$jarfile" echo "jarfile=$jarfile" >> $GITHUB_OUTPUT - name: Download engines run: | @@ -88,4 +97,4 @@ jobs: run: pip install requests==2.28.2 loguru==0.7.2 ruyaml==0.91.0 - name: Send deepimagej ${{ matrix.key }} tests shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries_deepimagej_{{ matrix.key }}/artifact + run: python -m scripts.check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries_deepimagej_{{ matrix.key }}/artifact diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index a0b1c26d..98c0bad2 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -57,15 +57,26 @@ jobs: cd scripts/check_compatibility_java_software mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - name: Get jar file name + id: get-jar run: | cd scripts/check_compatibility_java_software jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') + if [ -z "$jarfile" ]; then + echo "Failed to get jar file name" + exit 1 + fi + if [ ! -f "target/$jarfile" ]; then + echo "Jar file not found: target/$jarfile" + exit 1 + fi + echo "Jar file found: target/$jarfile" + echo "jarfile=$jarfile" >> $GITHUB_OUTPUT - name: Download engines run: | - java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.DownloadEngines icy + java -cp "scripts/check_compatibility_java_software/target/${{ steps.get-jar.outputs.jarfile }}" io.bioimage.modelrunner.ci.DownloadEngines icy - name: Run models run: | - java -cp scripts/check_compatibility_java_software/target/$jarfile io.bioimage.modelrunner.ci.ContinuousIntegration icy ${{ matrix.key }} + java -cp "scripts/check_compatibility_java_software/target/${{ steps.get-jar.outputs.jarfile }}" io.bioimage.modelrunner.ci.ContinuousIntegration icy ${{ matrix.key }} - name: Upload artifacts uses: actions/upload-artifact@v3 with: @@ -84,4 +95,4 @@ jobs: path: test_summaries - name: Send Icy ${{ matrix.key }} tests shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py icy ${{ matrix.key }} test_summaries/artifact + run: python -m scripts.check_compatibility_java_software.py icy ${{ matrix.key }} test_summaries/artifact From 6be07cfdaafc1bc26a88b0b203554c53efbaa354 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 11:47:24 +0200 Subject: [PATCH 068/150] create the collection backoffice plus dependencies --- .github/workflows/check_compatibility_deepimagej.yaml | 6 ++++-- .github/workflows/check_compatibility_icy.yaml | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 6e2e5bb2..bcb18885 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -94,7 +94,9 @@ jobs: with: path: test_summaries_deepimagej_${{ matrix.key }} - name: Install deps - run: pip install requests==2.28.2 loguru==0.7.2 ruyaml==0.91.0 + run: | + ls + pip install -e . - name: Send deepimagej ${{ matrix.key }} tests shell: bash -l {0} - run: python -m scripts.check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries_deepimagej_{{ matrix.key }}/artifact + run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries_deepimagej_{{ matrix.key }}/artifact diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 98c0bad2..f0eecd8f 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -93,6 +93,10 @@ jobs: uses: actions/download-artifact@v3 with: path: test_summaries + - name: Install deps + run: | + ls + pip install -e . - name: Send Icy ${{ matrix.key }} tests shell: bash -l {0} - run: python -m scripts.check_compatibility_java_software.py icy ${{ matrix.key }} test_summaries/artifact + run: python scripts/check_compatibility_java_software.py icy ${{ matrix.key }} test_summaries/artifact From b521fe1ca98d04ad9416a8e9ef713aa66818a0d9 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 11:52:09 +0200 Subject: [PATCH 069/150] improving naming of the paths of test summaries --- .../io/bioimage/modelrunner/ci/ContinuousIntegration.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java index be56181b..39a5a390 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java @@ -78,7 +78,7 @@ public static void main(String[] args) throws IOException { Path rdfDir = currentDir.resolve("../../../bioimageio-gh-pages/rdfs").normalize(); // Create a matcher for the pattern 'rdf.yaml' - runTests(rdfDir, "**", "**", Paths.get("test_summaries")); + runTests(rdfDir, "**", "**", Paths.get("test_summaries_" + software + "_" + version)); } @@ -105,7 +105,7 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa Object rdID = rdf.get("id"); String summariesPath = summariesDir.toAbsolutePath() + File.separator - + (rdID != null ? rdID : "") + File.separator + "test_summary_" + software + "_" + version + ".yaml"; + + (rdID != null ? rdID : "") + File.separator + "test_summary" + ".yaml"; Object type = rdf.get("type"); Object weightFormats = rdf.get("weights"); if (rdID == null || !(rdID instanceof String)) { @@ -141,7 +141,6 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa for (WeightFormat ww : weights.gettAllSupportedWeightObjects()) { - List summariesWeightFormat = new ArrayList(); Map summaryWeightFormat = new LinkedHashMap(); try { summaryWeightFormat = testResource(rdfPath.toAbsolutePath().toString(), ww, 4, "model"); @@ -151,7 +150,7 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa stackTrace(ex), "test was interrupted by an exception while testing" + ww.getFramework() + " weigths"); } summariesPath = summariesDir.toAbsolutePath() + File.separator - + rdID + File.separator + "test_summary_" + software + "_" + version + ".yaml"; + + rdID + File.separator + "test_summary_" + ww.getFramework() + ".yaml"; writeSummary(summariesPath, summaryWeightFormat); } From fc4cb0dccb3a33cf97d8399882c2551fe05e1647 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 12:52:16 +0200 Subject: [PATCH 070/150] correct installation of backoffice --- .../check_compatibility_deepimagej.yaml | 6 +++++- .github/workflows/check_compatibility_icy.yaml | 6 +++++- .gitignore | 2 ++ .../modelrunner/ci/ContinuousIntegration.java | 17 +++++++++++++---- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index bcb18885..d942185b 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -89,6 +89,10 @@ jobs: matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} steps: - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' - name: Get test results uses: actions/download-artifact@v3 with: @@ -96,7 +100,7 @@ jobs: - name: Install deps run: | ls - pip install -e . + pip install . - name: Send deepimagej ${{ matrix.key }} tests shell: bash -l {0} run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries_deepimagej_{{ matrix.key }}/artifact diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index f0eecd8f..ed79a60c 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -89,6 +89,10 @@ jobs: matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} steps: - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' - name: Get test results uses: actions/download-artifact@v3 with: @@ -96,7 +100,7 @@ jobs: - name: Install deps run: | ls - pip install -e . + pip install . - name: Send Icy ${{ matrix.key }} tests shell: bash -l {0} run: python scripts/check_compatibility_java_software.py icy ${{ matrix.key }} test_summaries/artifact diff --git a/.gitignore b/.gitignore index 8d1ea1e1..5c9e20da 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ __pycache__/ docs/ *.pyc TEMP/ +bioimageio-gh-pages +scripts/check_compatibility_java_software/test_summaries_null_null \ No newline at end of file diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java index 39a5a390..e9abf121 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java @@ -70,9 +70,13 @@ public class ContinuousIntegration { private static final String TEST_NAME = "reproduce test outputs from test inputs"; public static void main(String[] args) throws IOException { - - software = args[0]; - version = args[1]; + if (args.length != 0) { + software = args[0]; + version = args[1]; + } else { + software = "default"; + version = "default"; + } Path currentDir = Paths.get(ContinuousIntegration.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent(); Path rdfDir = currentDir.resolve("../../../bioimageio-gh-pages/rdfs").normalize(); @@ -224,10 +228,15 @@ private static Map testModelDownload(ModelDescriptor rd) { } else { error = downloadModel(rd); } + String details = null; + if (error != null && error.contains("The provided name does not correspond to")) + details = "Model does not exist on the Bioimage.io repo"; + else if (error != null) + details = error; return create(path, error == null ? "passed" : "failed", error == null ? null : software + " unable to download model", - error, error); + error, details); } private static String downloadModel(ModelDescriptor rd) { From 0ff8c707f04eb60ab371201a12fdcad8bf2ef857 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 16:11:19 +0200 Subject: [PATCH 071/150] update gitignore again and remove silly print --- .github/workflows/check_compatibility_deepimagej.yaml | 1 - .github/workflows/check_compatibility_icy.yaml | 1 - .gitignore | 3 ++- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index d942185b..4b8c4a8a 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -99,7 +99,6 @@ jobs: path: test_summaries_deepimagej_${{ matrix.key }} - name: Install deps run: | - ls pip install . - name: Send deepimagej ${{ matrix.key }} tests shell: bash -l {0} diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index ed79a60c..338358f1 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -99,7 +99,6 @@ jobs: path: test_summaries - name: Install deps run: | - ls pip install . - name: Send Icy ${{ matrix.key }} tests shell: bash -l {0} diff --git a/.gitignore b/.gitignore index 5c9e20da..aa48971c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ docs/ *.pyc TEMP/ bioimageio-gh-pages -scripts/check_compatibility_java_software/test_summaries_null_null \ No newline at end of file +scripts/check_compatibility_java_software/test_summaries_null_null +scripts/check_compatibility_java_software/test_summaries_default_default \ No newline at end of file From d700c34f30f232775a3de43d54f7721a4d62d157 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 18:51:53 +0200 Subject: [PATCH 072/150] provide the arguments correctly --- .github/workflows/check_compatibility_deepimagej.yaml | 2 +- .github/workflows/check_compatibility_icy.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 4b8c4a8a..814e2053 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -102,4 +102,4 @@ jobs: pip install . - name: Send deepimagej ${{ matrix.key }} tests shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} test_summaries_deepimagej_{{ matrix.key }}/artifact + run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} --summaries_dir "test_summaries_deepimagej_${{ matrix.key }}/artifact" diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 338358f1..afe218de 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -102,4 +102,4 @@ jobs: pip install . - name: Send Icy ${{ matrix.key }} tests shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py icy ${{ matrix.key }} test_summaries/artifact + run: python scripts/check_compatibility_java_software.py icy ${{ matrix.key }} --summaries_dir "test_summaries_icy_${{ matrix.key }}/artifact" From a64cc1dd4e2f5823e50bf8cd2af1b5a8aa948936 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 19:20:00 +0200 Subject: [PATCH 073/150] correct error that was failing passed tests --- .../modelrunner/ci/ContinuousIntegration.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java index e9abf121..a134f325 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java @@ -97,6 +97,8 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa for (Path rdfPath : rdfFiles) { System.out.println(""); System.out.println(""); + rdfPath = Paths.get("/home/carlos/git/collection/bioimageio-gh-pages" + + "/rdfs/10.5281/zenodo.5874741/5874742/rdf.yaml"); System.out.println(rdfPath); Map rdf = new LinkedHashMap(); @@ -151,7 +153,7 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa } catch (Exception ex) { ex.printStackTrace(); summaryWeightFormat = create(rdfPath, "failed", "exception thrown during testing", - stackTrace(ex), "test was interrupted by an exception while testing" + ww.getFramework() + " weigths"); + stackTrace(ex), "test was interrupted by an exception while testing " + ww.getFramework() + " weigths"); } summariesPath = summariesDir.toAbsolutePath() + File.separator + rdID + File.separator + "test_summary_" + ww.getFramework() + ".yaml"; @@ -330,7 +332,6 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int return failInferenceTest(rd.getName(), "unable to run model", stackTrace(e)); } - List maxDif = new ArrayList(); for (int i = 0; i < rd.getOutputTensors().size(); i ++) { Tensor tt = (Tensor) outs.get(i); if (rd.getOutputTensors().get(i).getPostprocessing().size() > 0) { @@ -356,12 +357,12 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int .multiThreaded().forEachPixel( ( j, o ) -> o.set( (T) new FloatType(o.getRealFloat() - j.getRealFloat())) ); double diff = computeMaxDiff(rai); if (diff > Math.pow(10, -decimal)) - return failInferenceTest(rd.getName(), "output number " + i + " produces a very different result, " - + "the max difference is " + diff +", bigger than max alllowed " + Math.pow(10, -decimal), null); - maxDif.add(computeMaxDiff(rai)); + return failInferenceTest(rd.getModelPath(), "output number " + i + " is not correct", + "output number " + i + " produces a very different result, " + + "the max difference is " + diff +", bigger than max alllowed " + Math.pow(10, -decimal)); } - return create(null, "passed", null, null, null); + return create(Paths.get(rd.getModelPath()), "passed", null, null, null); } private static Map failInferenceTest(String sourceName, String error, String tb) { From b90e8258ad33b7ae40cf7cedef41ffcdf5f195e5 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 19:45:13 +0200 Subject: [PATCH 074/150] fail the workflow on purpose --- .github/workflows/check_compatibility_deepimagej.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 814e2053..14f89ddc 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -20,6 +20,13 @@ jobs: outputs: matrix: ${{ steps.set-dict.outputs.matrix }} steps: + - run: wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + path: all_versions.json + - name: Fail this workflow + run: exit 1 - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 From 8f4ea3e9bb934200d0fc7ab75c444b57ace203e5 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 19:46:18 +0200 Subject: [PATCH 075/150] fail the other workflow on purpose --- .github/workflows/check_compatibility_icy.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index afe218de..480122f1 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -20,6 +20,13 @@ jobs: outputs: matrix: ${{ steps.set-dict.outputs.matrix }} steps: + - run: wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + path: all_versions.json + - name: Fail this workflow + run: exit 1 - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 From 7f2c9723f883045ca194fd6d8df22091db809dd5 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 19:47:05 +0200 Subject: [PATCH 076/150] test fail --- .github/workflows/check_compatibility_icy.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index 480122f1..d1114509 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -20,6 +20,8 @@ jobs: outputs: matrix: ${{ steps.set-dict.outputs.matrix }} steps: + - name: Fail this workflow + run: exit 1 - run: wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json - name: Upload artifacts uses: actions/upload-artifact@v3 From 7a04b2e5c8b3effc2869b2202a3efdab11a8325a Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 19:50:32 +0200 Subject: [PATCH 077/150] restore build yaml --- .github/workflows/build.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2defc7a4..6b404f4b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,8 +1,6 @@ name: test backoffice and build docs -on: - branches: - - doesnt-exist +on: push concurrency: group: test From b5a4014f06b511dd31337b3b91ed10b89eabdc71 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 19:51:25 +0200 Subject: [PATCH 078/150] restore default --- .github/workflows/generate_collection_json.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate_collection_json.yaml b/.github/workflows/generate_collection_json.yaml index 653e724c..a38d7c4a 100644 --- a/.github/workflows/generate_collection_json.yaml +++ b/.github/workflows/generate_collection_json.yaml @@ -3,8 +3,8 @@ run-name: generate collection on: workflow_dispatch: - #push: - #branches: [main] + push: + branches: [main] concurrency: generate-collection-json From 7195192df3c207cb87da7ebc5d210aefe1111e6d Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 22:04:04 +0200 Subject: [PATCH 079/150] remove intentional fail --- .github/workflows/check_compatibility_deepimagej.yaml | 7 ------- .github/workflows/check_compatibility_icy.yaml | 3 --- 2 files changed, 10 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 14f89ddc..814e2053 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -20,13 +20,6 @@ jobs: outputs: matrix: ${{ steps.set-dict.outputs.matrix }} steps: - - run: wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - path: all_versions.json - - name: Fail this workflow - run: exit 1 - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index d1114509..de909814 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -20,9 +20,6 @@ jobs: outputs: matrix: ${{ steps.set-dict.outputs.matrix }} steps: - - name: Fail this workflow - run: exit 1 - - run: wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json - name: Upload artifacts uses: actions/upload-artifact@v3 with: From 06da2c4cdc452a06e37012789a275bbc44a20a69 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 10 Jul 2024 22:47:17 +0200 Subject: [PATCH 080/150] remove default path forgotten --- .../java/io/bioimage/modelrunner/ci/ContinuousIntegration.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java index a134f325..3927b1b5 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java @@ -97,8 +97,6 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa for (Path rdfPath : rdfFiles) { System.out.println(""); System.out.println(""); - rdfPath = Paths.get("/home/carlos/git/collection/bioimageio-gh-pages" - + "/rdfs/10.5281/zenodo.5874741/5874742/rdf.yaml"); System.out.println(rdfPath); Map rdf = new LinkedHashMap(); From 1ee4bcb551104584a1bc11553d9ee124b61e6c0b Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 11 Jul 2024 14:17:43 +0200 Subject: [PATCH 081/150] make the details more understandable --- .../io/bioimage/modelrunner/ci/ContinuousIntegration.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java index 3927b1b5..1705f60f 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java @@ -98,7 +98,6 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa System.out.println(""); System.out.println(""); System.out.println(rdfPath); - Map rdf = new LinkedHashMap(); try { rdf = YAMLUtils.load(rdfPath.toAbsolutePath().toString()); @@ -244,7 +243,7 @@ private static String downloadModel(ModelDescriptor rd) { try { BioimageioRepo br = BioimageioRepo.connect(); String folder = br.downloadByName(rd.getName(), "models"); - rd.addModelPath(Paths.get(folder)); + rd.addModelPath(Paths.get(folder).toAbsolutePath()); downloadedModelsCorrectly.put(rd.getName(), folder); } catch (Exception ex) { error = stackTrace(ex); @@ -315,6 +314,8 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int e.printStackTrace(); return failInferenceTest(rd.getName(), "selected weights not supported by " + software + ": " + ww.getFramework(), stackTrace(e)); } + if (engineInfo == null) return create(Paths.get(rd.getModelPath()), "failed", "no compatible weights", + null, "no compatible weights for " + ww.getFramework() + "_" + ww.getTrainingVersion()); Model model; try { model = Model.createDeepLearningModel(rd.getModelPath(), rd.getModelPath() + File.separator + ww.getSourceFileName(), engineInfo); From 0fe821e33a280feb62e8f66c8828361310012f98 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 11 Jul 2024 14:22:08 +0200 Subject: [PATCH 082/150] remove intentional fail --- .github/workflows/check_compatibility_icy.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index de909814..afe218de 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -20,12 +20,6 @@ jobs: outputs: matrix: ${{ steps.set-dict.outputs.matrix }} steps: - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - path: all_versions.json - - name: Fail this workflow - run: exit 1 - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 From efd911c5a077a856839e7fec5f84047aacc64793 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 11 Jul 2024 16:51:14 +0200 Subject: [PATCH 083/150] also catch errors --- .../modelrunner/ci/ContinuousIntegration.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java index 1705f60f..4984463d 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java @@ -101,7 +101,7 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa Map rdf = new LinkedHashMap(); try { rdf = YAMLUtils.load(rdfPath.toAbsolutePath().toString()); - } catch (Exception ex) { + } catch (Exception | Error ex) { ex.printStackTrace(); continue; } @@ -127,7 +127,7 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa ModelWeight weights = null; try { weights = ModelWeight.build((Map) weightFormats); - } catch (Exception ex) { + } catch (Exception | Error ex) { Map summary = create(rdfPath, "failed", "Missing/Invalid weight formats for " + rdID, stackTrace(ex), "Unable to read weight formats"); writeSummary(summariesPath, summary); @@ -147,7 +147,7 @@ public static void runTests(Path rdfDir, String resourceID, String versionID, Pa Map summaryWeightFormat = new LinkedHashMap(); try { summaryWeightFormat = testResource(rdfPath.toAbsolutePath().toString(), ww, 4, "model"); - } catch (Exception ex) { + } catch (Exception | Error ex) { ex.printStackTrace(); summaryWeightFormat = create(rdfPath, "failed", "exception thrown during testing", stackTrace(ex), "test was interrupted by an exception while testing " + ww.getFramework() + " weigths"); @@ -245,7 +245,7 @@ private static String downloadModel(ModelDescriptor rd) { String folder = br.downloadByName(rd.getName(), "models"); rd.addModelPath(Paths.get(folder).toAbsolutePath()); downloadedModelsCorrectly.put(rd.getName(), folder); - } catch (Exception ex) { + } catch (Exception | Error ex) { error = stackTrace(ex); downloadedModelsIncorrectly.put(rd.getName(), error); } @@ -286,7 +286,7 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int RandomAccessibleInterval rai; try { rai = DecodeNumpy.retrieveImgLib2FromNpy(rd.getTestInputs().get(i).getLocalPath().toAbsolutePath().toString()); - } catch (Exception e) { + } catch (Exception | Error e) { return failInferenceTest(rd.getName(), "unable to open test input: " + rd.getTestInputs().get(i).getString(), stackTrace(e)); } Tensor inputTensor = Tensor.build(rd.getInputTensors().get(i).getName(), rd.getInputTensors().get(i).getAxesOrder(), rai); @@ -295,7 +295,7 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int JavaProcessing preproc; try { preproc = JavaProcessing.definePreprocessing(transform.getName(), transform.getKwargs()); - } catch (Exception e) { + } catch (Exception | Error e) { e.printStackTrace(); return failInferenceTest(rd.getName(), "pre-processing transformation not supported by " + software + ": " + transform.getName(), stackTrace(e)); } @@ -310,7 +310,7 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int EngineInfo engineInfo; try { engineInfo = EngineInfo.defineCompatibleDLEngineWithRdfYamlWeights(ww); - } catch (Exception e) { + } catch (Exception | Error e) { e.printStackTrace(); return failInferenceTest(rd.getName(), "selected weights not supported by " + software + ": " + ww.getFramework(), stackTrace(e)); } @@ -320,13 +320,13 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int try { model = Model.createDeepLearningModel(rd.getModelPath(), rd.getModelPath() + File.separator + ww.getSourceFileName(), engineInfo); model.loadModel(); - } catch (Exception e) { + } catch (Exception | Error e) { e.printStackTrace(); return failInferenceTest(rd.getName(), "unable to instantiate/load model", stackTrace(e)); } try { model.runModel(inps, outs); - } catch (Exception e) { + } catch (Exception | Error e) { e.printStackTrace(); return failInferenceTest(rd.getName(), "unable to run model", stackTrace(e)); } @@ -339,7 +339,7 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int JavaProcessing preproc; try { preproc = JavaProcessing.definePreprocessing(transform.getName(), transform.getKwargs()); - } catch (Exception e) { + } catch (Exception | Error e) { e.printStackTrace(); return failInferenceTest(rd.getName(), "post-processing transformation not supported by " + software + ": " + transform.getName(), stackTrace(e)); } @@ -348,7 +348,7 @@ Map testModelInference(ModelDescriptor rd, WeightFormat ww, int RandomAccessibleInterval rai; try { rai = DecodeNumpy.retrieveImgLib2FromNpy(rd.getTestOutputs().get(i).getLocalPath().toAbsolutePath().toString()); - } catch (Exception e) { + } catch (Exception | Error e) { e.printStackTrace(); return failInferenceTest(rd.getName(), "unable to open test output: " + rd.getTestOutputs().get(i).getString(), stackTrace(e)); } From 8924caed12f8995b243e81152d6f1783121f4bd9 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 11 Jul 2024 17:14:03 +0200 Subject: [PATCH 084/150] at the moment only use one version per engine --- .../main/java/io/bioimage/modelrunner/ci/DownloadEngines.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java index 4c8085ac..f248fd39 100644 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java +++ b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java @@ -45,7 +45,7 @@ public class DownloadEngines { private static final String ENGINES_DIR = new File(CWD, "engines").getAbsolutePath(); public static void main(String[] args) throws IOException { - if (args[0].equals(Tags.DEEPIMAGEJ)) { + if (args[0].equals(Tags.DEEPIMAGEJ) || args[0].equals(Tags.ICY)) { EngineInstall engineManager = EngineInstall.createInstaller(ENGINES_DIR); engineManager.basicEngineInstallation(); //InstalledEngines.buildEnginesFinder(ENGINES_DIR).getDownloadedForOS().stream().map(i -> i.toString()) From 854f3561b65022d753ad7afe28e34b783602755d Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 11 Jul 2024 18:49:30 +0200 Subject: [PATCH 085/150] correct a couple of details of the action --- .github/workflows/check_compatibility_icy.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml index afe218de..f6a5fdf8 100644 --- a/.github/workflows/check_compatibility_icy.yaml +++ b/.github/workflows/check_compatibility_icy.yaml @@ -80,11 +80,11 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v3 with: - path: test_summaries + path: test_summaries_icy_${{ matrix.key }} sendreport: runs-on: ubuntu-latest - needs: run + needs: [generate-version-dict, run] strategy: matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} steps: @@ -96,10 +96,10 @@ jobs: - name: Get test results uses: actions/download-artifact@v3 with: - path: test_summaries + path: test_summaries_icy_${{ matrix.key }} - name: Install deps run: | pip install . - - name: Send Icy ${{ matrix.key }} tests + - name: Send icy ${{ matrix.key }} tests shell: bash -l {0} run: python scripts/check_compatibility_java_software.py icy ${{ matrix.key }} --summaries_dir "test_summaries_icy_${{ matrix.key }}/artifact" From fab556e6170d6e38ccf1a59a84925a707284f67f Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Mon, 27 Jan 2025 19:51:28 +0100 Subject: [PATCH 086/150] make CI specific to DIJ and Python using headless mode --- .../workflows/check_compatibility_icy.yaml | 105 ----- scripts/check_compatibility_java_software.py | 184 -------- .../.gitignore | 16 - .../check_compatibility_java_software/pom.xml | 99 ---- .../modelrunner/ci/ContinuousIntegration.java | 399 ---------------- .../modelrunner/ci/DownloadEngines.java | 67 --- .../modelrunner/ci/JavaProcessing.java | 427 ------------------ .../java/io/bioimage/modelrunner/ci/Tags.java | 9 - 8 files changed, 1306 deletions(-) delete mode 100644 .github/workflows/check_compatibility_icy.yaml delete mode 100644 scripts/check_compatibility_java_software.py delete mode 100644 scripts/check_compatibility_java_software/.gitignore delete mode 100644 scripts/check_compatibility_java_software/pom.xml delete mode 100644 scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java delete mode 100644 scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java delete mode 100644 scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java delete mode 100644 scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/Tags.java diff --git a/.github/workflows/check_compatibility_icy.yaml b/.github/workflows/check_compatibility_icy.yaml deleted file mode 100644 index f6a5fdf8..00000000 --- a/.github/workflows/check_compatibility_icy.yaml +++ /dev/null @@ -1,105 +0,0 @@ -name: check compatibility icy - -concurrency: icy - -on: - push: - branches: - - main - paths: - - .github/workflows/check_compatibility_icy.yaml - - scripts/get_java_software_versions.py - - scripts/check_compatibility_java_software/**/* - workflow_dispatch: - schedule: - - cron: 0 1 * * * # update compatibility once a day - -jobs: - generate-version-dict: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.set-dict.outputs.matrix }} - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Install deps - run: pip install requests==2.28.2 beautifulsoup4==4.12.3 packaging==23.0 - - name: Generate dict - id: set-dict - run: | - matrix_output=$(python scripts/get_java_software_versions.py icy) - echo "matrix=${matrix_output}" >> $GITHUB_OUTPUT - - name: Versions matrix - run: echo '${{ steps.set-dict.outputs.matrix }}' - - run: - needs: generate-version-dict - runs-on: ubuntu-latest - strategy: - matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} - steps: - - uses: actions/checkout@v3 - - uses: actions/checkout@v3 - with: - repository: bioimage-io/collection-bioimage-io - ref: gh-pages - path: bioimageio-gh-pages - - name: Setup Maven Action - uses: stCarolas/setup-maven@v4.5 - with: - java-version: 11 - maven-version: 3.9.5 - - name: Build with Maven - run: | - cd scripts/check_compatibility_java_software - mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - - name: Get jar file name - id: get-jar - run: | - cd scripts/check_compatibility_java_software - jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') - if [ -z "$jarfile" ]; then - echo "Failed to get jar file name" - exit 1 - fi - if [ ! -f "target/$jarfile" ]; then - echo "Jar file not found: target/$jarfile" - exit 1 - fi - echo "Jar file found: target/$jarfile" - echo "jarfile=$jarfile" >> $GITHUB_OUTPUT - - name: Download engines - run: | - java -cp "scripts/check_compatibility_java_software/target/${{ steps.get-jar.outputs.jarfile }}" io.bioimage.modelrunner.ci.DownloadEngines icy - - name: Run models - run: | - java -cp "scripts/check_compatibility_java_software/target/${{ steps.get-jar.outputs.jarfile }}" io.bioimage.modelrunner.ci.ContinuousIntegration icy ${{ matrix.key }} - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - path: test_summaries_icy_${{ matrix.key }} - - sendreport: - runs-on: ubuntu-latest - needs: [generate-version-dict, run] - strategy: - matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.10' - - name: Get test results - uses: actions/download-artifact@v3 - with: - path: test_summaries_icy_${{ matrix.key }} - - name: Install deps - run: | - pip install . - - name: Send icy ${{ matrix.key }} tests - shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py icy ${{ matrix.key }} --summaries_dir "test_summaries_icy_${{ matrix.key }}/artifact" diff --git a/scripts/check_compatibility_java_software.py b/scripts/check_compatibility_java_software.py deleted file mode 100644 index ccce7ef3..00000000 --- a/scripts/check_compatibility_java_software.py +++ /dev/null @@ -1,184 +0,0 @@ -import argparse -from typing import List, Dict, Any -import os - -import requests - -from loguru import logger -from ruyaml import YAML, YAMLError - -from bioimageio_collection_backoffice.db_structure.compatibility import ( - CompatiblityReport, -) -from bioimageio_collection_backoffice.remote_collection import Record, RemoteCollection -from bioimageio_collection_backoffice.s3_client import Client - - - -def find_java_summaries(directory: str) -> List[str]: - """Walks through a directory and its subdirectories to find all YAML files.""" - yaml_files: List[str] = [] - # Walk through all directories and files in the specified directory - for root, _, files in os.walk(directory): - for file in files: - # Check if the file ends with .yaml or .yml - if file.endswith('.yaml') or file.endswith('.yml'): - # Create the full path to the file - full_path = os.path.join(root, file) - # Append the full path to the list of YAML files - yaml_files.append(full_path) - return yaml_files - - - -def read_yaml_from_url(url: str): - """Fetch and parse a YAML file from a specified URL. - - Args: - url (str): The URL of the YAML file. - - Returns: - dict: Parsed YAML data as a dictionary. - """ - response = requests.get(url) - response.raise_for_status() - - yaml=YAML(typ="safe") - data = yaml.load(response.text) - return data - - -def get_tests_from_summaries(rdf: str, path_to_summaries: str) -> Dict[str, str]: - summary = {} - try: - rdf_yaml = read_yaml_from_url(rdf) - except requests.RequestException as e: - summary["status"] = "failed" - summary["error"] = "Unable to access rdf.yaml file" - summary["details"] = str(e) - return summary - except YAMLError as e: - summary["status"] = "failed" - summary["error"] = "Unable to read rdf.yaml file" - summary["details"] = str(e) - return summary - - id = rdf_yaml["id"] - rdf_path = os.path.join(path_to_summaries, id) - test_files = os.listdir(rdf_path) - - if len(test_files) == 0: - summary["status"] = "failed" - summary["error"] = "No tests executed" - summary["details"] = "The model tests were not executed or the test files could not be located" - return summary - - summaries_yaml = None - error: str = "" - for test_file in test_files: - try: - summaries_yaml=YAML(typ='safe') # default, if not specfied, is 'rt' (round-trip) - summaries_yaml.load(test_file) - summary = find_passed_test(summaries_yaml) - if summary["status"] == "passed": - return summary - except YAMLError as e: - error += str(e) + os.linesep - continue - - if summary["status"] is not None: - return summary - - summary["status"] = "failed" - summary["error"] = "Unable to read the test results yaml file" - summary["details"] = str(error) - - return summary - - -def find_passed_test(summaries_yaml: List[Dict[Any, Any]]) -> Dict[Any, Any]: - summary = {} - for elem in summaries_yaml: - if not isinstance(elem, dict): - summary["status"] = "failed" - summary["error"] = "Invalid test output format" - summary["details"] = "Expected a list of dictionaries, but received an improperly formatted element." - return summary - elif elem.get("status") is not None: - return elem - - summary["status"] = "failed" - summary["error"] = "No test contents found" - summary["details"] = "test file was empty." - return summary - - - -def check_compatibility_java_software_impl( - record: Record, - software_name: str, - version: str, - summaries_dir: str = "test_summaries/artifact", -): - tool = f"{software_name}{version}" - report_path = record.get_compatibility_report_path(tool) - if list(record.client.ls(report_path)): - return - - rdf_data = record.client.load_file(record.rdf_path) - assert rdf_data is not None - rdf = yaml.load(rdf_data) - assert isinstance(rdf, dict) - if rdf.get("type") != "model": - return CompatiblityReport( - tool=tool, - status="not-applicable", - error=None, - details="only 'model' resources can be used in icy.", - ) - - #summaries = find_java_summaries(summaries_dir) - summary = get_tests_from_summaries(record.client.get_file_url(record.rdf_path), summaries_dir) - # produce test summaries for each weight format - # TODO check what it produces summary = test_model(record.client.get_file_url(record.rdf_path)) - - return CompatiblityReport( - tool=tool, - status=summary["status"], - error=None if summary["status"] == "passed" else summary["error"], - details=summary["details"], - links=["{software_name}/{software_name}"], - ) - - -def check_compatibility_java_software( - software_name: str, - version: str, - summaries_dir: str = "test_summaries", -): - """preliminary icy check - - only checks if test outputs are reproduced for onnx, torchscript, or pytorch_state_dict weights. - - """ - collection = RemoteCollection(Client()) - for record in collection.get_published_versions(): - try: - report = check_compatibility_java_software_impl( - record, software_name, version, summaries_dir - ) - except Exception as e: - logger.error(f"failed to check '{record.id}': {e}") - else: - print(report) - if report is not None: - record.set_compatibility_report(report) - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - _ = parser.add_argument("software_name") - _ = parser.add_argument("version") - _ = parser.add_argument("--summaries_dir", default="test_summaries/artifact", help="Directory path where summaries are stored.") - - check_compatibility_java_software(parser.parse_args().software_name, parser.parse_args().version, parser.parse_args().summaries_dir) diff --git a/scripts/check_compatibility_java_software/.gitignore b/scripts/check_compatibility_java_software/.gitignore deleted file mode 100644 index 7aa8b531..00000000 --- a/scripts/check_compatibility_java_software/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -/engines/ -/models/ - -# maven specific files -/target/ - -# eclipse specific files -/.settings/ -.classpath -.project - -# intellij specific files -.idea - -# miscellaneous -*.swp diff --git a/scripts/check_compatibility_java_software/pom.xml b/scripts/check_compatibility_java_software/pom.xml deleted file mode 100644 index cf80c081..00000000 --- a/scripts/check_compatibility_java_software/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - 4.0.0 - - - org.scijava - pom-scijava - 37.0.0 - - - - io.bioimage - dl-modelrunner-ci - 0.0.1-SNAPSHOT - - JDLL CI - Continuous integration code for JDLL - - https://github.com/bioimage-io/pytorch-java-interface-javacpp - 2023 - - Icy Bioimage Analysis - https://icy.bioimageanalysis.org/ - - - - Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - - carlosuc3m - Carlos Javier Garcia Lopez de Haro - https://github.com/carlosuc3m - - developer - debugger - reviewer - support - maintainer - - - - - - Carlos Garcia - https://github.com/carlosuc3m - carlosuc3m - - - - - - Image.sc Forum - https://forum.image.sc/tag/bioimage-io - - - - - scm:git:https://github.com/Icy-imaging/icy-bioimage-io - scm:git:git@github.com:Icy-imaging/icy-bioimage-io - HEAD - https://github.com/Icy-imaging/icy-bioimage-io - - - GitHub Issues - https://github.com/Icy-imaging/icy-bioimage-io/issues - - - None - - - - io.bioimage.modelrunner.ci - - apache_v2 - Institut Pasteur - - 0.5.8 - - - - - scijava.public - https://maven.scijava.org/content/groups/public - - - - - - io.bioimage - dl-modelrunner - ${dl-modelrunner.version} - - - diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java deleted file mode 100644 index 4984463d..00000000 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/ContinuousIntegration.java +++ /dev/null @@ -1,399 +0,0 @@ -/*- - * #%L - * This project performs Continuous Integration tasks on java software based on JDLL - * %% - * Copyright (C) 2023 Institut Pasteur. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ -package io.bioimage.modelrunner.ci; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.PathMatcher; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import io.bioimage.modelrunner.bioimageio.BioimageioRepo; -import io.bioimage.modelrunner.bioimageio.description.ModelDescriptor; -import io.bioimage.modelrunner.bioimageio.description.TransformSpec; -import io.bioimage.modelrunner.bioimageio.description.exceptions.ModelSpecsException; -import io.bioimage.modelrunner.bioimageio.description.weights.ModelWeight; -import io.bioimage.modelrunner.bioimageio.description.weights.WeightFormat; -import io.bioimage.modelrunner.engine.EngineInfo; -import io.bioimage.modelrunner.engine.installation.EngineInstall; -import io.bioimage.modelrunner.model.Model; -import io.bioimage.modelrunner.numpy.DecodeNumpy; -import io.bioimage.modelrunner.tensor.Tensor; -import io.bioimage.modelrunner.utils.Constants; -import io.bioimage.modelrunner.utils.YAMLUtils; -import net.imglib2.Cursor; -import net.imglib2.RandomAccessibleInterval; -import net.imglib2.loops.LoopBuilder; -import net.imglib2.type.NativeType; -import net.imglib2.type.numeric.RealType; -import net.imglib2.type.numeric.real.FloatType; -import net.imglib2.view.Views; - -/** - * - */ -public class ContinuousIntegration { - - private static Map downloadedModelsCorrectly = new HashMap(); - private static Map downloadedModelsIncorrectly = new HashMap(); - - private static String version; - - private static String software; - private static final String TEST_NAME = "reproduce test outputs from test inputs"; - - public static void main(String[] args) throws IOException { - if (args.length != 0) { - software = args[0]; - version = args[1]; - } else { - software = "default"; - version = "default"; - } - - Path currentDir = Paths.get(ContinuousIntegration.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent(); - Path rdfDir = currentDir.resolve("../../../bioimageio-gh-pages/rdfs").normalize(); - - // Create a matcher for the pattern 'rdf.yaml' - runTests(rdfDir, "**", "**", Paths.get("test_summaries_" + software + "_" + version)); - } - - - public static void runTests(Path rdfDir, String resourceID, String versionID, Path summariesDir) throws IOException { - - PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + resourceID + File.separator + versionID + File.separator + Constants.RDF_FNAME); - - List rdfFiles = Files.walk(rdfDir).filter(matcher::matches).collect(Collectors.toList()); - EngineInstall installer = EngineInstall.createInstaller(); - installer.basicEngineInstallation(); - - for (Path rdfPath : rdfFiles) { - System.out.println(""); - System.out.println(""); - System.out.println(rdfPath); - Map rdf = new LinkedHashMap(); - try { - rdf = YAMLUtils.load(rdfPath.toAbsolutePath().toString()); - } catch (Exception | Error ex) { - ex.printStackTrace(); - continue; - } - - Object rdID = rdf.get("id"); - String summariesPath = summariesDir.toAbsolutePath() + File.separator - + (rdID != null ? rdID : "") + File.separator + "test_summary" + ".yaml"; - Object type = rdf.get("type"); - Object weightFormats = rdf.get("weights"); - if (rdID == null || !(rdID instanceof String)) { - new Exception(rdfPath.toAbsolutePath().toString() + " is missing ID field").printStackTrace(); - continue; - } else if (type == null || !(type instanceof String) || !((String) type).equals("model")) { - Map summary = create(rdfPath, "not-applicable", null, null, "not a model"); - writeSummary(summariesPath, summary); - continue; - } else if (weightFormats == null || !(weightFormats instanceof Map)) { - Map summary = create(rdfPath, - "failed", "Missing weights dictionary for " + rdID, null, weightFormats.toString()); - writeSummary(summariesPath, summary); - continue; - } - ModelWeight weights = null; - try { - weights = ModelWeight.build((Map) weightFormats); - } catch (Exception | Error ex) { - Map summary = create(rdfPath, - "failed", "Missing/Invalid weight formats for " + rdID, stackTrace(ex), "Unable to read weight formats"); - writeSummary(summariesPath, summary); - continue; - } - - if (weights != null && weights.gettAllSupportedWeightObjects().size() == 0) { - Map summary = create(rdfPath, - "failed", "Unsupported model weights", null, "The model weights belong to a Deep Learning " - + "framework not supported by " + software + "_" + version + "."); - writeSummary(summariesPath, summary); - continue; - } - - - for (WeightFormat ww : weights.gettAllSupportedWeightObjects()) { - Map summaryWeightFormat = new LinkedHashMap(); - try { - summaryWeightFormat = testResource(rdfPath.toAbsolutePath().toString(), ww, 4, "model"); - } catch (Exception | Error ex) { - ex.printStackTrace(); - summaryWeightFormat = create(rdfPath, "failed", "exception thrown during testing", - stackTrace(ex), "test was interrupted by an exception while testing " + ww.getFramework() + " weigths"); - } - summariesPath = summariesDir.toAbsolutePath() + File.separator - + rdID + File.separator + "test_summary_" + ww.getFramework() + ".yaml"; - writeSummary(summariesPath, summaryWeightFormat); - } - - } - } - - private static Map create(Path rdfPath, String status, String error, - String tb, String details) { - Map summaryMap = new LinkedHashMap(); - summaryMap.put("name", TEST_NAME); - summaryMap.put("status", status); - summaryMap.put("error", error); - summaryMap.put("source_name", rdfPath.toAbsolutePath().toString()); - summaryMap.put("traceback", tb); - summaryMap.put("details", details); - summaryMap.put(software, version);; - return summaryMap; - } - - private static void writeSummaries(String summariesPath, List summaries) throws IOException { - Path path = Paths.get(summariesPath).getParent(); - if (path != null && !Files.exists(path)) - Files.createDirectories(path); - YAMLUtils.writeYamlFile(summariesPath, summaries); - } - - private static void writeSummary(String summariesPath, Map summary) throws IOException { - List summaries = new ArrayList(); - summaries.add(summary); - Path path = Paths.get(summariesPath).getParent(); - if (path != null && !Files.exists(path)) - Files.createDirectories(path); - YAMLUtils.writeYamlFile(summariesPath, summaries); - } - - private static Map testResource(String rdf, WeightFormat weightFormat, int decimal, String expectedType) { - ModelDescriptor rd = null; - try { - rd = ModelDescriptor.readFromLocalFile(rdf, false); - } catch (ModelSpecsException e) { - Map summary = create(Paths.get(rdf), - "failed", "Unable to parse specs from rdf.yaml file", stackTrace(e), - software + "_" + version + " is unable to read the specs from the rdf.yaml file. Spec version" - + " might not be compatible with the software version."); - return summary; - } - - Map test1 = testExpectedResourceType(rd, expectedType); - if (test1.get("status").equals("failed")) return test1; - - Map test2 = testModelDownload(rd); - if (test2.get("status").equals("failed")) return test2; - - return testModelInference(rd, weightFormat, decimal); - } - - private static Map testExpectedResourceType(ModelDescriptor rd, String type) { - boolean yes = rd.getType().equals(type); - Path path = Paths.get(rd.getModelPath() + File.separator + Constants.RDF_FNAME); - return create(path, yes ? "passed" : "failed", - yes ? null : "expected type was " + type + " but found " + rd.getType(), null, null); - } - - private static Map testModelDownload(ModelDescriptor rd) { - Path path = Paths.get(rd.getModelPath() + File.separator + Constants.RDF_FNAME); - String error = null; - if (downloadedModelsCorrectly.keySet().contains(rd.getName())) { - rd.addModelPath(Paths.get(downloadedModelsCorrectly.get(rd.getName()))); - } else if (downloadedModelsIncorrectly.keySet().contains(rd.getName())) { - error = downloadedModelsIncorrectly.get(rd.getName()); - } else { - error = downloadModel(rd); - } - String details = null; - if (error != null && error.contains("The provided name does not correspond to")) - details = "Model does not exist on the Bioimage.io repo"; - else if (error != null) - details = error; - - return create(path, error == null ? "passed" : "failed", - error == null ? null : software + " unable to download model", - error, details); - } - - private static String downloadModel(ModelDescriptor rd) { - String error = null; - try { - BioimageioRepo br = BioimageioRepo.connect(); - String folder = br.downloadByName(rd.getName(), "models"); - rd.addModelPath(Paths.get(folder).toAbsolutePath()); - downloadedModelsCorrectly.put(rd.getName(), folder); - } catch (Exception | Error ex) { - error = stackTrace(ex); - downloadedModelsIncorrectly.put(rd.getName(), error); - } - return error; - } - - private static < T extends RealType< T > & NativeType< T > > - Map testModelInference(ModelDescriptor rd, WeightFormat ww, int decimal) { - System.out.println(rd.getName()); - System.out.println(ww.getFramework()); - Map inferTest = new LinkedHashMap(); - inferTest.put("name", "reproduce test inputs from test outptus for " + ww.getFramework()); - inferTest.put("source_name", rd.getName()); - inferTest.put(software, version); - if (rd.getModelPath() == null) { - return create(null, "failed", - "model was not correctly downloaded", null, null); - } - if (software.equals(Tags.DEEPIMAGEJ) && rd.getInputTensors().size() != 1) { - return create(null, "failed", - software + " only supports models with 1 (one) input", null, software + " only supports models " - + "with 1 input and this model has " + rd.getInputTensors().size()); - } else if (rd.getInputTensors().size() != rd.getTestInputs().size()) { - return create(null, "failed", - "the number of test inputs should be the same as the number of model inputs", null, - "the number of test inputs should be the same as the number of model inputs," - + rd.getInputTensors().size() + " vs " + rd.getTestInputs().size()); - } else if (rd.getOutputTensors().size() != rd.getTestOutputs().size()) { - return create(null, "failed", - "the number of test outputs should be the same as the number of model outputs", null, - "the number of test outputs should be the same as the number of model outputs," - + rd.getInputTensors().size() + " vs " + rd.getTestInputs().size()); - } - - List> inps = new ArrayList>(); - List> outs = new ArrayList>(); - for (int i = 0; i < rd.getInputTensors().size(); i ++) { - RandomAccessibleInterval rai; - try { - rai = DecodeNumpy.retrieveImgLib2FromNpy(rd.getTestInputs().get(i).getLocalPath().toAbsolutePath().toString()); - } catch (Exception | Error e) { - return failInferenceTest(rd.getName(), "unable to open test input: " + rd.getTestInputs().get(i).getString(), stackTrace(e)); - } - Tensor inputTensor = Tensor.build(rd.getInputTensors().get(i).getName(), rd.getInputTensors().get(i).getAxesOrder(), rai); - if (rd.getInputTensors().get(i).getPreprocessing().size() > 0) { - TransformSpec transform = rd.getInputTensors().get(i).getPreprocessing().get(0); - JavaProcessing preproc; - try { - preproc = JavaProcessing.definePreprocessing(transform.getName(), transform.getKwargs()); - } catch (Exception | Error e) { - e.printStackTrace(); - return failInferenceTest(rd.getName(), "pre-processing transformation not supported by " + software + ": " + transform.getName(), stackTrace(e)); - } - inputTensor = preproc.execute(rd.getInputTensors().get(i), inputTensor); - } - inps.add(inputTensor); - } - for (int i = 0; i < rd.getOutputTensors().size(); i ++) { - Tensor outputTensor = Tensor.buildEmptyTensor(rd.getOutputTensors().get(i).getName(), rd.getOutputTensors().get(i).getAxesOrder()); - outs.add(outputTensor); - } - EngineInfo engineInfo; - try { - engineInfo = EngineInfo.defineCompatibleDLEngineWithRdfYamlWeights(ww); - } catch (Exception | Error e) { - e.printStackTrace(); - return failInferenceTest(rd.getName(), "selected weights not supported by " + software + ": " + ww.getFramework(), stackTrace(e)); - } - if (engineInfo == null) return create(Paths.get(rd.getModelPath()), "failed", "no compatible weights", - null, "no compatible weights for " + ww.getFramework() + "_" + ww.getTrainingVersion()); - Model model; - try { - model = Model.createDeepLearningModel(rd.getModelPath(), rd.getModelPath() + File.separator + ww.getSourceFileName(), engineInfo); - model.loadModel(); - } catch (Exception | Error e) { - e.printStackTrace(); - return failInferenceTest(rd.getName(), "unable to instantiate/load model", stackTrace(e)); - } - try { - model.runModel(inps, outs); - } catch (Exception | Error e) { - e.printStackTrace(); - return failInferenceTest(rd.getName(), "unable to run model", stackTrace(e)); - } - - for (int i = 0; i < rd.getOutputTensors().size(); i ++) { - Tensor tt = (Tensor) outs.get(i); - if (rd.getOutputTensors().get(i).getPostprocessing().size() > 0) { - TransformSpec transform = rd.getOutputTensors().get(i).getPostprocessing().get(0); - if (transform.getName().equals("python")) continue; - JavaProcessing preproc; - try { - preproc = JavaProcessing.definePreprocessing(transform.getName(), transform.getKwargs()); - } catch (Exception | Error e) { - e.printStackTrace(); - return failInferenceTest(rd.getName(), "post-processing transformation not supported by " + software + ": " + transform.getName(), stackTrace(e)); - } - tt = preproc.execute(rd.getInputTensors().get(i), tt); - } - RandomAccessibleInterval rai; - try { - rai = DecodeNumpy.retrieveImgLib2FromNpy(rd.getTestOutputs().get(i).getLocalPath().toAbsolutePath().toString()); - } catch (Exception | Error e) { - e.printStackTrace(); - return failInferenceTest(rd.getName(), "unable to open test output: " + rd.getTestOutputs().get(i).getString(), stackTrace(e)); - } - LoopBuilder.setImages( tt.getData(), rai ) - .multiThreaded().forEachPixel( ( j, o ) -> o.set( (T) new FloatType(o.getRealFloat() - j.getRealFloat())) ); - double diff = computeMaxDiff(rai); - if (diff > Math.pow(10, -decimal)) - return failInferenceTest(rd.getModelPath(), "output number " + i + " is not correct", - "output number " + i + " produces a very different result, " - + "the max difference is " + diff +", bigger than max alllowed " + Math.pow(10, -decimal)); - } - - return create(Paths.get(rd.getModelPath()), "passed", null, null, null); - } - - private static Map failInferenceTest(String sourceName, String error, String tb) { - return create(Paths.get(sourceName), "failed", error, tb, tb); - } - - - public static < T extends RealType< T > & NativeType< T > > double computeMaxDiff(final RandomAccessibleInterval< T > input) { - Cursor iterator = Views.iterable(input).cursor(); - T type = iterator.next(); - T min = type.copy(); - T max = type.copy(); - while ( iterator.hasNext() ) - { - type = iterator.next(); - if ( type.compareTo( min ) < 0 ) - min.set( type ); - if ( type.compareTo( max ) > 0 ) - max.set( type ); - } - return Math.max(-min.getRealDouble(), min.getRealDouble()); - } - - /** Dumps the given exception, including stack trace, to a string. - * - * @param t - * the given exception {@link Throwable} - * @return the String containing the whole exception trace - */ - public static String stackTrace(Throwable t) { - StringWriter sw = new StringWriter(); - t.printStackTrace(new PrintWriter(sw)); - return sw.toString(); - } -} diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java deleted file mode 100644 index f248fd39..00000000 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/DownloadEngines.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * #%L - * This project performs Continuous Integration tasks on the JDLL library - * %% - * Copyright (C) 2023 Institut Pasteur. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ -package io.bioimage.modelrunner.ci; - -import java.io.File; -import java.io.IOException; -import java.util.List; - -import io.bioimage.modelrunner.engine.installation.EngineInstall; -import io.bioimage.modelrunner.versionmanagement.AvailableEngines; -import io.bioimage.modelrunner.versionmanagement.DeepLearningVersion; -import io.bioimage.modelrunner.versionmanagement.InstalledEngines; - -/** - * Class to install the engines that a DIJ or Icy distribution would install - * - * @author Carlos Javier GArcia Lopez de Haro - */ -public class DownloadEngines { - /** - * Current directory - */ - private static final String CWD = new File("").getAbsolutePath(); - /** - * Directory where the engine will be downloaded, if you want to download it - * into another folder, please change it. - */ - private static final String ENGINES_DIR = new File(CWD, "engines").getAbsolutePath(); - - public static void main(String[] args) throws IOException { - if (args[0].equals(Tags.DEEPIMAGEJ) || args[0].equals(Tags.ICY)) { - EngineInstall engineManager = EngineInstall.createInstaller(ENGINES_DIR); - engineManager.basicEngineInstallation(); - //InstalledEngines.buildEnginesFinder(ENGINES_DIR).getDownloadedForOS().stream().map(i -> i.toString()) - System.out.println(InstalledEngines.buildEnginesFinder(ENGINES_DIR).getDownloadedForOS()); - } else if (args[0].equals(Tags.ICY)) { - List allEngines = AvailableEngines.getForCurrentOS(); - for (DeepLearningVersion engine : allEngines) { - try { - EngineInstall.installEngineInDir(engine, ENGINES_DIR); - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - System.out.println(InstalledEngines.buildEnginesFinder(ENGINES_DIR).getDownloadedForOS()); - } - } -} diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java deleted file mode 100644 index 24e05b34..00000000 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/JavaProcessing.java +++ /dev/null @@ -1,427 +0,0 @@ -package io.bioimage.modelrunner.ci; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Parameter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import io.bioimage.modelrunner.bioimageio.description.TensorSpec; -import io.bioimage.modelrunner.tensor.Tensor; - -import net.imglib2.RandomAccessibleInterval; -import net.imglib2.type.NativeType; -import net.imglib2.type.Type; -import net.imglib2.type.numeric.RealType; - -/** - * Class that handles the Java pre-processing transformations. - * The transformations can be either custom designed by the developer or - * coming from the Bioimage.io Java library - * and the tensors produced by them - * - * @author Carlos Garcia Lopez de Haro - * - */ -public class JavaProcessing { - /** - * Transformation as specified in the rdf.yaml - */ - private String rdfSpec; - /** - * String containing the name of the method that runs JAva pre-processing - */ - private String javaMethodName; - /** - * String referring to the BioImage.io class that contains the specified transformations - */ - private String javaClassName; - /** - * Class that contains the pre-processing - */ - private Class transformationClass; - /** - * Arguments used for the Java method - */ - private Map args; - /** - * Name of the tensor that is going to be pre-processed - */ - private String tensorName; - /** - * Specs of the tensor that is going to be pre-processed - */ - private TensorSpec tensorSpec; - /** - * INDArray containing all the information of the input tensor to which this - * pre-processing transformation corresponds - */ - private Tensor tensor; - /** - * Package where the BioImage.io transformations are. - */ - private static final String BIOIMAGEIO_TRANSFORMATIONS_PACKAGE = "io.bioimage.modelrunner.transformations."; - /** - * Name of the standard method used by the BioImage.io transformations to call the - * pre-processing routine - */ - private static String bioImageIoExecutionMethodName = "apply"; - - /** - * Create pre-processing object that contains the path to a pre-processing protocol file - * @param javaMethod - * file that contains the Icy protocols to run pre-processing - * @param args - * args of the pre-processing specified in the rdf.yaml - * @throws ClassNotFoundException if the pre-processing transformation is not found in the classpath - */ - private JavaProcessing(String javaMethod, Map args) throws ClassNotFoundException { - this.rdfSpec = javaMethod; - this.args = args; - checkMethodExists(); - } - - /** - * Create a Java pre-processing object - * @param methodName - * name of the Java method for pre-processing - * @param args - * arguments of the Java method - * @return result of runnning Java pre-processing on the tensor - * @throws ClassNotFoundException if the pre-processing transformation is not found - */ - public static JavaProcessing definePreprocessing(String methodName, Map args) throws ClassNotFoundException { - return new JavaProcessing(methodName, args); - } - - /** - * Executes the Java pre-processing transformation specified - * on the rdf.yaml on the input map with the corresponding tensor name - * @param tensorSpec - * specs of the tensor where pre-processing is going to be executed - * @param inputMap - * map containing the inputs of the model - * @return a Map with the results of pre-processing the input tensor containing - * the inputs provided in the input map too. - * @throws IllegalArgumentException if the tensor that the pre-processing refers to is not found - */ - public Tensor execute(TensorSpec tensorSpec, Tensor input) - throws IllegalArgumentException { - this.tensorSpec = tensorSpec; - this.tensorName = tensorSpec.getName(); - this.tensor = input;; - LinkedHashMap resultsMap = executeJavaTransformation(); - return (Tensor) resultsMap.get(tensor.getName()); - } - - /** - * Fill the args map with variables provided by the input map. - * This is done to allow several pre- and post-processing that can be - * executed one after another - * @param inputsMap - * the provided map with different inputs - */ - private void fillArgs(Map inputsMap) { - // TODO decide whether to use a key word when one of the inputs to pre - // processing has to be given by the previous pre-processing or - // the arg should just be null - for (String kk : this.args.keySet()) { - if (this.args.get(kk) == null && inputsMap.get(kk) != null) { - this.args.put(kk, inputsMap.get(kk)); - } - } - } - - /** - * Method that adds the tensor to the input dictionary as a NDArray. - * NDArrays are the objects used by Java pre-processings so they can - * be shared among different Java softwares - * @param inputMap - * map of input tensors for the model - * @throws IllegalArgumentException if the tensor that the pre-processing refers to is not found - */ - private < T extends RealType< T > & NativeType< T > > void addTensorToInputs(Map inputMap) throws IllegalArgumentException { - Object inputTensor = inputMap.get(this.tensorName); - if (inputTensor == null) { - throw new IllegalArgumentException("There should be an input tensor called '" + - tensorName + "', but no object referring to it has been found."); - } - - if (inputTensor instanceof RandomAccessibleInterval) { - this.tensor = Tensor.build(tensorSpec.getName(), tensorSpec.getAxesOrder(), (RandomAccessibleInterval) inputTensor); - } else if (inputTensor instanceof Tensor) { - this.tensor = ((Tensor) inputTensor); - } - } - - /** - * Method used to convert Strings in using snake case (snake_case) into camel - * case with the first letter as upper case (CamelCase) - * @param str - * the String to be converted - * @return String converted into camel case with first upper - */ - public static String snakeCaseToCamelCaseFirstCap(String str) { - while(str.contains("_")) { - str = str.replaceFirst("_[a-z]", String.valueOf(Character.toUpperCase(str.charAt(str.indexOf("_") + 1)))); - } - str = str.substring(0, 1).toUpperCase() + str.substring(1); - return str; - } - - /** - * Method that checks if the pre-processing transformations specified in the - * rdf,yaml exist in the classpath - * @throws ClassNotFoundException if the transformations are not found in the classpath - */ - private void checkMethodExists() throws ClassNotFoundException { - if (rdfSpec.contains(".") && !rdfSpec.contains("::")) { - javaClassName = rdfSpec; - javaMethodName = bioImageIoExecutionMethodName; - findClassInClassPath(); - } else if (rdfSpec.contains(".") && rdfSpec.contains("::")) { - javaClassName = rdfSpec.substring(0, rdfSpec.indexOf("::")); - javaMethodName = rdfSpec.substring(rdfSpec.indexOf("::") + 2); - findClassInClassPath(); - } else { - findMethodInBioImageIo(); - } - } - - /** - * Tries to find a given class in the classpath - * @throws ClassNotFoundException if the class does not exist in the classpath - */ - private void findClassInClassPath() throws ClassNotFoundException { - Class.forName(this.javaClassName, false, JavaProcessing.class.getClassLoader()); - } - - /** - * Find of the transformation exists in the BioImage.io Java Core - * @throws ClassNotFoundException if the BioImage.io transformation does not exist - */ - private void findMethodInBioImageIo() throws ClassNotFoundException { - this.javaMethodName = snakeCaseToCamelCaseFirstCap(this.rdfSpec) + "Transformation"; - this.javaClassName = BIOIMAGEIO_TRANSFORMATIONS_PACKAGE + this.javaMethodName; - findClassInClassPath(); - this.javaMethodName = bioImageIoExecutionMethodName; - } - - /** - * Execute the transformation form the BioImage.io defined in the rdf.yaml - * @throws IllegalArgumentException if the transformation is not correctly defined, - * does not exist or is missing any argument - */ - private LinkedHashMap executeJavaTransformation() throws IllegalArgumentException { - try { - return runJavaTransformationWithArgs(); - - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException("Processing method '" + this.rdfSpec +"' not found" - + " in the BioImage.io Java Core Transformations or in the Java Classpath: " - + "https://github.com/bioimage-io/model-runner-java/tree/nd4j/src/main/java/org/bioimageanalysis/icy/deeplearning/transformations" - + ". " + System.lineSeparator() + e.getCause()); - } catch (InstantiationException e) { - e.printStackTrace(); - throw new IllegalArgumentException("Processing method '" + this.rdfSpec +"' failed" - + " due to an error instantiating the class that defines the transformation (" - + this.javaClassName + "). Go to the following link to see valid transformations:" - + "https://github.com/bioimage-io/core-bioimage-io-java/tree/master/src/main/java/io/bioimage/specification/transformation" - + ". " + System.lineSeparator() + e.getCause()); - } catch (IllegalAccessException e) { - e.printStackTrace(); - throw new IllegalArgumentException("Processing method '" + this.rdfSpec +"' failed" - + " throwing an IllegalAccessException." - + " Go to the following link to see valid transformations:" - + "https://github.com/bioimage-io/core-bioimage-io-java/tree/master/src/main/java/io/bioimage/specification/transformation" - + ". " + System.lineSeparator() + e.getCause()); - } catch (InvocationTargetException e) { - e.printStackTrace(); - throw new IllegalArgumentException("Processing method '" + this.rdfSpec +"' failed" - + " throwing an InvocationTargetException." - + " Go to the following link to see valid transformations:" - + "https://github.com/bioimage-io/core-bioimage-io-java/tree/master/src/main/java/io/bioimage/specification/transformation" - + ". " + System.lineSeparator() + System.lineSeparator() + e.getCause()); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - throw new IllegalArgumentException("Processing method '" + this.rdfSpec +"' failed" - + " because the method needed to call the transformation (" + this.javaMethodName - + ") was not found in the transformation class (" - + this.javaClassName + "). Go to the following link to see valid transformations:" - + "https://github.com/bioimage-io/core-bioimage-io-java/tree/master/src/main/java/io/bioimage/specification/transformation" - + ". " + System.lineSeparator() + e.getCause()); - } catch (SecurityException e) { - e.printStackTrace(); - throw new IllegalArgumentException("Processing method '" + this.rdfSpec +"' failed" - + " throwing an SecurityException." - + " Go to the following link to see valid transformations:" - + "https://github.com/bioimage-io/core-bioimage-io-java/tree/master/src/main/java/io/bioimage/specification/transformation" - + ". " + System.lineSeparator() + e.getCause()); - } - } - - /** - * Run the transformation from the Java transformation class - * @throws IllegalAccessException if the method or class cannot be accessed with reflection - * @throws InstantiationException if there is an error instantiating the transformation class - * @throws InvocationTargetException if there is any error invoking the methods - * @throws IllegalArgumentException if any of the arguments provided with reflection is illegal - * @throws SecurityException if there is any security breach - * @throws NoSuchMethodException if the method tried to run does not exist - * @throws ClassNotFoundException if the class referenced for the transformation does not exist - */ - private LinkedHashMap runJavaTransformationWithArgs() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException { - this.transformationClass = getClass().getClassLoader().loadClass(this.javaClassName); - Method[] publicMethods = this.transformationClass.getMethods(); - Method transformationMethod = null; - for (Method mm : publicMethods) { - if (mm.getName().equals(this.javaMethodName)) { - transformationMethod = mm; - break; - } - } - if (transformationMethod == null) - throw new IllegalArgumentException("The pre-processing transformation class does not contain" - + "the method '" + this.javaMethodName + "' needed to call the transformation."); - // Check that the arguments specified in the rdf.yaml are of the corect type - return executeMethodWithArgs(transformationMethod); - } - - /** - * - * @param mm - * @return - * @throws InstantiationException if there is any error instantiating the class - * @throws if it is illegal to instantiate the class or to call the method - * @throws IllegalArgumentException if any of the arguments for the method is wrong - * @throws InvocationTargetException if the target of the method is incorrectly captured - * @throws SecurityException if there is any security violation - * @throws NoSuchMethodException if the constructor with the needed argument does not exist - */ - private > LinkedHashMap executeMethodWithArgs(Method mm) throws InstantiationException, - IllegalAccessException, - IllegalArgumentException, - InvocationTargetException, NoSuchMethodException, SecurityException { - - - LinkedHashMap resultsMap = new LinkedHashMap(); - Object instance = createInstanceWitArgs(); - - if (mm.getReturnType().equals(Void.TYPE)) { - mm.invoke(instance, tensor); - resultsMap.put(tensorName, tensor); - } else { - Object returnObject = mm.invoke(instance, tensor); - // Depending on what the output is, do one thing or another - if ((returnObject instanceof HashMap) || (returnObject instanceof HashMap)) { - // If the output is a HashMap, assume the pre-processing already provides - // the inputs map of the model - resultsMap = (LinkedHashMap) returnObject; - } else if (returnObject instanceof RandomAccessibleInterval) { - resultsMap.put(tensorName, (RandomAccessibleInterval) returnObject); - } else if (returnObject instanceof Tensor) { - resultsMap.put(tensorName, (Tensor) returnObject); - } else { - throw new IllegalArgumentException("The processing transformation '" - + rdfSpec + "' corresponding to tensor '" + tensorName - + "' outputs an object whose Type is not supported as" - + " an output for transformations in DeepIcy. The supported " - + " Types are Icy Sequences, Icy Tensors, NDArrays and Maps or" - + " HashMaps."); - } - } - return resultsMap; - } - - /** - * - * @return - * @throws IllegalArgumentException - * @throws IllegalAccessException - * @throws InvocationTargetException - * @throws InstantiationException - * @throws NoSuchMethodException - * @throws SecurityException - */ - public Object createInstanceWitArgs() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException, SecurityException { - // The instance of the pre-processing transformation should be initialized - // with the corresponding input tensor - Object transformationObject = transformationClass.getConstructor().newInstance(); - for (String arg : this.args.keySet()) { - setArg(transformationObject, arg); - } - return transformationObject; - } - - /** - * Set the argument in the processing trasnformation instance - * @param instance - * instance of the processing trasnformation - * @param argName - * name of the argument - * @throws IllegalArgumentException if no method is found for the given argument - * @throws InvocationTargetExceptionif there is any error invoking the method - * @throws IllegalAccessException if it is illegal to access the method - */ - public void setArg(Object instance, String argName) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { - String mName = getArgumentSetterName(argName); - Method mm = checkArgType(argName, mName); - mm.invoke(instance, args.get(argName)); - } - - /** - * Get the setter that the Java transformation class uses to set the argument of the - * pre-processing. The setter has to be named as the argument but in CamelCase with the - * first letter in upper case and preceded by set. For example: min_distance -> setMinDistance - * @param argName - * the name of the argument - * @return the method name - * @throws IllegalArgumentException if no method is found for the given argument - */ - public String getArgumentSetterName(String argName) throws IllegalArgumentException { - String mName = "set" + snakeCaseToCamelCaseFirstCap(argName); - // Check that the method exists - Method[] methods = transformationClass.getMethods(); - for (Method mm : methods) { - if (mm.getName().equals(mName)) - return mName; - } - throw new IllegalArgumentException("Setter for argument '" + argName + "' of the processing " - + "transformation '" + rdfSpec + "' of tensor '" + tensorName - + "' not found in the Java transformation class '" + this.javaClassName + "'. " - + "A method called '" + mName + "' should be present."); - } - - /** - * Method that checks that the type of the arguments provided in the rdf.yaml is correct. - * It also returns the setter method to set the argument - * - * @param mm - * the method that executes the pre-processing transformation - * @return the method used to provide the argument to the instance - * @throws IllegalArgumentException if any of the arguments' type is not correct - */ - private Method checkArgType(String argName, String mName) throws IllegalArgumentException { - Object arg = this.args.get(argName); - Method[] methods = this.transformationClass.getMethods(); - List possibleMethods = new ArrayList(); - for (Method mm : methods) { - if (mm.getName().equals(mName)) - possibleMethods.add(mm); - } - if (possibleMethods.size() == 0) - getArgumentSetterName(argName); - for (Method mm : possibleMethods) { - Parameter[] pps = mm.getParameters(); - if (pps.length != 1) { - continue; - } - if (pps[0].getType() == Object.class) - return mm; - } - throw new IllegalArgumentException("Setter '" + mName + "' should have only one input parameter with type Object.class."); - } -} diff --git a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/Tags.java b/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/Tags.java deleted file mode 100644 index 41b6f3d5..00000000 --- a/scripts/check_compatibility_java_software/src/main/java/io/bioimage/modelrunner/ci/Tags.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.bioimage.modelrunner.ci; - -public class Tags { - - protected static final String DEEPIMAGEJ = "deepimagej"; - - protected static final String ICY = "icy"; - -} From 9643a8c1a0334ce70a96cbca426e346a9abb0f31 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 01:07:37 +0100 Subject: [PATCH 087/150] big update of the CI to be "truer" --- .../check_compatibility_deepimagej.yaml | 135 +++++-------- scripts/check_compatibility_deepimagej.py | 186 ++++++++++++++++++ .../deepimagej_check_outputs.py | 60 ++++++ .../deepimagej_download_model.py | 110 +++++++++++ .../deepimagej_read_yaml.py | 38 ++++ .../download_engines_dij.py | 47 +++++ scripts/get_java_software_versions.py | 147 -------------- scripts/script_utils.py | 2 +- 8 files changed, 493 insertions(+), 232 deletions(-) create mode 100644 scripts/check_compatibility_deepimagej.py create mode 100644 scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py create mode 100644 scripts/deepimagej_jython_scripts/deepimagej_download_model.py create mode 100644 scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py create mode 100644 scripts/deepimagej_jython_scripts/download_engines_dij.py delete mode 100644 scripts/get_java_software_versions.py diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 814e2053..f0489f19 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -8,98 +8,65 @@ on: - main paths: - .github/workflows/check_compatibility_deepimagej.yaml - - scripts/get_java_software_versions.py - - scripts/check_compatibility_java_software/**/* + - scripts/check_compatibility_deepimagej.py workflow_dispatch: schedule: - cron: 0 1 * * * # update compatibility once a day jobs: - generate-version-dict: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.set-dict.outputs.matrix }} - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Install deps - run: pip install requests==2.28.2 beautifulsoup4==4.12.3 packaging==23.0 - - name: Generate dict - id: set-dict - run: | - matrix_output=$(python scripts/get_java_software_versions.py deepimagej) - echo "matrix=${matrix_output}" >> $GITHUB_OUTPUT - - name: Versions matrix - run: echo '${{ steps.set-dict.outputs.matrix }}' - run: - needs: generate-version-dict - runs-on: ubuntu-latest strategy: - matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} + fail-fast: false + matrix: + include: + - name: ubuntu + os: ubuntu-latest + url_file_name: fiji-linux64.zip + fiji_executable: ImageJ-linux64 + runs-on: ${{ matrix.os }} + environment: 'production' steps: - - uses: actions/checkout@v3 - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 + - uses: actions/setup-python@v5 with: - repository: bioimage-io/collection-bioimage-io - ref: gh-pages - path: bioimageio-gh-pages - - name: Setup Maven Action - uses: stCarolas/setup-maven@v4.5 - with: - java-version: 11 - maven-version: 3.9.5 - - name: Build with Maven - run: | - cd scripts/check_compatibility_java_software - mvn clean install org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade -Dshade.mainClass=io.bioimage.modelrunner.ci.ContinuousIntegration - - name: Get jar file name - id: get-jar - run: | - cd scripts/check_compatibility_java_software - jarfile=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.build.finalName}.jar') - if [ -z "$jarfile" ]; then - echo "Failed to get jar file name" - exit 1 - fi - if [ ! -f "target/$jarfile" ]; then - echo "Jar file not found: target/$jarfile" - exit 1 - fi - echo "Jar file found: target/$jarfile" - echo "jarfile=$jarfile" >> $GITHUB_OUTPUT - - name: Download engines + python-version: "3.10" + cache: "pip" # caching pip dependencies + - name: Installing Numpy for output comparison + run: pip install numpy + - run: wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions_draft.json + - run: wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json + - name: Set up Fiji + shell: bash run: | - java -cp "scripts/check_compatibility_java_software/target/${{ steps.get-jar.outputs.jarfile }}" io.bioimage.modelrunner.ci.DownloadEngines deepimagej - - name: Run models - run: | - java -cp "scripts/check_compatibility_java_software/target/${{ steps.get-jar.outputs.jarfile }}" io.bioimage.modelrunner.ci.ContinuousIntegration deepimagej ${{ matrix.key }} - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - path: test_summaries_deepimagej_${{ matrix.key }} - - sendreport: - runs-on: ubuntu-latest - needs: [generate-version-dict, run] - strategy: - matrix: ${{ fromJson(needs.generate-version-dict.outputs.matrix) }} - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.10' - - name: Get test results - uses: actions/download-artifact@v3 - with: - path: test_summaries_deepimagej_${{ matrix.key }} - - name: Install deps + mkdir -p fiji + curl -L -o fiji.zip https://downloads.imagej.net/fiji/latest/${{ matrix.url_file_name }} + unzip fiji.zip -d fiji + - name: Install deepimageJ run: | - pip install . - - name: Send deepimagej ${{ matrix.key }} tests - shell: bash -l {0} - run: python scripts/check_compatibility_java_software.py deepimagej ${{ matrix.key }} --summaries_dir "test_summaries_deepimagej_${{ matrix.key }}/artifact" + fiji/Fiji.app/${{ matrix.fiji_executable }} --update add-update-site "deepimagej" "https://sites.imagej.net/DeepImageJ/" + - name: Install engines + shell: bash + run: fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console scripts/deepimagej_jython_scripts/download_engines.py -engines_path fiji/Fiji.app/engines + - name: Run deepImageJ tests for drafts + run: python scripts/check_compatibility_deepimagej.py \ + all_versions_draft.json \ + generated-reports \ + "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" \ + fiji + - rname: Run deepImageJ tests for pusblished versions + run: python scripts/check_compatibility_deepimagej.py \ + all_versions_draft.json \ + generated-reports \ + "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" \ + fiji + - name: Upload reports + run: python scripts/upload_reports.py generated-reports + env: + S3_HOST: ${{vars.S3_HOST}} + S3_BUCKET: ${{vars.S3_BUCKET}} + S3_FOLDER: ${{vars.S3_FOLDER}} + S3_ACCESS_KEY_ID: ${{secrets.S3_ACCESS_KEY_ID}} + S3_SECRET_ACCESS_KEY: ${{secrets.S3_SECRET_ACCESS_KEY}} + RUN_URL: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} + JSON_OUTS_FNAME: "dij_ouputs_file.json" + MACRO_NAME: "dij_macro_ci.ijm" \ No newline at end of file diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py new file mode 100644 index 00000000..b31c126f --- /dev/null +++ b/scripts/check_compatibility_deepimagej.py @@ -0,0 +1,186 @@ +import argparse +from pathlib import Path +from typing import List, Dict, Any +import os +import re + +import requests +import subprocess +from functools import partial + +from loguru import logger + +from bioimageio_collection_backoffice.db_structure.compatibility import ( + CompatiblityReport, +) +from bioimageio_collection_backoffice.remote_collection import Record, RemoteCollection +from bioimageio_collection_backoffice.s3_client import Client + +from script_utils import CompatibilityReportDict, check_tool_compatibility, download_rdf + + +def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): + + yaml_file = None + try: + read_yaml = subprocess.run( + [ + headless_command + f" scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py -yaml_fpath {yaml_file}" + ], + check=True, + stdout=subprocess.PIPE, + text=True + ) + except BaseException as e: + report = CompatibilityReportDict( + status="failed", + error=f"unable to read the yaml file", + details=str(e), + links=["deepimagej/deepimagej"], + ) + return report + model_dir = None + try: + download_result = subprocess.run( + [ + headless_command + f" scripts/deepimagej_jython_scripts/download_model.py -yaml_fpath {yaml_file} -models_dir {os.path.join(fiji_path, 'models')}" + ], + check=True, + stdout=subprocess.PIPE, + text=True + ) + model_dir = download_result.stdout.strip().splitlines()[-1] + except BaseException as e: + report = CompatibilityReportDict( + status="failed", + error=f"unable to download the model", + details=str(e), + links=["deepimagej/deepimagej"], + ) + return report + macro_path = os.path.join(model_dir, str(os.getenv("MACRO_NAME"))) + try: + run = subprocess.run( + [headless_command + " -macro " + macro_path], + check=True, + stdout=subprocess.PIPE, + text=True + ) + except BaseException as e: + report = CompatibilityReportDict( + status="failed", + error=f"error running the model", + details=str(e), + links=["deepimagej/deepimagej"], + ) + return report + try: + check_outputs = subprocess.run( + [ + headless_command + f" scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py -model_dir {model_dir}" + ], + check=True, + stdout=subprocess.PIPE, + text=True + ) + except BaseException as e: + report = CompatibilityReportDict( + status="failed", + error=f"error comparing expected outputs and actual outputs", + details=str(e), + links=["deepimagej/deepimagej"], + ) + return report + report = CompatibilityReportDict( + status="passed", + error=None, + details=None, + links=["deepimagej/deepimagej"], + ) + return report + + + + + + +def check_compatibility_deepimagej_impl( + rdf_url: str, + sha256: str, + headless_command: str = "", + fiji_path: str = "fiji", +) -> CompatibilityReportDict: + """Create a `CompatibilityReport` for a resource description. + + Args: + rdf_url: URL to the rdf.yaml file + sha256: SHA-256 value of **rdf_url** content + """ + assert headless_command is not "", "please provide the fiji headless call" + + rdf = download_rdf(rdf_url, sha256) + + if rdf["type"] != "model": + report = CompatibilityReportDict( + status="not-applicable", + error=None, + details="only 'model' resources can be used in deepimagej.", + links=["deepimagej/deepimagej"], + ) + + elif len(rdf["inputs"]) > 1 or len(rdf["outputs"]) > 1: + report = CompatibilityReportDict( + status="failed", + error=f"deepimagej only supports single tensor input/output (found {len(rdf['inputs'])}/{len(rdf['outputs'])})", + details=None, + links=["deepimagej/deepimagej"], + ) + else: + report = test_model_deepimagej(rdf_url, headless_command, fiji_path) + + return report + + +def check_compatibility_deepimagej( + deepimagej_version: str, all_version_path: Path, output_folder: Path, headless_command: str, fiji_path: str, +): + partial_impl = partial( + check_compatibility_deepimagej_impl, + headless_command=headless_command, + fiji_path=fiji_path + ) + check_tool_compatibility( + "deepimagej", + deepimagej_version, + all_version_path=all_version_path, + output_folder=output_folder, + check_tool_compatibility_impl=partial_impl, + applicable_types={"model"}, + ) + +def get_dij_version(fiji_path): + plugins_path = os.path.join(fiji_path, "plugins") + pattern = re.compile(r"^deepimagej-\d+\.\d+\.\d+(-snapshot)?\.jar$") + + matching_files = [ + lower(file) + for file in os.listdir(plugins_path) + if pattern.match(lower(file)) + ] + assert len(matching_files) > 0, "No deepImageJ plugin found, review your installation" + version = pattern.search(matching_files[0]).group(1) + print(version) + return version + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + _ = parser.add_argument("all_versions", type=Path) + _ = parser.add_argument("output_folder", type=Path) + _ = parser.add_argument("fiji_path", type=Path) + _ = parser.add_argument("headless_command", type=Path) + + args = parser.parse_args() + check_compatibility_deepimagej( + get_dij_version(args.fiji_path), args.all_versions, args.output_folder, headless_command=args.headless_command, fiji_path=args.fiji_path + ) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py new file mode 100644 index 00000000..7cb27b03 --- /dev/null +++ b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py @@ -0,0 +1,60 @@ +""" +Python script that checks that the wanted objects have actually been created and correspond to the expected ones +""" + +import json +import os +import argparse + +from net.imglib2.img.display.imagej import ImageJFunctions + +from ij import IJ + + +def find_expected_output(outputs_dir, name): + for ff in os.listdir(outputs_dir): + if ff.endswith(f"_{name}.tif") or ff.endswith(f"_{name}.tiff"): + return os.path.join(outputs_dir, ff) + raise Exception(f"Expected output for {name} not found") + + +def main(model_dir): + with open(os.path.join(model_dir, os.getenv("JSON_OUTS_FNAME")), 'r') as f: + expected_outputs = json.load(f) + + for i, output in enumerate(expected_outputs): + name = output["name"] + dij_output = output["dij"] + outputs_path = output["expected"] + if not os.path.exists(dij_output): + raise Exception(f"Output {i} was not generated by deepimagej") + elif not os.path.exists(outputs_path): + raise Exception(f"Cannot find expected output {i}") + expected_output = find_expected_output(outputs_path, name) + dij_rai = ImageJFunctions.wrap(IJ.openImage(dij_output)) + expected_rai = ImageJFunctions.wrap(IJ.openImage(expected_output)) + dij_shape = dij_rai.dimensionsAsLongArray() + expected_shape = expected_rai.dimensionsAsLongArray() + assert dij_shape == expected_shape, f"Output {i} in deepiamgej has different shape {dij_shape} vs {expected_shape}" + dij_cursor = dij_rai.cursor() + expected_cursor = expected_rai.cursor() + while dij_cursor.hasNext(): + dij_cursor.fwd() + expected_cursor.fwd() + if dij_cursor.get().getRealFloat() - expected_cursor.get().getRealFloat() > 1e-5: + raise Exception(f"Values of output {i} differ") + + +if __name__ == '__main__': + # Create the argument parser + parser = argparse.ArgumentParser() + + # Add the arguments + parser.add_argument('-model_dir', type=str, required=True) + + + # Parse the arguments + args = parser.parse_args() + + model_dir = args.model_dir + main(model_dir) \ No newline at end of file diff --git a/scripts/deepimagej_jython_scripts/deepimagej_download_model.py b/scripts/deepimagej_jython_scripts/deepimagej_download_model.py new file mode 100644 index 00000000..2099b229 --- /dev/null +++ b/scripts/deepimagej_jython_scripts/deepimagej_download_model.py @@ -0,0 +1,110 @@ +# Copyright (C) 2024 deepImageJ developers +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +""" +Jython script that downloads the wanted model(s) from the Bioimage.io repo and +creates a macro to run the model(s) downloaded on the sample input with deepimageJ +""" + +from io.bioimage.modelrunner.bioimageio import BioimageioRepo +from io.bioimage.modelrunner.bioimageio.description import ModelDescriptorFactory +from io.bioimage.modelrunner.utils import Constants +from io.bioimage.modelrunner.numpy import DecodeNumpy +from io.bioimage.modelrunner.versionmanagement import AvailableEngines + + +from ij import IJ + +import os +import argparse +import json + +MACRO_STR = "run(\"DeepImageJ Run\", \"modelPath={model_path} inputPath={input_path} outputFolder={output_folder} displayOutput=null\")" +CREATED_INPUT_SAMPLE_NAME = "converted_sample_input_0.tif" +CREATED_OUTPUT_SAMPLE_NAME = "converted_sample_ouput_0.tif" + + + +def convert_npy_to_tif(folder_path, test_name, axesOrder, name=CREATED_INPUT_SAMPLE_NAME): + rai = DecodeNumpy.loadNpy(os.path.join(folder_path, test_name)) + imp = ImPlusRaiManager.convert(rai, axesOrder) + out_path = os.path.join(folder_path, name) + IJ.saveAsTiff(imp, out_path) + + + +# Create the argument parser +parser = argparse.ArgumentParser() + +# Add the arguments +parser.add_argument('-yaml_fpath', type=str, required=True, help='Path to the yaml file that contains the rdf.yaml file') +parser.add_argument('-models_dir', type=str, required=True, help='Directory where models are going to be saved') + + +# Parse the arguments +args = parser.parse_args() +rdf_fname = args.yaml_fpath +models_dir = args.models_dir + +descriptor = ModelDescriptorFactory.readFromLocalFile(rdf_fname) + + +if not os.path.exists(models_dir) or not os.path.isdir(models_dir): + os.makedirs(models_dir) + + +br = BioimageioRepo.connect() +mfp = br.downloadModelByID(descriptor.getID(), models_dir) + +macro_path = os.path.join(mfp, os.getenv("MACRO_NAME")) + +outputs_json = [] + + +with open(macro_path, "a") as file: + + sample_name = descriptor.getInputTensors().get(0).getSampleTensorName() + if sample_name is None: + test_name = descriptor.getInputTensors().get(0).getTestTensorName() + if test_name is None: + raise Exception("There are no test inputs for model: " + descriptor.getID()) + convert_npy_to_tif(mfp, test_name, descriptor.getInputTensors().get(0).getAxesOrder()) + sample_name = CREATED_INPUT_SAMPLE_NAME + if " " in mfp: + macro = MACRO_STR.format(model_path="[" + mfp + "]", input_path="[" + os.path.join(mfp, sample_name) + "]", output_folder="[" + os.path.join(mfp, "outputs") + "]") + else: + macro = MACRO_STR.format(model_path=mfp, input_path=os.path.join(mfp, sample_name), output_folder=os.path.join(mfp, "outputs")) + macro = macro.replace(os.sep, os.sep + os.sep) + file.write(macro + os.linesep) + +for n in range(descriptor.getOutputTensors().size()): + test_name = descriptor.getOutputTensors().get(n).getTestTensorName() + if test_name is None: + sample_name = descriptor.getOutputTensors().get(n).getSampleTensorName() + if sample_name is None: + raise Exception("There are no test ouputs for model: " + descriptor.getID()) + else: + convert_npy_to_tif(mfp, test_name, descriptor.getOutputTensors().get(n).getAxesOrder(), name=CREATED_OUTPUT_SAMPLE_NAME) + sample_name = CREATED_OUTPUT_SAMPLE_NAME + out_dict = {} + out_dict["name"] = descriptor.getOutputTensors().get(n).getName() + out_dict["dij"] = os.path.join(mfp, "outputs") + out_dict["expected"] = os.path.join(mfp, CREATED_OUTPUT_SAMPLE_NAME) + outputs_json.append(out_dict) + +with open(os.path.join(mfp, os.getenv("JSON_OUTS_FNAME")), 'w') as f: + json.dump(outputs_json, f) + +print(mfp) \ No newline at end of file diff --git a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py new file mode 100644 index 00000000..5271c036 --- /dev/null +++ b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py @@ -0,0 +1,38 @@ +# Copyright (C) 2024 deepImageJ developers +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +""" +Jython script that checks if a yaml file corresponds to the bioimage.io format and is supported by deepimagej +""" + +from io.bioimage.modelrunner.bioimageio.description import ModelDescriptorFactory + + + +import argparse + + +# Create the argument parser +parser = argparse.ArgumentParser() + +# Add the arguments +parser.add_argument('-yaml_fpath', type=str, required=True, help='Path to the yaml file that contains the rdf.yaml file') + + +# Parse the arguments +args = parser.parse_args() +yaml_fpath = args.yaml_fpath + +descriptor = ModelDescriptorFactory.readFromLocalFile(yaml_fpath) \ No newline at end of file diff --git a/scripts/deepimagej_jython_scripts/download_engines_dij.py b/scripts/deepimagej_jython_scripts/download_engines_dij.py new file mode 100644 index 00000000..a569c6cd --- /dev/null +++ b/scripts/deepimagej_jython_scripts/download_engines_dij.py @@ -0,0 +1,47 @@ +# Copyright (C) 2024 deepImageJ developers +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +""" +Jython script that downloads the basic engines needed to run most of the Deep Learning models +""" + +from io.bioimage.modelrunner.engine.installation import EngineInstall + +import os +import argparse + + +# Create the argument parser +parser = argparse.ArgumentParser() + +# Add the arguments +parser.add_argument('-engines_path', type=str, default="engines", required=False, + help='Path where the engines are going to be installed') + + +# Parse the arguments +args = parser.parse_args() + +engines_path = args.engines_path + + +if not os.path.exists(engines_path) or not os.path.isdir(engines_path): + os.makedirs(engines_path) + +installer = EngineInstall.createInstaller(engines_path) +installer.basicEngineInstallation() + +print(os.path.abspath(engines_path)) +print(os.listdir(os.path.abspath(engines_path))) \ No newline at end of file diff --git a/scripts/get_java_software_versions.py b/scripts/get_java_software_versions.py deleted file mode 100644 index 33746af5..00000000 --- a/scripts/get_java_software_versions.py +++ /dev/null @@ -1,147 +0,0 @@ -import argparse -import requests -from bs4 import BeautifulSoup -import re -import datetime -from typing import Dict, Any, List -from packaging.version import Version -from pathlib import Path -import os -import zipfile -import xml.etree.ElementTree as ET -import json - -DEEPIMAGEJ_UPDATE_SITE_URL = "https://sites.imagej.net/DeepImageJ/plugins/" -DEEPIMAGEJ_PATTERN = r"DeepImageJ-(\d+\.\d+\.\d+)\.jar-(\d{14})" -DIJ_POM_FILE = 'META-INF/maven/io.github.deepimagej/DeepImageJ_/pom.xml' -MINIMUM_DIJ_VERSION = Version("3.0.4") -DEEPIMAGEJ_TAG = "deepimagej" - - -ICY_POM_FILE = '' -ICY_TAG = "icy" - -TEMP_PATH = os.path.abspath("TEMP") - -JDLL_GROUP_ID = "io.bioimage" - -JDLL_ARTIFACT_ID = "dl-modelrunner" - - -def download_file(url: str, local_filename: str): - with requests.get(url, stream=True) as response: - response.raise_for_status() - with open(local_filename, 'wb') as file: - for chunk in response.iter_content(chunk_size=8192): - _ = file.write(chunk) - - -def get_version_from_pomxml(content: str) -> str: - root = ET.fromstring(content) - namespace = "{http://maven.apache.org/POM/4.0.0}" - - version = "" - for dependency in root.findall(f".//{namespace}dependency"): - group_id = dependency.find(f"{namespace}groupId") - artifact_id = dependency.find(f"{namespace}artifactId") - if group_id is not None and artifact_id is not None: - if group_id.text == JDLL_GROUP_ID and artifact_id.text == JDLL_ARTIFACT_ID: - version = dependency.find(f"{namespace}version").text - break - if version == "": - raise FileNotFoundError("JDLL version not founf in pom.xml") - - return version - - -def read_file_in_jar(jar_file_path: str, file_name: str) -> str: - with zipfile.ZipFile(jar_file_path, 'r') as jar: - if file_name in jar.namelist(): - with jar.open(file_name) as file: - content = file.read().decode('utf-8') - return content - else: - raise FileNotFoundError(f"{file_name} not found in the JAR file") - - - -def find_associated_jdll_version(link: str) -> str: - Path(TEMP_PATH).mkdir(parents=True, exist_ok=True) - fname = os.path.join(TEMP_PATH, link.split("/")[-1]) - download_file(link, fname) - if "deepimagej" in link.lower(): - return get_version_from_pomxml(read_file_in_jar(fname, DIJ_POM_FILE)) - else: - return get_version_from_pomxml(read_file_in_jar(fname, ICY_POM_FILE)) - - -def parse_links() -> List[Any]: - response = requests.get(DEEPIMAGEJ_UPDATE_SITE_URL) - soup = BeautifulSoup(response.content, 'html.parser') - links = soup.find_all('a') - return links - - - -def get_deepimagej_versions() -> Dict[str, str]: - """ - Retrieves deepImageJ versions and their associated JDLL versions. - - This method parses available links, filters for relevant deepImageJ JAR files, - and extracts their versions and timestamps. It then associates each unique deepImageJ - version with the corresponding JDLL version deom the deepImageJ pom.xml file. - - Returns: - Dict[str, str]: A dictionary where each key is a deepImageJ version and the value - is the associated JDLL version. - """ - links = parse_links() - v_dic: Dict[str, Any] = {} - v_dic_rev: Dict[str, str] = {} - for link in links: - href = link.get('href') - if '.jar' in href and 'deepimagej' in href.lower() and 'deepimagej_' not in href.lower(): - tmp_dic = get_dij_version_and_date(href) - if Version(tmp_dic["vv"]) < MINIMUM_DIJ_VERSION: - continue - if tmp_dic["vv"] not in v_dic_rev.keys(): - v_dic_rev[tmp_dic["vv"]] = tmp_dic["ts"] - v_dic[href] = tmp_dic - elif tmp_dic["ts"] > v_dic_rev[tmp_dic["vv"]]: - v_dic[href] = tmp_dic - v_dic_rev[tmp_dic["vv"]] = tmp_dic["ts"] - assoc_dict: Dict[str, str] = {} - for kk in v_dic.keys(): - jdll_v = find_associated_jdll_version(DEEPIMAGEJ_UPDATE_SITE_URL + kk) - assoc_dict[v_dic[kk]["vv"]] = jdll_v - return assoc_dict - - - -def get_dij_version_and_date(filename: str) -> Dict[str, Any]: - match = re.search(DEEPIMAGEJ_PATTERN, filename) - - version_dic: Dict[str, Any] = {} - if match: - version = match.group(1) - date = match.group(2) - version_dic["vv"] = version - version_dic["ts"] = datetime.datetime(int(date[:4]), int(date[4:6]), int(date[6:8])).timestamp() - else: - version_dic["vv"] = None - version_dic["ts"] = None - return version_dic - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - _ = parser.add_argument("software_name") - if parser.parse_args().software_name == DEEPIMAGEJ_TAG: - matrix = get_deepimagej_versions() - #print(json.dumps(matrix)) - #print(f"matrix={json.dumps({"0.0.1": "0.5.9"})}") - matrix = {"key": ["3.0.4"], "value": ["0.5.9"]} - print(json.dumps(matrix)) - elif parser.parse_args().software_name == ICY_TAG: - matrix = {"key": ["0.0.1"], "value": ["0.5.9"]} - print(json.dumps(matrix)) diff --git a/scripts/script_utils.py b/scripts/script_utils.py index 738c1c53..8ff2433b 100644 --- a/scripts/script_utils.py +++ b/scripts/script_utils.py @@ -90,7 +90,7 @@ def check_tool_compatibility( report_url = ( "/".join(rdf_url.split("/")[:-2]) - + f"/compatibility/ilastik_{tool_version}.yaml" + + f"/compatibility/{tool_name}_{tool_version}.yaml" ) r = requests.head(report_url) if r.status_code != 404: From aac17c60bbc56447e71b8a20bf11f02c286c7f1d Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 01:16:06 +0100 Subject: [PATCH 088/150] correct text format and add download --- .../check_compatibility_deepimagej.yaml | 95 +++++++++---------- scripts/check_compatibility_deepimagej.py | 15 ++- 2 files changed, 59 insertions(+), 51 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index f0489f19..f20461c6 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -1,7 +1,6 @@ +--- name: check compatibility deepimagej - concurrency: deepimagej - on: push: branches: @@ -11,8 +10,7 @@ on: - scripts/check_compatibility_deepimagej.py workflow_dispatch: schedule: - - cron: 0 1 * * * # update compatibility once a day - + - cron: 0 1 * * * jobs: run: strategy: @@ -26,47 +24,48 @@ jobs: runs-on: ${{ matrix.os }} environment: 'production' steps: - - uses: actions/checkout@v5 - - uses: actions/setup-python@v5 - with: - python-version: "3.10" - cache: "pip" # caching pip dependencies - - name: Installing Numpy for output comparison - run: pip install numpy - - run: wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions_draft.json - - run: wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json - - name: Set up Fiji - shell: bash - run: | - mkdir -p fiji - curl -L -o fiji.zip https://downloads.imagej.net/fiji/latest/${{ matrix.url_file_name }} - unzip fiji.zip -d fiji - - name: Install deepimageJ - run: | - fiji/Fiji.app/${{ matrix.fiji_executable }} --update add-update-site "deepimagej" "https://sites.imagej.net/DeepImageJ/" - - name: Install engines - shell: bash - run: fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console scripts/deepimagej_jython_scripts/download_engines.py -engines_path fiji/Fiji.app/engines - - name: Run deepImageJ tests for drafts - run: python scripts/check_compatibility_deepimagej.py \ - all_versions_draft.json \ - generated-reports \ - "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" \ - fiji - - rname: Run deepImageJ tests for pusblished versions - run: python scripts/check_compatibility_deepimagej.py \ - all_versions_draft.json \ - generated-reports \ - "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" \ - fiji - - name: Upload reports - run: python scripts/upload_reports.py generated-reports - env: - S3_HOST: ${{vars.S3_HOST}} - S3_BUCKET: ${{vars.S3_BUCKET}} - S3_FOLDER: ${{vars.S3_FOLDER}} - S3_ACCESS_KEY_ID: ${{secrets.S3_ACCESS_KEY_ID}} - S3_SECRET_ACCESS_KEY: ${{secrets.S3_SECRET_ACCESS_KEY}} - RUN_URL: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} - JSON_OUTS_FNAME: "dij_ouputs_file.json" - MACRO_NAME: "dij_macro_ci.ijm" \ No newline at end of file + - uses: actions/checkout@v5 + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + cache: pip + - name: Installing Numpy for output comparison + run: pip install numpy + - run: wget + https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions_draft.json + - run: wget + https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json + - name: Set up Fiji + shell: bash + run: > + mkdir -p fiji + curl -L -o fiji.zip https://downloads.imagej.net/fiji/latest/${{ matrix.url_file_name }} + unzip fiji.zip -d fiji + - name: Install deepimageJ + run: > + fiji/Fiji.app/${{ matrix.fiji_executable }} --update add-update-site + "deepimagej" "https://sites.imagej.net/DeepImageJ/" + - name: Install engines + shell: bash + run: fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console + scripts/deepimagej_jython_scripts/download_engines.py -engines_path + fiji/Fiji.app/engines + - name: Run deepImageJ tests for drafts + run: python scripts/check_compatibility_deepimagej.py \ all_versions_draft.json + \ generated-reports \ "fiji/Fiji.app/${{ matrix.fiji_executable }} + --headless --console" \ fiji + - rname: Run deepImageJ tests for pusblished versions + run: python scripts/check_compatibility_deepimagej.py \ all_versions_draft.json + \ generated-reports \ "fiji/Fiji.app/${{ matrix.fiji_executable }} + --headless --console" \ fiji + - name: Upload reports + run: python scripts/upload_reports.py generated-reports + env: + S3_HOST: ${{vars.S3_HOST}} + S3_BUCKET: ${{vars.S3_BUCKET}} + S3_FOLDER: ${{vars.S3_FOLDER}} + S3_ACCESS_KEY_ID: ${{secrets.S3_ACCESS_KEY_ID}} + S3_SECRET_ACCESS_KEY: ${{secrets.S3_SECRET_ACCESS_KEY}} + RUN_URL: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} + JSON_OUTS_FNAME: dij_ouputs_file.json + MACRO_NAME: dij_macro_ci.ijm diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index b31c126f..22db20b6 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -4,7 +4,7 @@ import os import re -import requests +import urllib.request import subprocess from functools import partial @@ -20,8 +20,17 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): - - yaml_file = None + yaml_file = "rdf.yaml" + try: + urllib.request.urlretrieve(rdf_url, yaml_file) + except Exception as e: + report = CompatibilityReportDict( + status="failed", + error=f"unable to download the yaml file", + details=str(e), + links=["deepimagej/deepimagej"], + ) + return report try: read_yaml = subprocess.run( [ From 8d77f1356fc587af20696acfff107b8cf8e02c91 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 01:16:54 +0100 Subject: [PATCH 089/150] correct yaml typo --- .github/workflows/check_compatibility_deepimagej.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index f20461c6..0818dd01 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -54,7 +54,7 @@ jobs: run: python scripts/check_compatibility_deepimagej.py \ all_versions_draft.json \ generated-reports \ "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" \ fiji - - rname: Run deepImageJ tests for pusblished versions + - name: Run deepImageJ tests for pusblished versions run: python scripts/check_compatibility_deepimagej.py \ all_versions_draft.json \ generated-reports \ "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" \ fiji From c8f84d78beb77a3cd5cc2075de47f923e425d85e Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 01:17:34 +0100 Subject: [PATCH 090/150] another typo --- .github/workflows/check_compatibility_deepimagej.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 0818dd01..2cc6db9f 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -24,7 +24,7 @@ jobs: runs-on: ${{ matrix.os }} environment: 'production' steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.10" From 4b05ef007afcdb463c40a6ea14cb78fa73f27c1c Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 01:21:13 +0100 Subject: [PATCH 091/150] use test file --- .github/workflows/check_compatibility_deepimagej.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 2cc6db9f..5358b15c 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -31,10 +31,8 @@ jobs: cache: pip - name: Installing Numpy for output comparison run: pip install numpy - - run: wget - https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions_draft.json - - run: wget - https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json + - run: wget https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/all_versions.json #wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions_draft.json + - run: wget https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/all_versions.json #wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json - name: Set up Fiji shell: bash run: > From 900bcd94609d26f4a23e1a5fe8b39bcdd41bda71 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 01:23:21 +0100 Subject: [PATCH 092/150] more typos --- .github/workflows/check_compatibility_deepimagej.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 5358b15c..36819e58 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -35,14 +35,13 @@ jobs: - run: wget https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/all_versions.json #wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json - name: Set up Fiji shell: bash - run: > + run: | mkdir -p fiji curl -L -o fiji.zip https://downloads.imagej.net/fiji/latest/${{ matrix.url_file_name }} unzip fiji.zip -d fiji - name: Install deepimageJ - run: > - fiji/Fiji.app/${{ matrix.fiji_executable }} --update add-update-site - "deepimagej" "https://sites.imagej.net/DeepImageJ/" + run: | + fiji/Fiji.app/${{ matrix.fiji_executable }} --update add-update-site "deepimagej" "https://sites.imagej.net/DeepImageJ/" - name: Install engines shell: bash run: fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console From 39466398b5e297e3f277f63023f109e7786e555c Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 01:25:56 +0100 Subject: [PATCH 093/150] typo on file name --- .github/workflows/check_compatibility_deepimagej.yaml | 2 +- .../{download_engines_dij.py => deepimagej_download_engines.py} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename scripts/deepimagej_jython_scripts/{download_engines_dij.py => deepimagej_download_engines.py} (100%) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 36819e58..bcee188c 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -45,7 +45,7 @@ jobs: - name: Install engines shell: bash run: fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console - scripts/deepimagej_jython_scripts/download_engines.py -engines_path + scripts/deepimagej_jython_scripts/deepimagej_download_engines.py -engines_path fiji/Fiji.app/engines - name: Run deepImageJ tests for drafts run: python scripts/check_compatibility_deepimagej.py \ all_versions_draft.json diff --git a/scripts/deepimagej_jython_scripts/download_engines_dij.py b/scripts/deepimagej_jython_scripts/deepimagej_download_engines.py similarity index 100% rename from scripts/deepimagej_jython_scripts/download_engines_dij.py rename to scripts/deepimagej_jython_scripts/deepimagej_download_engines.py From 4277519291f1d42dca91afb95240f00cca17ee15 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 01:39:28 +0100 Subject: [PATCH 094/150] install dij correctly --- .github/workflows/check_compatibility_deepimagej.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index bcee188c..0ae29701 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -41,7 +41,8 @@ jobs: unzip fiji.zip -d fiji - name: Install deepimageJ run: | - fiji/Fiji.app/${{ matrix.fiji_executable }} --update add-update-site "deepimagej" "https://sites.imagej.net/DeepImageJ/" + fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --update add-update-site "DeepImageJ" "https://sites.imagej.net/DeepImageJ/" + fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --update update - name: Install engines shell: bash run: fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console From ca11ecfeeee45e126e772b0d57729e47c24fd78a Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 01:43:14 +0100 Subject: [PATCH 095/150] remove not needed import --- scripts/check_compatibility_deepimagej.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 22db20b6..333cb75a 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -8,14 +8,6 @@ import subprocess from functools import partial -from loguru import logger - -from bioimageio_collection_backoffice.db_structure.compatibility import ( - CompatiblityReport, -) -from bioimageio_collection_backoffice.remote_collection import Record, RemoteCollection -from bioimageio_collection_backoffice.s3_client import Client - from script_utils import CompatibilityReportDict, check_tool_compatibility, download_rdf @@ -125,7 +117,7 @@ def check_compatibility_deepimagej_impl( rdf_url: URL to the rdf.yaml file sha256: SHA-256 value of **rdf_url** content """ - assert headless_command is not "", "please provide the fiji headless call" + assert headless_command != "", "please provide the fiji headless call" rdf = download_rdf(rdf_url, sha256) From 411d1bc25879c129ebd05c35194c728e50878fbc Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 01:48:56 +0100 Subject: [PATCH 096/150] install backoffice --- .github/workflows/check_compatibility_deepimagej.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 0ae29701..cd773e8f 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -29,8 +29,8 @@ jobs: with: python-version: "3.10" cache: pip - - name: Installing Numpy for output comparison - run: pip install numpy + - name: Install backoffice + run: pip install . - run: wget https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/all_versions.json #wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions_draft.json - run: wget https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/all_versions.json #wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json - name: Set up Fiji From 48479d9f1f6a9862405b73463f82bc032e4ae5be Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 02:18:03 +0100 Subject: [PATCH 097/150] reorder args that were incorrectly ordererd --- .../check_compatibility_deepimagej.yaml | 16 ++++++++++------ scripts/check_compatibility_deepimagej.py | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index cd773e8f..a6dd80ad 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -49,13 +49,17 @@ jobs: scripts/deepimagej_jython_scripts/deepimagej_download_engines.py -engines_path fiji/Fiji.app/engines - name: Run deepImageJ tests for drafts - run: python scripts/check_compatibility_deepimagej.py \ all_versions_draft.json - \ generated-reports \ "fiji/Fiji.app/${{ matrix.fiji_executable }} - --headless --console" \ fiji + run: python scripts/check_compatibility_deepimagej.py \ + all_versions.json \ + generated-reports \ + "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" \ + fiji - name: Run deepImageJ tests for pusblished versions - run: python scripts/check_compatibility_deepimagej.py \ all_versions_draft.json - \ generated-reports \ "fiji/Fiji.app/${{ matrix.fiji_executable }} - --headless --console" \ fiji + run: python scripts/check_compatibility_deepimagej.py \ + all_versions.json \ + generated-reports \ + "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" \ + fiji - name: Upload reports run: python scripts/upload_reports.py generated-reports env: diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 333cb75a..d79bd9fb 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -178,8 +178,8 @@ def get_dij_version(fiji_path): parser = argparse.ArgumentParser() _ = parser.add_argument("all_versions", type=Path) _ = parser.add_argument("output_folder", type=Path) - _ = parser.add_argument("fiji_path", type=Path) _ = parser.add_argument("headless_command", type=Path) + _ = parser.add_argument("fiji_path", type=Path) args = parser.parse_args() check_compatibility_deepimagej( From 24f93aab760f103fc7eb24caba1030df9a3f6172 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 02:23:19 +0100 Subject: [PATCH 098/150] correct path to fiji app --- .github/workflows/check_compatibility_deepimagej.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index a6dd80ad..e7da8838 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -53,13 +53,13 @@ jobs: all_versions.json \ generated-reports \ "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" \ - fiji + fiji/Fiji.app - name: Run deepImageJ tests for pusblished versions run: python scripts/check_compatibility_deepimagej.py \ all_versions.json \ generated-reports \ "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" \ - fiji + fiji/Fiji.app - name: Upload reports run: python scripts/upload_reports.py generated-reports env: From e26095e9e5b293c7a1aab22ad0568c437d3ccce9 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 02:45:54 +0100 Subject: [PATCH 099/150] add some prints for debugging --- scripts/check_compatibility_deepimagej.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index d79bd9fb..e997427b 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -160,6 +160,8 @@ def check_compatibility_deepimagej( ) def get_dij_version(fiji_path): + print(os.listdir()) + print(os.getcwd()) plugins_path = os.path.join(fiji_path, "plugins") pattern = re.compile(r"^deepimagej-\d+\.\d+\.\d+(-snapshot)?\.jar$") From df95c9805bcb799a07c8952eead3994f75acbe08 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 02:51:54 +0100 Subject: [PATCH 100/150] more debugging prints --- scripts/check_compatibility_deepimagej.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index e997427b..e0b825ed 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -160,8 +160,9 @@ def check_compatibility_deepimagej( ) def get_dij_version(fiji_path): - print(os.listdir()) - print(os.getcwd()) + print(os.listdir("fiji")) + print(os.listdir("fiji/Fiji.App")) + print(os.listdir("fiji/Fiji.app")) plugins_path = os.path.join(fiji_path, "plugins") pattern = re.compile(r"^deepimagej-\d+\.\d+\.\d+(-snapshot)?\.jar$") From 319f2a492ebbfc02f505b4c5e6a846842c0d35a7 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 03:04:16 +0100 Subject: [PATCH 101/150] keep printing --- scripts/check_compatibility_deepimagej.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index e0b825ed..5de2e46c 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -160,8 +160,6 @@ def check_compatibility_deepimagej( ) def get_dij_version(fiji_path): - print(os.listdir("fiji")) - print(os.listdir("fiji/Fiji.App")) print(os.listdir("fiji/Fiji.app")) plugins_path = os.path.join(fiji_path, "plugins") pattern = re.compile(r"^deepimagej-\d+\.\d+\.\d+(-snapshot)?\.jar$") From 7b49eb9c686f54d033d79f01283fdc7e82b3bde6 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 03:10:14 +0100 Subject: [PATCH 102/150] keep printint --- scripts/check_compatibility_deepimagej.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 5de2e46c..4904ae9f 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -160,14 +160,15 @@ def check_compatibility_deepimagej( ) def get_dij_version(fiji_path): - print(os.listdir("fiji/Fiji.app")) + print(os.listdir("fiji/Fiji.app/plugins")) plugins_path = os.path.join(fiji_path, "plugins") + print(os.listdir(plugins_path)) pattern = re.compile(r"^deepimagej-\d+\.\d+\.\d+(-snapshot)?\.jar$") matching_files = [ - lower(file) + file.lower() for file in os.listdir(plugins_path) - if pattern.match(lower(file)) + if pattern.match(file.lower()) ] assert len(matching_files) > 0, "No deepImageJ plugin found, review your installation" version = pattern.search(matching_files[0]).group(1) From 1fbe8dd8df98999343ae84d4c17321955751a137 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 03:14:17 +0100 Subject: [PATCH 103/150] remove space that was causing issues --- .github/workflows/check_compatibility_deepimagej.yaml | 6 ++---- scripts/check_compatibility_deepimagej.py | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index e7da8838..fc9ef648 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -52,14 +52,12 @@ jobs: run: python scripts/check_compatibility_deepimagej.py \ all_versions.json \ generated-reports \ - "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" \ - fiji/Fiji.app + "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" fiji/Fiji.app - name: Run deepImageJ tests for pusblished versions run: python scripts/check_compatibility_deepimagej.py \ all_versions.json \ generated-reports \ - "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" \ - fiji/Fiji.app + "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" fiji/Fiji.app - name: Upload reports run: python scripts/upload_reports.py generated-reports env: diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 4904ae9f..a7bc7232 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -160,9 +160,7 @@ def check_compatibility_deepimagej( ) def get_dij_version(fiji_path): - print(os.listdir("fiji/Fiji.app/plugins")) plugins_path = os.path.join(fiji_path, "plugins") - print(os.listdir(plugins_path)) pattern = re.compile(r"^deepimagej-\d+\.\d+\.\d+(-snapshot)?\.jar$") matching_files = [ From 58d0e599d65fa8c19e6623828a9721805212e75c Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 03:17:37 +0100 Subject: [PATCH 104/150] remove all spaces --- .github/workflows/check_compatibility_deepimagej.yaml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index fc9ef648..5a714ccc 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -49,15 +49,9 @@ jobs: scripts/deepimagej_jython_scripts/deepimagej_download_engines.py -engines_path fiji/Fiji.app/engines - name: Run deepImageJ tests for drafts - run: python scripts/check_compatibility_deepimagej.py \ - all_versions.json \ - generated-reports \ - "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" fiji/Fiji.app + run: python scripts/check_compatibility_deepimagej.py all_versions.json generated-reports "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" fiji/Fiji.app - name: Run deepImageJ tests for pusblished versions - run: python scripts/check_compatibility_deepimagej.py \ - all_versions.json \ - generated-reports \ - "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" fiji/Fiji.app + run: python scripts/check_compatibility_deepimagej.py all_versions.json generated-reports "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" fiji/Fiji.app - name: Upload reports run: python scripts/upload_reports.py generated-reports env: From 0dacf6a153341073e2183bac7f955840783e255e Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 03:22:44 +0100 Subject: [PATCH 105/150] save reports for debugging --- .github/workflows/check_compatibility_deepimagej.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 5a714ccc..fd106d56 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -31,7 +31,7 @@ jobs: cache: pip - name: Install backoffice run: pip install . - - run: wget https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/all_versions.json #wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions_draft.json + - run: wget https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/all_versions_draft.json #wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions_draft.json - run: wget https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/all_versions.json #wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json - name: Set up Fiji shell: bash @@ -49,9 +49,14 @@ jobs: scripts/deepimagej_jython_scripts/deepimagej_download_engines.py -engines_path fiji/Fiji.app/engines - name: Run deepImageJ tests for drafts - run: python scripts/check_compatibility_deepimagej.py all_versions.json generated-reports "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" fiji/Fiji.app + run: python scripts/check_compatibility_deepimagej.py all_versions_draft.json generated-reports "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" fiji/Fiji.app - name: Run deepImageJ tests for pusblished versions run: python scripts/check_compatibility_deepimagej.py all_versions.json generated-reports "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" fiji/Fiji.app + - name: Save reports for debugging purposes + uses: actions/upload-artifact@v4 + with: + name: generated-reports-dij + path: generated-reports - name: Upload reports run: python scripts/upload_reports.py generated-reports env: From c9ddb4fb0429c82f81918cab7256f76f6dbc0dcd Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 11:41:25 +0100 Subject: [PATCH 106/150] add prints to debug --- scripts/check_compatibility_deepimagej.py | 2 ++ scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py | 1 + 2 files changed, 3 insertions(+) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index a7bc7232..1c7d7c71 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -23,6 +23,7 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): links=["deepimagej/deepimagej"], ) return report + print(os.listdir()) try: read_yaml = subprocess.run( [ @@ -168,6 +169,7 @@ def get_dij_version(fiji_path): for file in os.listdir(plugins_path) if pattern.match(file.lower()) ] + print(matching_files) assert len(matching_files) > 0, "No deepImageJ plugin found, review your installation" version = pattern.search(matching_files[0]).group(1) print(version) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py index 5271c036..e6dba30e 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py @@ -30,6 +30,7 @@ # Add the arguments parser.add_argument('-yaml_fpath', type=str, required=True, help='Path to the yaml file that contains the rdf.yaml file') +print(yaml_fpath) # Parse the arguments args = parser.parse_args() From 9ccd83bd88e6c5f5d4a92dadf6f9325203cb8a72 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 11:53:18 +0100 Subject: [PATCH 107/150] retrieve the whole stack trace --- scripts/check_compatibility_deepimagej.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 1c7d7c71..5fe754fb 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -7,6 +7,7 @@ import urllib.request import subprocess from functools import partial +import traceback from script_utils import CompatibilityReportDict, check_tool_compatibility, download_rdf @@ -19,11 +20,13 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"unable to download the yaml file", - details=str(e), + details=traceback.format_exc(), links=["deepimagej/deepimagej"], ) return report - print(os.listdir()) + print(type(headless_command)) + print(type(yaml_file)) + print(headless_command + f" scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py -yaml_fpath {yaml_file}" ) try: read_yaml = subprocess.run( [ @@ -37,7 +40,7 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"unable to read the yaml file", - details=str(e), + details=traceback.format_exc(), links=["deepimagej/deepimagej"], ) return report @@ -56,7 +59,7 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"unable to download the model", - details=str(e), + details=traceback.format_exc(), links=["deepimagej/deepimagej"], ) return report @@ -72,7 +75,7 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"error running the model", - details=str(e), + details=traceback.format_exc(), links=["deepimagej/deepimagej"], ) return report @@ -89,7 +92,7 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"error comparing expected outputs and actual outputs", - details=str(e), + details=traceback.format_exc(), links=["deepimagej/deepimagej"], ) return report @@ -162,7 +165,7 @@ def check_compatibility_deepimagej( def get_dij_version(fiji_path): plugins_path = os.path.join(fiji_path, "plugins") - pattern = re.compile(r"^deepimagej-\d+\.\d+\.\d+(-snapshot)?\.jar$") + pattern = re.compile(r"^deepimagej-(\d+\.\d+\.\d+(?:-snapshot)?)\.jar$") matching_files = [ file.lower() From ca82f32466f1d2e0386b717711f4c1609ab78825 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 12:02:04 +0100 Subject: [PATCH 108/150] print weird error --- scripts/check_compatibility_deepimagej.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 5fe754fb..d2f0f813 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -25,8 +25,10 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): ) return report print(type(headless_command)) + print((headless_command)) print(type(yaml_file)) - print(headless_command + f" scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py -yaml_fpath {yaml_file}" ) + print((yaml_file)) + #print(headless_command + f" scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py -yaml_fpath {yaml_file}" ) try: read_yaml = subprocess.run( [ From 49cff31add7d05fddaad2741cc095a1bf1ac4ea0 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 12:13:49 +0100 Subject: [PATCH 109/150] change arg to fiji_executable and correct subprocess definintions --- .../check_compatibility_deepimagej.yaml | 4 +- scripts/check_compatibility_deepimagej.py | 56 ++++++++++++------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index fd106d56..2f4b9662 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -49,9 +49,9 @@ jobs: scripts/deepimagej_jython_scripts/deepimagej_download_engines.py -engines_path fiji/Fiji.app/engines - name: Run deepImageJ tests for drafts - run: python scripts/check_compatibility_deepimagej.py all_versions_draft.json generated-reports "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" fiji/Fiji.app + run: python scripts/check_compatibility_deepimagej.py all_versions_draft.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app - name: Run deepImageJ tests for pusblished versions - run: python scripts/check_compatibility_deepimagej.py all_versions.json generated-reports "fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console" fiji/Fiji.app + run: python scripts/check_compatibility_deepimagej.py all_versions.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app - name: Save reports for debugging purposes uses: actions/upload-artifact@v4 with: diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index d2f0f813..deba2e1f 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -12,7 +12,7 @@ from script_utils import CompatibilityReportDict, check_tool_compatibility, download_rdf -def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): +def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): yaml_file = "rdf.yaml" try: urllib.request.urlretrieve(rdf_url, yaml_file) @@ -24,15 +24,15 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): links=["deepimagej/deepimagej"], ) return report - print(type(headless_command)) - print((headless_command)) - print(type(yaml_file)) - print((yaml_file)) - #print(headless_command + f" scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py -yaml_fpath {yaml_file}" ) try: read_yaml = subprocess.run( [ - headless_command + f" scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py -yaml_fpath {yaml_file}" + fiji_executable, + "--headless", + "--console", + "scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py", + "-yaml_fpath", + yaml_file ], check=True, stdout=subprocess.PIPE, @@ -50,7 +50,14 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): try: download_result = subprocess.run( [ - headless_command + f" scripts/deepimagej_jython_scripts/download_model.py -yaml_fpath {yaml_file} -models_dir {os.path.join(fiji_path, 'models')}" + fiji_executable, + "--headless", + "--console", + "scripts/deepimagej_jython_scripts/download_model.py", + "-yaml_fpath", + yaml_file, + "-models_dir", + os.path.join(fiji_path, 'models') ], check=True, stdout=subprocess.PIPE, @@ -68,7 +75,13 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): macro_path = os.path.join(model_dir, str(os.getenv("MACRO_NAME"))) try: run = subprocess.run( - [headless_command + " -macro " + macro_path], + [ + fiji_executable, + "--headless", + "--console", + "-macro", + macro_path, + ], check=True, stdout=subprocess.PIPE, text=True @@ -84,7 +97,12 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): try: check_outputs = subprocess.run( [ - headless_command + f" scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py -model_dir {model_dir}" + fiji_executable, + "--headless", + "--console", + "scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py", + "-model_dir", + model_dir, ], check=True, stdout=subprocess.PIPE, @@ -114,7 +132,7 @@ def test_model_deepimagej(rdf_url: str, headless_command: str, fiji_path: str): def check_compatibility_deepimagej_impl( rdf_url: str, sha256: str, - headless_command: str = "", + fiji_executable: str = "", fiji_path: str = "fiji", ) -> CompatibilityReportDict: """Create a `CompatibilityReport` for a resource description. @@ -123,7 +141,7 @@ def check_compatibility_deepimagej_impl( rdf_url: URL to the rdf.yaml file sha256: SHA-256 value of **rdf_url** content """ - assert headless_command != "", "please provide the fiji headless call" + assert fiji_executable != "", "please provide the fiji executable path" rdf = download_rdf(rdf_url, sha256) @@ -143,17 +161,17 @@ def check_compatibility_deepimagej_impl( links=["deepimagej/deepimagej"], ) else: - report = test_model_deepimagej(rdf_url, headless_command, fiji_path) + report = test_model_deepimagej(rdf_url, fiji_executable, fiji_path) return report def check_compatibility_deepimagej( - deepimagej_version: str, all_version_path: Path, output_folder: Path, headless_command: str, fiji_path: str, + deepimagej_version: str, all_version_path: Path, output_folder: Path, fiji_executable: str, fiji_path: str, ): partial_impl = partial( check_compatibility_deepimagej_impl, - headless_command=headless_command, + fiji_executable=fiji_executable, fiji_path=fiji_path ) check_tool_compatibility( @@ -174,10 +192,8 @@ def get_dij_version(fiji_path): for file in os.listdir(plugins_path) if pattern.match(file.lower()) ] - print(matching_files) assert len(matching_files) > 0, "No deepImageJ plugin found, review your installation" version = pattern.search(matching_files[0]).group(1) - print(version) return version @@ -185,10 +201,10 @@ def get_dij_version(fiji_path): parser = argparse.ArgumentParser() _ = parser.add_argument("all_versions", type=Path) _ = parser.add_argument("output_folder", type=Path) - _ = parser.add_argument("headless_command", type=Path) - _ = parser.add_argument("fiji_path", type=Path) + _ = parser.add_argument("fiji_executable", type=str) + _ = parser.add_argument("fiji_path", type=str) args = parser.parse_args() check_compatibility_deepimagej( - get_dij_version(args.fiji_path), args.all_versions, args.output_folder, headless_command=args.headless_command, fiji_path=args.fiji_path + get_dij_version(args.fiji_path), args.all_versions, args.output_folder, fiji_executable=args.fiji_executable, fiji_path=args.fiji_path ) From 3f30eb4b20740f287677b153f3cbc7cd271a1041 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 12:17:01 +0100 Subject: [PATCH 110/150] correct error --- scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py index e6dba30e..5271c036 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py @@ -30,7 +30,6 @@ # Add the arguments parser.add_argument('-yaml_fpath', type=str, required=True, help='Path to the yaml file that contains the rdf.yaml file') -print(yaml_fpath) # Parse the arguments args = parser.parse_args() From f3d7e47e7590f65fa605a452004650d70a0e5262 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 12:18:26 +0100 Subject: [PATCH 111/150] listen to every change in jython scripts --- .github/workflows/check_compatibility_deepimagej.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 2f4b9662..ce46ad6d 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -8,6 +8,7 @@ on: paths: - .github/workflows/check_compatibility_deepimagej.yaml - scripts/check_compatibility_deepimagej.py + - scripts/deepimagej_jython_scripts/** workflow_dispatch: schedule: - cron: 0 1 * * * From 11500600a620126fa5963777d841ff11b8e00c68 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 12:25:05 +0100 Subject: [PATCH 112/150] check what is this --- scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py index 5271c036..d992d1ea 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py @@ -35,4 +35,5 @@ args = parser.parse_args() yaml_fpath = args.yaml_fpath +print(yaml_fpath) descriptor = ModelDescriptorFactory.readFromLocalFile(yaml_fpath) \ No newline at end of file From ec9cd083d4160d312b0d3dab8974e8803b5aede7 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 12:32:08 +0100 Subject: [PATCH 113/150] debug mode --- scripts/check_compatibility_deepimagej.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index deba2e1f..0ed62689 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -30,6 +30,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): fiji_executable, "--headless", "--console", + "--debug", "scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py", "-yaml_fpath", yaml_file From 093ef0f211294ffea54582871a697854957bdf94 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 12:39:32 +0100 Subject: [PATCH 114/150] try if this prints something --- scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py index d992d1ea..2e2d9355 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py @@ -36,4 +36,4 @@ yaml_fpath = args.yaml_fpath print(yaml_fpath) -descriptor = ModelDescriptorFactory.readFromLocalFile(yaml_fpath) \ No newline at end of file +#descriptor = ModelDescriptorFactory.readFromLocalFile(yaml_fpath) \ No newline at end of file From 09544b86d5f8dbdd643fb7518b0a7a2f90c76831 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 12:41:32 +0100 Subject: [PATCH 115/150] cehck anything is printed --- scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py index 2e2d9355..59c6722f 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py @@ -36,4 +36,5 @@ yaml_fpath = args.yaml_fpath print(yaml_fpath) +print("AA") #descriptor = ModelDescriptorFactory.readFromLocalFile(yaml_fpath) \ No newline at end of file From 0f6a8d8af66fd3077a0fad185264abf0498cf79e Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 12:51:52 +0100 Subject: [PATCH 116/150] capture the output of the subprocess --- scripts/check_compatibility_deepimagej.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 0ed62689..121775b0 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -30,7 +30,6 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): fiji_executable, "--headless", "--console", - "--debug", "scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py", "-yaml_fpath", yaml_file @@ -39,6 +38,8 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): stdout=subprocess.PIPE, text=True ) + printed_output = read_yaml.stdout + print("Subprocess Output:\n", printed_output) except BaseException as e: report = CompatibilityReportDict( status="failed", @@ -54,7 +55,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): fiji_executable, "--headless", "--console", - "scripts/deepimagej_jython_scripts/download_model.py", + "scripts/deepimagej_jython_scripts/deepimagej_download_model.py", "-yaml_fpath", yaml_file, "-models_dir", From 67abf4fc255f0f18952b3f6a0af4c6df1b97e882 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 13:00:29 +0100 Subject: [PATCH 117/150] mm --- scripts/check_compatibility_deepimagej.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 121775b0..a823c0e9 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -38,6 +38,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): stdout=subprocess.PIPE, text=True ) + print('hereeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee') printed_output = read_yaml.stdout print("Subprocess Output:\n", printed_output) except BaseException as e: From b123b800c1f23cc0eaf21f0de07c169de25c6e1f Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 13:05:01 +0100 Subject: [PATCH 118/150] try more prints --- scripts/check_compatibility_deepimagej.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index a823c0e9..aa4bfd4e 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -24,6 +24,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): links=["deepimagej/deepimagej"], ) return report + print("HEREEEEEEEEEEEEEEEEEEEEEEEE") try: read_yaml = subprocess.run( [ @@ -42,6 +43,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): printed_output = read_yaml.stdout print("Subprocess Output:\n", printed_output) except BaseException as e: + print('hereeeeeeeeeeeeeeeeeeeeee22222222222222222222222222222222222222') report = CompatibilityReportDict( status="failed", error=f"unable to read the yaml file", From 52f62a334121e95acfb31b17e2de51da281de4db Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 13:12:23 +0100 Subject: [PATCH 119/150] more prints --- scripts/check_compatibility_deepimagej.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index aa4bfd4e..99299fd5 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -14,6 +14,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): yaml_file = "rdf.yaml" + print("LOOOOOOOOOOOOOOOOOOOOOOL") try: urllib.request.urlretrieve(rdf_url, yaml_file) except Exception as e: From e8cee982dce479a3f365471e96f3a3d94e45b565 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 13:28:52 +0100 Subject: [PATCH 120/150] more checks --- scripts/check_compatibility_deepimagej.py | 6 ------ scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py | 6 +++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 99299fd5..6ca8282a 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -14,7 +14,6 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): yaml_file = "rdf.yaml" - print("LOOOOOOOOOOOOOOOOOOOOOOL") try: urllib.request.urlretrieve(rdf_url, yaml_file) except Exception as e: @@ -25,7 +24,6 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): links=["deepimagej/deepimagej"], ) return report - print("HEREEEEEEEEEEEEEEEEEEEEEEEE") try: read_yaml = subprocess.run( [ @@ -40,11 +38,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): stdout=subprocess.PIPE, text=True ) - print('hereeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee') - printed_output = read_yaml.stdout - print("Subprocess Output:\n", printed_output) except BaseException as e: - print('hereeeeeeeeeeeeeeeeeeeeee22222222222222222222222222222222222222') report = CompatibilityReportDict( status="failed", error=f"unable to read the yaml file", diff --git a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py index 59c6722f..d8ec29ba 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py @@ -23,7 +23,8 @@ import argparse - +import sys +print("ARGV:", sys.argv) # Create the argument parser parser = argparse.ArgumentParser() @@ -35,6 +36,5 @@ args = parser.parse_args() yaml_fpath = args.yaml_fpath -print(yaml_fpath) -print("AA") +print(f"YAML_FILE: '{yaml_fpath}'") #descriptor = ModelDescriptorFactory.readFromLocalFile(yaml_fpath) \ No newline at end of file From 3772e10aec47c4cce3b192ea10a733470dccafc5 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 13:29:46 +0100 Subject: [PATCH 121/150] print subprocess output --- scripts/check_compatibility_deepimagej.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 6ca8282a..5bcfaeba 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -38,6 +38,8 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): stdout=subprocess.PIPE, text=True ) + printed_output = download_result.stdout + print("Subprocess Output:\n", printed_output) except BaseException as e: report = CompatibilityReportDict( status="failed", From 859982eddb85c977ca9abf0cde5964f907b5da4b Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 13:36:34 +0100 Subject: [PATCH 122/150] ll --- scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py index d8ec29ba..610125a7 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py @@ -36,5 +36,5 @@ args = parser.parse_args() yaml_fpath = args.yaml_fpath -print(f"YAML_FILE: '{yaml_fpath}'") +print("YAML_FILE: '" + yaml_fpath + "'") #descriptor = ModelDescriptorFactory.readFromLocalFile(yaml_fpath) \ No newline at end of file From 3f9caee53eabf265cb74d9a6760b32f5eae974e5 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 13:43:12 +0100 Subject: [PATCH 123/150] correct error --- scripts/check_compatibility_deepimagej.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 5bcfaeba..121775b0 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -38,7 +38,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): stdout=subprocess.PIPE, text=True ) - printed_output = download_result.stdout + printed_output = read_yaml.stdout print("Subprocess Output:\n", printed_output) except BaseException as e: report = CompatibilityReportDict( From fe7a7041414a9fa88fade1a5643cb7795211b8eb Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 13:50:39 +0100 Subject: [PATCH 124/150] use full path --- scripts/check_compatibility_deepimagej.py | 5 ++--- scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 121775b0..804d34ac 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -13,7 +13,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): - yaml_file = "rdf.yaml" + yaml_file = os.path.abspath("rdf.yaml") try: urllib.request.urlretrieve(rdf_url, yaml_file) except Exception as e: @@ -38,8 +38,6 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): stdout=subprocess.PIPE, text=True ) - printed_output = read_yaml.stdout - print("Subprocess Output:\n", printed_output) except BaseException as e: report = CompatibilityReportDict( status="failed", @@ -74,6 +72,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): links=["deepimagej/deepimagej"], ) return report + print(model_dir) macro_path = os.path.join(model_dir, str(os.getenv("MACRO_NAME"))) try: run = subprocess.run( diff --git a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py index 610125a7..024a72b5 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py @@ -23,8 +23,6 @@ import argparse -import sys -print("ARGV:", sys.argv) # Create the argument parser parser = argparse.ArgumentParser() @@ -36,5 +34,4 @@ args = parser.parse_args() yaml_fpath = args.yaml_fpath -print("YAML_FILE: '" + yaml_fpath + "'") -#descriptor = ModelDescriptorFactory.readFromLocalFile(yaml_fpath) \ No newline at end of file +descriptor = ModelDescriptorFactory.readFromLocalFile(yaml_fpath) \ No newline at end of file From eb5ee4f9824dfb66600934c788ba2678d63bc1ad Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 13:59:43 +0100 Subject: [PATCH 125/150] use correct method --- .../deepimagej_jython_scripts/deepimagej_download_model.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_download_model.py b/scripts/deepimagej_jython_scripts/deepimagej_download_model.py index 2099b229..179a22be 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_download_model.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_download_model.py @@ -66,7 +66,7 @@ def convert_npy_to_tif(folder_path, test_name, axesOrder, name=CREATED_INPUT_SAM br = BioimageioRepo.connect() -mfp = br.downloadModelByID(descriptor.getID(), models_dir) +mfp = br.downloadModelByID(descriptor.getModelID(), models_dir) macro_path = os.path.join(mfp, os.getenv("MACRO_NAME")) @@ -79,7 +79,7 @@ def convert_npy_to_tif(folder_path, test_name, axesOrder, name=CREATED_INPUT_SAM if sample_name is None: test_name = descriptor.getInputTensors().get(0).getTestTensorName() if test_name is None: - raise Exception("There are no test inputs for model: " + descriptor.getID()) + raise Exception("There are no test inputs for model: " + descriptor.getModelID()) convert_npy_to_tif(mfp, test_name, descriptor.getInputTensors().get(0).getAxesOrder()) sample_name = CREATED_INPUT_SAMPLE_NAME if " " in mfp: @@ -94,7 +94,7 @@ def convert_npy_to_tif(folder_path, test_name, axesOrder, name=CREATED_INPUT_SAM if test_name is None: sample_name = descriptor.getOutputTensors().get(n).getSampleTensorName() if sample_name is None: - raise Exception("There are no test ouputs for model: " + descriptor.getID()) + raise Exception("There are no test ouputs for model: " + descriptor.getModelID()) else: convert_npy_to_tif(mfp, test_name, descriptor.getOutputTensors().get(n).getAxesOrder(), name=CREATED_OUTPUT_SAMPLE_NAME) sample_name = CREATED_OUTPUT_SAMPLE_NAME From ea504a13160b06fa7eca374cc950d93f98af04dd Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 14:07:39 +0100 Subject: [PATCH 126/150] print all env vars --- scripts/check_compatibility_deepimagej.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 804d34ac..23bfdd7b 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -205,6 +205,9 @@ def get_dij_version(fiji_path): _ = parser.add_argument("fiji_executable", type=str) _ = parser.add_argument("fiji_path", type=str) + for key, value in os.environ.items(): + print(f"{key}={value}") + args = parser.parse_args() check_compatibility_deepimagej( get_dij_version(args.fiji_path), args.all_versions, args.output_folder, fiji_executable=args.fiji_executable, fiji_path=args.fiji_path From f454882d88d368e00f214c6a452c91c4670cc0b5 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 14:12:49 +0100 Subject: [PATCH 127/150] add env vars to the correct place --- .github/workflows/check_compatibility_deepimagej.yaml | 10 +++++++--- scripts/check_compatibility_deepimagej.py | 3 --- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index ce46ad6d..cd51beae 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -51,8 +51,14 @@ jobs: fiji/Fiji.app/engines - name: Run deepImageJ tests for drafts run: python scripts/check_compatibility_deepimagej.py all_versions_draft.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app + env: + JSON_OUTS_FNAME: dij_ouputs_file.json + MACRO_NAME: dij_macro_ci.ijm - name: Run deepImageJ tests for pusblished versions run: python scripts/check_compatibility_deepimagej.py all_versions.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app + env: + JSON_OUTS_FNAME: dij_ouputs_file.json + MACRO_NAME: dij_macro_ci.ijm - name: Save reports for debugging purposes uses: actions/upload-artifact@v4 with: @@ -66,6 +72,4 @@ jobs: S3_FOLDER: ${{vars.S3_FOLDER}} S3_ACCESS_KEY_ID: ${{secrets.S3_ACCESS_KEY_ID}} S3_SECRET_ACCESS_KEY: ${{secrets.S3_SECRET_ACCESS_KEY}} - RUN_URL: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} - JSON_OUTS_FNAME: dij_ouputs_file.json - MACRO_NAME: dij_macro_ci.ijm + RUN_URL: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} \ No newline at end of file diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 23bfdd7b..804d34ac 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -205,9 +205,6 @@ def get_dij_version(fiji_path): _ = parser.add_argument("fiji_executable", type=str) _ = parser.add_argument("fiji_path", type=str) - for key, value in os.environ.items(): - print(f"{key}={value}") - args = parser.parse_args() check_compatibility_deepimagej( get_dij_version(args.fiji_path), args.all_versions, args.output_folder, fiji_executable=args.fiji_executable, fiji_path=args.fiji_path From 7f0b9b2d20aac53028abdc054a225b23edc2a8ab Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 14:23:31 +0100 Subject: [PATCH 128/150] add missing import --- scripts/deepimagej_jython_scripts/deepimagej_download_model.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_download_model.py b/scripts/deepimagej_jython_scripts/deepimagej_download_model.py index 179a22be..499a473e 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_download_model.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_download_model.py @@ -20,10 +20,9 @@ from io.bioimage.modelrunner.bioimageio import BioimageioRepo from io.bioimage.modelrunner.bioimageio.description import ModelDescriptorFactory -from io.bioimage.modelrunner.utils import Constants from io.bioimage.modelrunner.numpy import DecodeNumpy -from io.bioimage.modelrunner.versionmanagement import AvailableEngines +from deepimagej.tools import ImPlusRaiManager from ij import IJ From 180b97264d56d4d74bd31b132eeef6801354a79f Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 14:32:16 +0100 Subject: [PATCH 129/150] try to understand why some test images where not seen --- scripts/check_compatibility_deepimagej.py | 4 +++- .../deepimagej_jython_scripts/deepimagej_download_model.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 804d34ac..9ffa73c9 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -63,7 +63,9 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): stdout=subprocess.PIPE, text=True ) - model_dir = download_result.stdout.strip().splitlines()[-1] + out_str = download_result.stdout + print(out_str) + model_dir = out_str.strip().splitlines()[-1] except BaseException as e: report = CompatibilityReportDict( status="failed", diff --git a/scripts/deepimagej_jython_scripts/deepimagej_download_model.py b/scripts/deepimagej_jython_scripts/deepimagej_download_model.py index 499a473e..85d71ca4 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_download_model.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_download_model.py @@ -77,6 +77,7 @@ def convert_npy_to_tif(folder_path, test_name, axesOrder, name=CREATED_INPUT_SAM sample_name = descriptor.getInputTensors().get(0).getSampleTensorName() if sample_name is None: test_name = descriptor.getInputTensors().get(0).getTestTensorName() + print(descriptor.getName() + ": " + test_name) if test_name is None: raise Exception("There are no test inputs for model: " + descriptor.getModelID()) convert_npy_to_tif(mfp, test_name, descriptor.getInputTensors().get(0).getAxesOrder()) From 69c934a80a6e4310d02b53b191b4e7a8047e8428 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 14:39:03 +0100 Subject: [PATCH 130/150] use abs path --- scripts/check_compatibility_deepimagej.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 9ffa73c9..68d3f9b4 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -208,6 +208,7 @@ def get_dij_version(fiji_path): _ = parser.add_argument("fiji_path", type=str) args = parser.parse_args() + fiji_path = os.path.abspath(args.fiji_path) check_compatibility_deepimagej( - get_dij_version(args.fiji_path), args.all_versions, args.output_folder, fiji_executable=args.fiji_executable, fiji_path=args.fiji_path + get_dij_version(fiji_path), args.all_versions, args.output_folder, fiji_executable=args.fiji_executable, fiji_path=fiji_path ) From e36b6404e44a1124a7021aaa976a4441f1cbccb8 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 15:23:41 +0100 Subject: [PATCH 131/150] catch errors on macro execution --- .github/workflows/check_compatibility_deepimagej.yaml | 10 ++++++---- scripts/check_compatibility_deepimagej.py | 10 +++++++++- .../deepimagej_download_model.py | 3 ++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index cd51beae..56c1093f 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -52,13 +52,15 @@ jobs: - name: Run deepImageJ tests for drafts run: python scripts/check_compatibility_deepimagej.py all_versions_draft.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app env: - JSON_OUTS_FNAME: dij_ouputs_file.json - MACRO_NAME: dij_macro_ci.ijm + JSON_OUTS_FNAME: dij_ouputs_file${{ github.run_id }}.json + MACRO_NAME: dij_macro_ci${{ github.run_id }}.ijm + FINISH_STR: MACRO_COMPLETED_${{ github.run_id }} - name: Run deepImageJ tests for pusblished versions run: python scripts/check_compatibility_deepimagej.py all_versions.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app env: - JSON_OUTS_FNAME: dij_ouputs_file.json - MACRO_NAME: dij_macro_ci.ijm + JSON_OUTS_FNAME: dij_ouputs_file${{ github.run_id }}.json + MACRO_NAME: dij_macro_ci${{ github.run_id }}.ijm + FINISH_STR: MACRO_COMPLETED_${{ github.run_id }} - name: Save reports for debugging purposes uses: actions/upload-artifact@v4 with: diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 68d3f9b4..d72f48b0 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -74,7 +74,6 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): links=["deepimagej/deepimagej"], ) return report - print(model_dir) macro_path = os.path.join(model_dir, str(os.getenv("MACRO_NAME"))) try: run = subprocess.run( @@ -89,6 +88,15 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): stdout=subprocess.PIPE, text=True ) + out_str = run.stdout + if os.getenv("FINISH_STR") not in out_str: + report = CompatibilityReportDict( + status="failed", + error=f"error running the model", + details=out_str), + links=["deepimagej/deepimagej"], + ) + return report except BaseException as e: report = CompatibilityReportDict( status="failed", diff --git a/scripts/deepimagej_jython_scripts/deepimagej_download_model.py b/scripts/deepimagej_jython_scripts/deepimagej_download_model.py index 85d71ca4..1e6ec24c 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_download_model.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_download_model.py @@ -30,7 +30,8 @@ import argparse import json -MACRO_STR = "run(\"DeepImageJ Run\", \"modelPath={model_path} inputPath={input_path} outputFolder={output_folder} displayOutput=null\")" +MACRO_STR = "run(\"DeepImageJ Run\", \"modelPath={model_path} inputPath={input_path} outputFolder={output_folder} displayOutput=null\")" \ + + os.linesep + "print('" + os.getenv("FINISH_STR") + "')" CREATED_INPUT_SAMPLE_NAME = "converted_sample_input_0.tif" CREATED_OUTPUT_SAMPLE_NAME = "converted_sample_ouput_0.tif" From eecb81b509e5753a002ce4b16b5dce8d3f721534 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 15:27:00 +0100 Subject: [PATCH 132/150] typo --- scripts/check_compatibility_deepimagej.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index d72f48b0..105a9a4a 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -93,7 +93,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"error running the model", - details=out_str), + details=out_str, links=["deepimagej/deepimagej"], ) return report From db55f41cbe2990e5695fe15416ee10342ae08331 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 15:35:54 +0100 Subject: [PATCH 133/150] add prints --- scripts/check_compatibility_deepimagej.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 105a9a4a..4c9ced65 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -89,6 +89,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): text=True ) out_str = run.stdout + print(out_str) if os.getenv("FINISH_STR") not in out_str: report = CompatibilityReportDict( status="failed", @@ -216,6 +217,7 @@ def get_dij_version(fiji_path): _ = parser.add_argument("fiji_path", type=str) args = parser.parse_args() + print(os.getenv("FINISH_STR")) fiji_path = os.path.abspath(args.fiji_path) check_compatibility_deepimagej( get_dij_version(fiji_path), args.all_versions, args.output_folder, fiji_executable=args.fiji_executable, fiji_path=fiji_path From 6d1a7f0dd223d0872608c427075e2cc9139a7540 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 16:49:59 +0100 Subject: [PATCH 134/150] check if dij has been run by checking the outputs are there --- .../check_compatibility_deepimagej.yaml | 2 -- scripts/check_compatibility_deepimagej.py | 17 ++++++++++++++--- .../deepimagej_download_model.py | 3 +-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 56c1093f..52076fa2 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -54,13 +54,11 @@ jobs: env: JSON_OUTS_FNAME: dij_ouputs_file${{ github.run_id }}.json MACRO_NAME: dij_macro_ci${{ github.run_id }}.ijm - FINISH_STR: MACRO_COMPLETED_${{ github.run_id }} - name: Run deepImageJ tests for pusblished versions run: python scripts/check_compatibility_deepimagej.py all_versions.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app env: JSON_OUTS_FNAME: dij_ouputs_file${{ github.run_id }}.json MACRO_NAME: dij_macro_ci${{ github.run_id }}.ijm - FINISH_STR: MACRO_COMPLETED_${{ github.run_id }} - name: Save reports for debugging purposes uses: actions/upload-artifact@v4 with: diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 4c9ced65..13f97684 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -3,6 +3,7 @@ from typing import List, Dict, Any import os import re +import json import urllib.request import subprocess @@ -12,6 +13,18 @@ from script_utils import CompatibilityReportDict, check_tool_compatibility, download_rdf +def check_dij_macro_generated_outputs(model_dir: str): + with open(os.path.join(model_dir, os.getenv("JSON_OUTS_FNAME")), 'r') as f: + expected_outputs = json.load(f) + + for i, output in enumerate(expected_outputs): + name = output["name"] + dij_output = output["dij"] + if not os.path.exists(dij_output): + return False + return True + + def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): yaml_file = os.path.abspath("rdf.yaml") try: @@ -89,8 +102,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): text=True ) out_str = run.stdout - print(out_str) - if os.getenv("FINISH_STR") not in out_str: + if not check_dij_macro_generated_outputs(model_dir): report = CompatibilityReportDict( status="failed", error=f"error running the model", @@ -217,7 +229,6 @@ def get_dij_version(fiji_path): _ = parser.add_argument("fiji_path", type=str) args = parser.parse_args() - print(os.getenv("FINISH_STR")) fiji_path = os.path.abspath(args.fiji_path) check_compatibility_deepimagej( get_dij_version(fiji_path), args.all_versions, args.output_folder, fiji_executable=args.fiji_executable, fiji_path=fiji_path diff --git a/scripts/deepimagej_jython_scripts/deepimagej_download_model.py b/scripts/deepimagej_jython_scripts/deepimagej_download_model.py index 1e6ec24c..85d71ca4 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_download_model.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_download_model.py @@ -30,8 +30,7 @@ import argparse import json -MACRO_STR = "run(\"DeepImageJ Run\", \"modelPath={model_path} inputPath={input_path} outputFolder={output_folder} displayOutput=null\")" \ - + os.linesep + "print('" + os.getenv("FINISH_STR") + "')" +MACRO_STR = "run(\"DeepImageJ Run\", \"modelPath={model_path} inputPath={input_path} outputFolder={output_folder} displayOutput=null\")" CREATED_INPUT_SAMPLE_NAME = "converted_sample_input_0.tif" CREATED_OUTPUT_SAMPLE_NAME = "converted_sample_ouput_0.tif" From b6a80d693a3235fe5679ae4ebdf50a640eb60582 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 16:52:33 +0100 Subject: [PATCH 135/150] do not use python 3 things in jython --- .../deepimagej_check_outputs.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py index 7cb27b03..d306902a 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py @@ -22,27 +22,27 @@ def main(model_dir): with open(os.path.join(model_dir, os.getenv("JSON_OUTS_FNAME")), 'r') as f: expected_outputs = json.load(f) - for i, output in enumerate(expected_outputs): + for output in expected_outputs: name = output["name"] dij_output = output["dij"] outputs_path = output["expected"] if not os.path.exists(dij_output): - raise Exception(f"Output {i} was not generated by deepimagej") + raise Exception("Output " + name + " was not generated by deepimagej") elif not os.path.exists(outputs_path): - raise Exception(f"Cannot find expected output {i}") + raise Exception("Cannot find expected output " + name) expected_output = find_expected_output(outputs_path, name) dij_rai = ImageJFunctions.wrap(IJ.openImage(dij_output)) expected_rai = ImageJFunctions.wrap(IJ.openImage(expected_output)) dij_shape = dij_rai.dimensionsAsLongArray() expected_shape = expected_rai.dimensionsAsLongArray() - assert dij_shape == expected_shape, f"Output {i} in deepiamgej has different shape {dij_shape} vs {expected_shape}" + assert dij_shape == expected_shape, "Output " + name + " in deepimagej has different shape " + str(dij_shape) + " vs " + str(expected_shape) dij_cursor = dij_rai.cursor() expected_cursor = expected_rai.cursor() while dij_cursor.hasNext(): dij_cursor.fwd() expected_cursor.fwd() if dij_cursor.get().getRealFloat() - expected_cursor.get().getRealFloat() > 1e-5: - raise Exception(f"Values of output {i} differ") + raise Exception("Values of output " + name + " differ") if __name__ == '__main__': From a2de3268b140b13252096769de0ff643c732644f Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 16:53:13 +0100 Subject: [PATCH 136/150] remoe unnecessary print --- scripts/check_compatibility_deepimagej.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 13f97684..5625cc47 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -76,8 +76,6 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): stdout=subprocess.PIPE, text=True ) - out_str = download_result.stdout - print(out_str) model_dir = out_str.strip().splitlines()[-1] except BaseException as e: report = CompatibilityReportDict( From 5fc727d6f5e6968cd6ff1b605776923d28ee30a5 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 16:54:47 +0100 Subject: [PATCH 137/150] sae drafts to be faster --- .github/workflows/check_compatibility_deepimagej.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 52076fa2..0297fdf6 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -54,6 +54,11 @@ jobs: env: JSON_OUTS_FNAME: dij_ouputs_file${{ github.run_id }}.json MACRO_NAME: dij_macro_ci${{ github.run_id }}.ijm + - name: Save reports for debugging purposes for drafts + uses: actions/upload-artifact@v4 + with: + name: generated-reports-dij-drafts + path: generated-reports - name: Run deepImageJ tests for pusblished versions run: python scripts/check_compatibility_deepimagej.py all_versions.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app env: From 688d633cc0be5aa9c9bc4435dab17b384137512d Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 16:57:08 +0100 Subject: [PATCH 138/150] identation error --- scripts/check_compatibility_deepimagej.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 5625cc47..d63dabef 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -15,13 +15,13 @@ def check_dij_macro_generated_outputs(model_dir: str): with open(os.path.join(model_dir, os.getenv("JSON_OUTS_FNAME")), 'r') as f: - expected_outputs = json.load(f) + expected_outputs = json.load(f) - for i, output in enumerate(expected_outputs): - name = output["name"] - dij_output = output["dij"] - if not os.path.exists(dij_output): - return False + for i, output in enumerate(expected_outputs): + name = output["name"] + dij_output = output["dij"] + if not os.path.exists(dij_output): + return False return True From f5410af58b6e1e4400da0b14ede9d436b1221bb0 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 17:12:48 +0100 Subject: [PATCH 139/150] print url to understand better --- scripts/check_compatibility_deepimagej.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index d63dabef..e09db3fc 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -26,6 +26,7 @@ def check_dij_macro_generated_outputs(model_dir: str): def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): + print(rdf_url) yaml_file = os.path.abspath("rdf.yaml") try: urllib.request.urlretrieve(rdf_url, yaml_file) From a47614cb3dc496644a2bb498091090e5886055fc Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 17:14:58 +0100 Subject: [PATCH 140/150] correct error stupid --- scripts/check_compatibility_deepimagej.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index e09db3fc..548197c2 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -77,7 +77,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): stdout=subprocess.PIPE, text=True ) - model_dir = out_str.strip().splitlines()[-1] + model_dir = download_result.stdout.strip().splitlines()[-1] except BaseException as e: report = CompatibilityReportDict( status="failed", From 05929a6838682924135f1aa2391dc997013272c9 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 17:29:15 +0100 Subject: [PATCH 141/150] correct macro run checker --- scripts/check_compatibility_deepimagej.py | 14 +++++++++++--- .../deepimagej_check_outputs.py | 12 ++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 548197c2..f1fa4e6d 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -13,15 +13,23 @@ from script_utils import CompatibilityReportDict, check_tool_compatibility, download_rdf -def check_dij_macro_generated_outputs(model_dir: str): +def find_expected_output(outputs_dir, name): + for ff in os.listdir(outputs_dir): + if ff.endswith("_" + name + ".tif") or ff.endswith("_" + name + ".tiff"): + return True + return False + + +def check_dij_macro_generated_outputs(model_dir: str, name: str): with open(os.path.join(model_dir, os.getenv("JSON_OUTS_FNAME")), 'r') as f: expected_outputs = json.load(f) - for i, output in enumerate(expected_outputs): - name = output["name"] + for output in enumerate(expected_outputs): dij_output = output["dij"] if not os.path.exists(dij_output): return False + if not find_expected_output(dij_output, name): + return False return True diff --git a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py index d306902a..7482b372 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py @@ -13,9 +13,9 @@ def find_expected_output(outputs_dir, name): for ff in os.listdir(outputs_dir): - if ff.endswith(f"_{name}.tif") or ff.endswith(f"_{name}.tiff"): + if ff.endswith("_" + name + ".tif") or ff.endswith("_" + name + ".tiff"): return os.path.join(outputs_dir, ff) - raise Exception(f"Expected output for {name} not found") + raise Exception("Expected output for " + name + " not found") def main(model_dir): @@ -24,13 +24,13 @@ def main(model_dir): for output in expected_outputs: name = output["name"] - dij_output = output["dij"] - outputs_path = output["expected"] - if not os.path.exists(dij_output): + dij_output_path = output["dij"] + expected_output = output["expected"] + if not os.path.exists(dij_output) or len(os.listdir(dij_output_path)) != len(expected_outputs): raise Exception("Output " + name + " was not generated by deepimagej") elif not os.path.exists(outputs_path): raise Exception("Cannot find expected output " + name) - expected_output = find_expected_output(outputs_path, name) + dij_output = find_expected_output(dij_output_path, name) dij_rai = ImageJFunctions.wrap(IJ.openImage(dij_output)) expected_rai = ImageJFunctions.wrap(IJ.openImage(expected_output)) dij_shape = dij_rai.dimensionsAsLongArray() From daeff06bbc76541fc73d41280fdda7f7862ce159 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 17:47:49 +0100 Subject: [PATCH 142/150] provide more verbose exceptions --- scripts/check_compatibility_deepimagej.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index f1fa4e6d..b86f5f18 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -20,11 +20,12 @@ def find_expected_output(outputs_dir, name): return False -def check_dij_macro_generated_outputs(model_dir: str, name: str): +def check_dij_macro_generated_outputs(model_dir: str): with open(os.path.join(model_dir, os.getenv("JSON_OUTS_FNAME")), 'r') as f: expected_outputs = json.load(f) for output in enumerate(expected_outputs): + name = output["name"] dij_output = output["dij"] if not os.path.exists(dij_output): return False @@ -42,7 +43,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"unable to download the yaml file", - details=traceback.format_exc(), + details=e.stderr if isinstance(e, subprocess.CalledProcessError) else str(e), links=["deepimagej/deepimagej"], ) return report @@ -58,13 +59,14 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): ], check=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True ) except BaseException as e: report = CompatibilityReportDict( status="failed", error=f"unable to read the yaml file", - details=traceback.format_exc(), + details=e.stderr if isinstance(e, subprocess.CalledProcessError) else str(e), links=["deepimagej/deepimagej"], ) return report @@ -83,6 +85,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): ], check=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True ) model_dir = download_result.stdout.strip().splitlines()[-1] @@ -90,7 +93,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"unable to download the model", - details=traceback.format_exc(), + details=e.stderr if isinstance(e, subprocess.CalledProcessError) else str(e), links=["deepimagej/deepimagej"], ) return report @@ -106,6 +109,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): ], check=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True ) out_str = run.stdout @@ -121,7 +125,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"error running the model", - details=traceback.format_exc(), + details=e.stderr if isinstance(e, subprocess.CalledProcessError) else str(e), links=["deepimagej/deepimagej"], ) return report @@ -137,13 +141,14 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): ], check=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True ) except BaseException as e: report = CompatibilityReportDict( status="failed", error=f"error comparing expected outputs and actual outputs", - details=traceback.format_exc(), + details=e.stderr if isinstance(e, subprocess.CalledProcessError) else str(e), links=["deepimagej/deepimagej"], ) return report From deb26e93bb874b2216029650bb7b67596ada11de Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 18:18:59 +0100 Subject: [PATCH 143/150] more verbose --- scripts/check_compatibility_deepimagej.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index b86f5f18..9f565b8d 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -43,7 +43,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"unable to download the yaml file", - details=e.stderr if isinstance(e, subprocess.CalledProcessError) else str(e), + details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else str(e), links=["deepimagej/deepimagej"], ) return report @@ -66,7 +66,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"unable to read the yaml file", - details=e.stderr if isinstance(e, subprocess.CalledProcessError) else str(e), + details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else str(e), links=["deepimagej/deepimagej"], ) return report @@ -93,7 +93,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"unable to download the model", - details=e.stderr if isinstance(e, subprocess.CalledProcessError) else str(e), + details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else str(e), links=["deepimagej/deepimagej"], ) return report @@ -125,7 +125,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"error running the model", - details=e.stderr if isinstance(e, subprocess.CalledProcessError) else str(e), + details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else str(e), links=["deepimagej/deepimagej"], ) return report @@ -148,7 +148,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"error comparing expected outputs and actual outputs", - details=e.stderr if isinstance(e, subprocess.CalledProcessError) else str(e), + details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else str(e), links=["deepimagej/deepimagej"], ) return report From a5241b9e940d738512c3ccfd41922f4d85057ee1 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 18:51:10 +0100 Subject: [PATCH 144/150] remoe enumerate that was causing errors --- scripts/check_compatibility_deepimagej.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 9f565b8d..9c6a4b09 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -24,7 +24,7 @@ def check_dij_macro_generated_outputs(model_dir: str): with open(os.path.join(model_dir, os.getenv("JSON_OUTS_FNAME")), 'r') as f: expected_outputs = json.load(f) - for output in enumerate(expected_outputs): + for output in expected_outputs: name = output["name"] dij_output = output["dij"] if not os.path.exists(dij_output): @@ -43,7 +43,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"unable to download the yaml file", - details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else str(e), + details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else traceback.format_exc(), links=["deepimagej/deepimagej"], ) return report @@ -66,7 +66,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"unable to read the yaml file", - details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else str(e), + details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else traceback.format_exc(), links=["deepimagej/deepimagej"], ) return report @@ -93,7 +93,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"unable to download the model", - details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else str(e), + details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else traceback.format_exc(), links=["deepimagej/deepimagej"], ) return report @@ -125,7 +125,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"error running the model", - details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else str(e), + details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else traceback.format_exc(), links=["deepimagej/deepimagej"], ) return report @@ -148,7 +148,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): report = CompatibilityReportDict( status="failed", error=f"error comparing expected outputs and actual outputs", - details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else str(e), + details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else traceback.format_exc(), links=["deepimagej/deepimagej"], ) return report From 4c2afc8a3911accff762c3a5aa68806b628e38ea Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 Jan 2025 23:48:36 +0100 Subject: [PATCH 145/150] correct small error --- scripts/check_compatibility_deepimagej.py | 1 - scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 9c6a4b09..bec22613 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -35,7 +35,6 @@ def check_dij_macro_generated_outputs(model_dir: str): def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): - print(rdf_url) yaml_file = os.path.abspath("rdf.yaml") try: urllib.request.urlretrieve(rdf_url, yaml_file) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py index 7482b372..90eba0d9 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py @@ -26,7 +26,7 @@ def main(model_dir): name = output["name"] dij_output_path = output["dij"] expected_output = output["expected"] - if not os.path.exists(dij_output) or len(os.listdir(dij_output_path)) != len(expected_outputs): + if not os.path.exists(dij_output_path) or len(os.listdir(dij_output_path)) != len(expected_outputs): raise Exception("Output " + name + " was not generated by deepimagej") elif not os.path.exists(outputs_path): raise Exception("Cannot find expected output " + name) From 178d64527d5575d4ca336799a399ba69d9bcc929 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 29 Jan 2025 10:10:46 +0100 Subject: [PATCH 146/150] error using non defined variable --- scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py index 90eba0d9..c0b3270e 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py @@ -28,7 +28,7 @@ def main(model_dir): expected_output = output["expected"] if not os.path.exists(dij_output_path) or len(os.listdir(dij_output_path)) != len(expected_outputs): raise Exception("Output " + name + " was not generated by deepimagej") - elif not os.path.exists(outputs_path): + elif not os.path.exists(expected_output): raise Exception("Cannot find expected output " + name) dij_output = find_expected_output(dij_output_path, name) dij_rai = ImageJFunctions.wrap(IJ.openImage(dij_output)) From 94dd165958780f9cab6fd1d92a4ad809596957a4 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 29 Jan 2025 13:56:50 +0100 Subject: [PATCH 147/150] remove processing and halo to be able to produce the expected result --- .../check_compatibility_deepimagej.yaml | 20 ++++++------- scripts/check_compatibility_deepimagej.py | 30 +++++++++++++++++-- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/.github/workflows/check_compatibility_deepimagej.yaml b/.github/workflows/check_compatibility_deepimagej.yaml index 0297fdf6..86ab9d0b 100644 --- a/.github/workflows/check_compatibility_deepimagej.yaml +++ b/.github/workflows/check_compatibility_deepimagej.yaml @@ -49,16 +49,16 @@ jobs: run: fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console scripts/deepimagej_jython_scripts/deepimagej_download_engines.py -engines_path fiji/Fiji.app/engines - - name: Run deepImageJ tests for drafts - run: python scripts/check_compatibility_deepimagej.py all_versions_draft.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app - env: - JSON_OUTS_FNAME: dij_ouputs_file${{ github.run_id }}.json - MACRO_NAME: dij_macro_ci${{ github.run_id }}.ijm - - name: Save reports for debugging purposes for drafts - uses: actions/upload-artifact@v4 - with: - name: generated-reports-dij-drafts - path: generated-reports + #- name: Run deepImageJ tests for drafts + # run: python scripts/check_compatibility_deepimagej.py all_versions_draft.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app + # env: + # JSON_OUTS_FNAME: dij_ouputs_file${{ github.run_id }}.json + # MACRO_NAME: dij_macro_ci${{ github.run_id }}.ijm + #- name: Save reports for debugging purposes for drafts + # uses: actions/upload-artifact@v4 + # with: + # name: generated-reports-dij-drafts + # path: generated-reports - name: Run deepImageJ tests for pusblished versions run: python scripts/check_compatibility_deepimagej.py all_versions.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app env: diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index bec22613..803d9a2b 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -12,6 +12,13 @@ from script_utils import CompatibilityReportDict, check_tool_compatibility, download_rdf +try: + from ruyaml import YAML +except ImportError: + from ruamel.yaml import YAML + +yaml = YAML(typ="safe") + def find_expected_output(outputs_dir, name): for ff in os.listdir(outputs_dir): @@ -33,6 +40,23 @@ def check_dij_macro_generated_outputs(model_dir: str): return False return True +def remove_processing_and_halo(model_dir: str): + data = None + with open(os.path.join(model_dir, "rdf.yaml")) as stream: + data = yaml.load(stream) + for inp in data["inputs"]: + inp.pop('preprocessing', None) + for out in data["outputs"]: + out.pop('postprocessing', None) + if not isinstance(out["axes"][0], dict): + out.pop('halo', None) + continue + for ax in out["axes"]: + ax.pop('halo', None) + with open(os.path.join(model_dir, "rdf.yaml"), 'w') as outfile: + yaml.dump(data, outfile) + + def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): yaml_file = os.path.abspath("rdf.yaml") @@ -96,6 +120,7 @@ def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str): links=["deepimagej/deepimagej"], ) return report + remove_processing_and_halo(model_dir) macro_path = os.path.join(model_dir, str(os.getenv("MACRO_NAME"))) try: run = subprocess.run( @@ -188,10 +213,11 @@ def check_compatibility_deepimagej_impl( links=["deepimagej/deepimagej"], ) - elif len(rdf["inputs"]) > 1 or len(rdf["outputs"]) > 1: + elif len(rdf["inputs"]) > 1 :#or len(rdf["outputs"]) > 1: report = CompatibilityReportDict( status="failed", - error=f"deepimagej only supports single tensor input/output (found {len(rdf['inputs'])}/{len(rdf['outputs'])})", + #error=f"deepimagej only supports single tensor input/output (found {len(rdf['inputs'])}/{len(rdf['outputs'])})", + error=f"deepimagej only supports single tensor input (found {len(rdf['inputs'])})", details=None, links=["deepimagej/deepimagej"], ) From 3c307261c81ae1727b0d8d32c9c4f6be517b566f Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 30 Jan 2025 00:06:04 +0100 Subject: [PATCH 148/150] correct the similarity threshold --- scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py index c0b3270e..dada1eb1 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py @@ -41,7 +41,8 @@ def main(model_dir): while dij_cursor.hasNext(): dij_cursor.fwd() expected_cursor.fwd() - if dij_cursor.get().getRealFloat() - expected_cursor.get().getRealFloat() > 1e-5: + if dij_cursor.get().getRealFloat() - expected_cursor.get().getRealFloat() > (1.5 * 1e-4) \ + or expected_cursor.get().getRealFloat() - dij_cursor.get().getRealFloat() > (1.5 * 1e-4): raise Exception("Values of output " + name + " differ") From 0aa71e181db70afdf0966b7caaf445e4487a3afc Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 30 Jan 2025 12:30:11 +0100 Subject: [PATCH 149/150] update tolerance --- scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py index dada1eb1..04f61fee 100644 --- a/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py +++ b/scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py @@ -41,8 +41,7 @@ def main(model_dir): while dij_cursor.hasNext(): dij_cursor.fwd() expected_cursor.fwd() - if dij_cursor.get().getRealFloat() - expected_cursor.get().getRealFloat() > (1.5 * 1e-4) \ - or expected_cursor.get().getRealFloat() - dij_cursor.get().getRealFloat() > (1.5 * 1e-4): + if abs(dij_cursor.get().getRealFloat() - expected_cursor.get().getRealFloat()) > (1.5 * 1e-4 + 1e-4 * abs(expected_cursor.get().getRealFloat())): raise Exception("Values of output " + name + " differ") From 87fbadc0a6d50c98eef806e5f7701a9bfc1b0bf2 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 30 Jan 2025 12:51:11 +0100 Subject: [PATCH 150/150] do not remove pre or post processing --- scripts/check_compatibility_deepimagej.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/check_compatibility_deepimagej.py b/scripts/check_compatibility_deepimagej.py index 803d9a2b..9e7478eb 100644 --- a/scripts/check_compatibility_deepimagej.py +++ b/scripts/check_compatibility_deepimagej.py @@ -44,10 +44,7 @@ def remove_processing_and_halo(model_dir: str): data = None with open(os.path.join(model_dir, "rdf.yaml")) as stream: data = yaml.load(stream) - for inp in data["inputs"]: - inp.pop('preprocessing', None) for out in data["outputs"]: - out.pop('postprocessing', None) if not isinstance(out["axes"][0], dict): out.pop('halo', None) continue