Skip to content

Commit

Permalink
improve robustness and correct small details
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 16, 2024
1 parent 244fd5c commit bb0d84d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,6 @@ public static TensorSpec findTensorInList(String name, List<TensorSpec> tts)
*/
public List<String> getLinks();

/**
* Mark the model as downloaded or not. This method is useful for when the
* user selects a model from the BioImage.io
* @param dd
* whether the model is already downloaded or not
*/
public void setDownloaded(boolean dd);

/**
* Whether the model is already in the local repo or it has to be downloaded
* @return true if the model is already installed or false otherwise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,12 @@ public class ModelDescriptorV04 implements ModelDescriptor
private String version;
private List<String> links;
private Map<String, String> parent;
private boolean isModelLocal;
private static String fromLocalKey = "fromLocalRepo";
private static String modelPathKey = "modelPath";
private String modelID;
private String newModelID;
private String localModelPath;
private boolean supportBioengine = false;

private static BioimageioRepo BMZ_REPO;

private ModelDescriptorV04()
{
Expand Down Expand Up @@ -175,9 +172,6 @@ protected static ModelDescriptorV04 buildModelDescription(Map<String, Object> ya
case "weights":
modelDescription.weights = buildWeights((Map<String, Object>) yamlElements.get(field));
break;
case "fromLocalRepo":
modelDescription.isModelLocal = (boolean) fieldElement;
break;
case "modelPath":
modelDescription.localModelPath = (String) fieldElement;
break;
Expand Down Expand Up @@ -742,22 +736,14 @@ public Map<String, String> getParent() {
return parent;
}

/**
* Mark the model as downloaded or not. This method is useful for when the
* user selects a model from the BioImage.io
* @param dd
* whether the model is already downloaded or not
*/
public void setDownloaded(boolean dd) {
isModelLocal = dd;
}

/**
* Whether the model is already in the local repo or it has to be downloaded
* @return true if the model is already installed or false otherwise
*/
public boolean isModelInLocalRepo() {
return isModelLocal;
if (this.localModelPath == null)
return false;
return new File(localModelPath).isDirectory();
}

/**
Expand Down Expand Up @@ -822,18 +808,13 @@ public String buildInfo() {

@Override
public void addModelPath(Path modelBasePath) {
// TODO Auto-generated method stub

this.localModelPath = modelBasePath.toFile().getAbsolutePath();
}

@Override
public String getModelURL() {
if (this.download_url == null && BMZ_REPO == null) {
BMZ_REPO = BioimageioRepo.connect();
}

if (this.download_url == null)
this.download_url = BMZ_REPO.getModelRdfUrl(modelID, version);
this.download_url = BioimageioRepo.getModelRdfUrl(modelID, version);
return this.download_url;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package io.bioimage.modelrunner.bioimageio.description;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.nio.file.Path;
Expand Down Expand Up @@ -65,7 +66,6 @@ public class ModelDescriptorV05 implements ModelDescriptor
private Map<String, Object> attachments;
private String version;
private List<String> links;
private boolean isModelLocal;
private static String fromLocalKey = "fromLocalRepo";
private static String modelPathKey = "modelPath";
private String modelID;
Expand Down Expand Up @@ -165,9 +165,6 @@ protected void buildModelDescription() throws ModelSpecsException
case "weights":
weights = buildWeights((Map<String, Object>) yamlElements.get(field));
break;
case "fromLocalRepo":
isModelLocal = (boolean) fieldElement;
break;
case "modelPath":
localModelPath = (String) fieldElement;
break;
Expand Down Expand Up @@ -594,22 +591,14 @@ public List<String> getLinks() {
return links;
}

/**
* Mark the model as downloaded or not. This method is useful for when the
* user selects a model from the BioImage.io
* @param dd
* whether the model is already downloaded or not
*/
public void setDownloaded(boolean dd) {
isModelLocal = dd;
}

/**
* Whether the model is already in the local repo or it has to be downloaded
* @return true if the model is already installed or false otherwise
*/
public boolean isModelInLocalRepo() {
return isModelLocal;
if (this.localModelPath == null)
return false;
return new File(localModelPath).isDirectory();
}

/**
Expand Down Expand Up @@ -684,8 +673,7 @@ public List<Badge> getBadges() {

@Override
public void addModelPath(Path modelBasePath) {
// TODO Auto-generated method stub

this.localModelPath = modelBasePath.toFile().getAbsolutePath();
}

@Override
Expand Down

0 comments on commit bb0d84d

Please sign in to comment.