Skip to content

Commit

Permalink
adapt to new zenodo API
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 30, 2023
1 parent bb7eedc commit 99ff74c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.Arrays;
import java.util.List;

import io.bioimage.modelrunner.utils.Constants;

/**
* Define each of the sample inputs spedified in the yaml file
* @author Carlos Garcia Lopez de Haro
Expand Down Expand Up @@ -92,6 +94,8 @@ public String getFileExtension() {
return null;
if (string.lastIndexOf(".") == -1)
return null;
if (string.startsWith(Constants.ZENODO_DOMAIN) && string.endsWith(Constants.ZENODO_ANNOYING_SUFFIX))
return string.substring(string.lastIndexOf("."), string.length() - Constants.ZENODO_ANNOYING_SUFFIX.length());
return string.substring(string.lastIndexOf("."));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.Arrays;
import java.util.List;

import io.bioimage.modelrunner.utils.Constants;

/**
* Define each of the test inputs and outputs defined in the rdf.yaml file
* @author Carlos Garcia Lopez de Haro
Expand Down Expand Up @@ -92,6 +94,8 @@ public String getFileExtension() {
return null;
if (string.lastIndexOf(".") == -1)
return null;
if (string.startsWith(Constants.ZENODO_DOMAIN) && string.endsWith(Constants.ZENODO_ANNOYING_SUFFIX))
return string.substring(string.lastIndexOf("."), string.length() - Constants.ZENODO_ANNOYING_SUFFIX.length());
return string.substring(string.lastIndexOf("."));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import io.bioimage.modelrunner.bioimageio.description.weights.WeightFormat;
import io.bioimage.modelrunner.engine.EngineInfo;
import io.bioimage.modelrunner.engine.installation.FileDownloader;
import io.bioimage.modelrunner.utils.Constants;
import io.bioimage.modelrunner.utils.ZipUtils;

/**
Expand Down Expand Up @@ -512,8 +513,8 @@ private void unzipTfWeights() throws IOException {
* @throws MalformedURLException if the String does not correspond to an URL
*/
public static String getFileNameFromURLString(String str) throws MalformedURLException {
if (str.startsWith("https://zenodo.org/"))
str = str.substring(0, str.length() - "/content".length());
if (str.startsWith(Constants.ZENODO_DOMAIN))
str = str.substring(0, str.length() - Constants.ZENODO_ANNOYING_SUFFIX.length());
URL url = new URL(str);
return new File(url.getPath()).getName();
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/bioimage/modelrunner/utils/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,12 @@ public class Constants {
* File name of the resource description file inside the model folder
*/
public static final String RDF_FNAME = "rdf.yaml";
/**
* Last part of files stored in zenodo
*/
public static final String ZENODO_ANNOYING_SUFFIX = "/content";
/**
* Zenodo domain
*/
public static final String ZENODO_DOMAIN = "https://zenodo.org/";
}

0 comments on commit 99ff74c

Please sign in to comment.