Skip to content

Commit

Permalink
correct arising errors
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Aug 5, 2024
1 parent 9586f37 commit 2accea9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public Map<Path, ModelDescriptor> listAllModels(boolean verbose) {
ModelDescriptor descriptor = ModelDescriptorFactory.readFromYamlTextString(stringRDF);
models.put(Paths.get(url), descriptor);
} catch (Exception ex) {
ex.printStackTrace();
// TODO Maybe add some error message? This should be responsibility of the BioImage.io user
// Only display error message if there was an error creating
// the descriptor from the yaml file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -118,7 +117,7 @@ protected static ModelDescriptorV04 buildModelDescription(Map<String, Object> ya
modelDescription.description = (String) fieldElement;
break;
case "id":
modelDescription.modelID = (String) fieldElement;
modelDescription.modelID = findID(yamlElements);
break;
case "authors":
modelDescription.authors = buildAuthorElements((List<?>) fieldElement);
Expand Down Expand Up @@ -264,6 +263,19 @@ private void addBioEngine() throws ModelSpecsException {
}
}

private static String findID(Map<String, Object> yamlElements) {

if (yamlElements.get("config") instanceof Map) {
Map<String, Object> configMap = (Map<String, Object>) yamlElements.get("config");
if (configMap.get("bioimageio") instanceof Map) {
Map<String, Object> bioimageMap = (Map<String, Object>) configMap.get("bioimageio");
if (bioimageMap.get("nickname") != null)
return (String) bioimageMap.get("nickname");
}
}
return (String) yamlElements.get("id");
}

/**
* MAke sure that an object that is supposed to be a List<String>
* is actually a List<String>
Expand Down Expand Up @@ -440,6 +452,7 @@ private void calculateTotalInputHalo() {
if (inAx == null || inAx.getHalo() > axHalo) return;
inAx.halo = axHalo;
});
return;
}

double axScale = ax.getScale();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ protected void buildModelDescription() throws ModelSpecsException
// TODO createCovers();
break;
case "inputs":
buildInputTensors((List<?>) yamlElements.get(field));
input_tensors = buildInputTensors((List<?>) yamlElements.get(field));
break;
case "outputs":
buildOutputTensors((List<?>) yamlElements.get(field));
output_tensors = buildOutputTensors((List<?>) yamlElements.get(field));
calculateTotalInputHalo();
break;
case "config":
Expand Down Expand Up @@ -324,6 +324,7 @@ private void calculateTotalInputHalo() {
if (inAx == null || inAx.getHalo() > axHalo) return;
inAx.halo = axHalo;
});
return;
}

double axScale = ax.getScale();
Expand Down

0 comments on commit 2accea9

Please sign in to comment.