Skip to content

Commit

Permalink
add forgotten throws
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 24, 2024
1 parent 96f22f4 commit 062b779
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,9 @@ public static boolean installEnginesForModelInDir(ModelDescriptor descriptor, St
* @return true if at least one DL engine of the model weights defined in the rdf.yaml is
* successfully installed
* @throws IOException if there is any error creating the folder for the engine
* @throws InterruptedException if the thread is interrupted while trying to connect to the Bioimage.io
*/
public static boolean installEnginesForModelByID(String modelID) throws IOException {
public static boolean installEnginesForModelByID(String modelID) throws IOException, InterruptedException {
return installEnginesForModelByIDInDir(modelID, InstalledEngines.getEnginesDir(), null);
}

Expand All @@ -849,9 +850,10 @@ public static boolean installEnginesForModelByID(String modelID) throws IOExcept
* @return true if at least one DL engine of the model weights defined in the rdf.yaml is
* successfully installed
* @throws IOException if there is any error creating the folder for the engine
* @throws InterruptedException if the thread is interrupted while trying to connect to the Bioimage.io
*/
public static boolean installEnginesForModelByID(String modelID,
DownloadTracker.TwoParameterConsumer<String, Double> consumer) throws IOException {
DownloadTracker.TwoParameterConsumer<String, Double> consumer) throws IOException, InterruptedException {
return installEnginesForModelByIDInDir(modelID, InstalledEngines.getEnginesDir(), consumer);
}

Expand All @@ -869,8 +871,9 @@ public static boolean installEnginesForModelByID(String modelID,
* @return true if at least one DL engine of the model weights defined in the rdf.yaml is
* successfully installed
* @throws IOException if there is any error creating the folder for the engine
* @throws InterruptedException if the thread is interrupted while trying to connect to the Bioimage.io
*/
public static boolean installEnginesForModelByIDInDir(String modelID, String enginesDir) throws IOException {
public static boolean installEnginesForModelByIDInDir(String modelID, String enginesDir) throws IOException, InterruptedException {
return installEnginesForModelByIDInDir(modelID, enginesDir, null);
}

Expand All @@ -890,9 +893,10 @@ public static boolean installEnginesForModelByIDInDir(String modelID, String eng
* @return true if at least one DL engine of the model weights defined in the rdf.yaml is
* successfully installed
* @throws IOException if there is any error creating the folder for the engine
* @throws InterruptedException if the thread is interrupted while trying to connect to the Bioimage.io
*/
public static boolean installEnginesForModelByIDInDir(String modelID, String enginesDir,
DownloadTracker.TwoParameterConsumer<String, Double> consumer) throws IOException {
DownloadTracker.TwoParameterConsumer<String, Double> consumer) throws IOException, InterruptedException {
ModelDescriptor descriptor = BioimageioRepo.connect().selectByID(modelID);
if (descriptor == null)
return false;
Expand All @@ -912,8 +916,9 @@ public static boolean installEnginesForModelByIDInDir(String modelID, String eng
* @return true if at least one DL engine of the model weights defined in the rdf.yaml is
* successfully installed
* @throws IOException if there is any error creating the folder for the engine
* @throws InterruptedException if the thread is interrupted while trying to connect to the Bioimage.io
*/
public static boolean installEnginesForModelByName(String modelName) throws IOException {
public static boolean installEnginesForModelByName(String modelName) throws IOException, InterruptedException {
return installEnginesForModelByNameinDir(modelName, InstalledEngines.getEnginesDir(), null);
}

Expand All @@ -932,9 +937,10 @@ public static boolean installEnginesForModelByName(String modelName) throws IOEx
* @return true if at least one DL engine of the model weights defined in the rdf.yaml is
* successfully installed
* @throws IOException if there is any error creating the folder for the engine
* @throws InterruptedException if the thread is interrupted while trying to connect to the Bioimage.io
*/
public static boolean installEnginesForModelByName(String modelName,
DownloadTracker.TwoParameterConsumer<String, Double> consumer) throws IOException {
DownloadTracker.TwoParameterConsumer<String, Double> consumer) throws IOException, InterruptedException {
return installEnginesForModelByNameinDir(modelName, InstalledEngines.getEnginesDir(), consumer);
}

Expand All @@ -952,8 +958,9 @@ public static boolean installEnginesForModelByName(String modelName,
* @return true if at least one DL engine of the model weights defined in the rdf.yaml is
* successfully installed
* @throws IOException if there is any error creating the folder for the engine
* @throws InterruptedException if the thread is interrupted while trying to connect to the Bioimage.io
*/
public static boolean installEnginesForModelByNameinDir(String modelName, String enginesDir) throws IOException {
public static boolean installEnginesForModelByNameinDir(String modelName, String enginesDir) throws IOException, InterruptedException {
return installEnginesForModelByNameinDir(modelName, enginesDir, null);
}

Expand All @@ -973,9 +980,10 @@ public static boolean installEnginesForModelByNameinDir(String modelName, String
* @return true if at least one DL engine of the model weights defined in the rdf.yaml is
* successfully installed
* @throws IOException if there is any error creating the folder for the engine
* @throws InterruptedException if the thread is interrupted while trying to connect to the Bioimage.io
*/
public static boolean installEnginesForModelByNameinDir(String modelName, String enginesDir,
DownloadTracker.TwoParameterConsumer<String, Double> consumer) throws IOException {
DownloadTracker.TwoParameterConsumer<String, Double> consumer) throws IOException, InterruptedException {
ModelDescriptor descriptor = BioimageioRepo.connect().selectByName(modelName);
if (descriptor == null)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ private static void installAllValidEngines() {
*
* @param args
* main args, in this case nothing is needed
* @throws InterruptedException if the thread is interrupted
*/
public static void main(String[] args) {
public static void main(String[] args) throws InterruptedException {
List<String> modelsWithErrors = new ArrayList<String>();
installAllValidEngines();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ public static void main(String[] args) throws Exception {
* @param tensor
* input tensor for stardist
* @return the OP can be run to use stardist
* @throws InterruptedException if the thread is interrupted while looking for the model on the zoo
* @throws IllegalArgumentException if tehre is any incorrect argument
*/
public static < T extends RealType< T > & NativeType< T > >
StardistInferJdllOp create(String modelName, Tensor<T> tensor) {
StardistInferJdllOp create(String modelName, Tensor<T> tensor) throws IllegalArgumentException, InterruptedException {
StardistInferJdllOp op = new StardistInferJdllOp();
op.setModel(modelName);
op.setInputTensor(tensor);
Expand All @@ -115,8 +117,9 @@ StardistInferJdllOp create(String modelName, Tensor<T> tensor) {
* the model name. It can be either the path to a Bioimage.io model folder or the name of
* one of the pretrained models available in the stardist package
* @throws IllegalArgumentException if the model name is not valid
* @throws InterruptedException if the thread is interrupted while looking for the model on the zoo
*/
public void setModel(String modelName) throws IllegalArgumentException {
public void setModel(String modelName) throws IllegalArgumentException, InterruptedException {
Objects.requireNonNull(modelName, "The modelName input argument cannot be null.");
if (new File(modelName).isFile() && !isModelFileStardist(modelName))
throw new IllegalArgumentException("The file selected does not correspond to "
Expand Down Expand Up @@ -222,8 +225,9 @@ public boolean isOpInstalled() {
* @param modelName
* file path or name of a stardist model
* @return true if it corresponds to a stardsit model or false otherwise
* @throws InterruptedException if the thread is interrupted while looking for the model on the zoo
*/
public static boolean isModelCompatible(String modelName) {
public static boolean isModelCompatible(String modelName) throws InterruptedException {
if (modelName == null)
return false;
if (new File(modelName).isFile())
Expand Down Expand Up @@ -258,8 +262,9 @@ public static boolean isModelFileStardist(String modelFile) {
* a String corresponding to any of the following fields of the rdf.yaml file of a stardist
* model: 'name', 'nickname' or 'id'
* @return true if it actually corresponds to astardist model or false otherwise
* @throws InterruptedException if the thread is interrupted while looking for the model on the zoo
*/
public static boolean isModelNameStardist(String modelName) {
public static boolean isModelNameStardist(String modelName) throws InterruptedException {
BioimageioRepo br = BioimageioRepo.connect();
if (br.selectByName(modelName) != null) {
return br.selectByName(modelName).getConfig().getSpecMap().keySet().contains(STARDIST_FIELD_KEY);
Expand All @@ -273,8 +278,9 @@ public static boolean isModelNameStardist(String modelName) {
* Returns a list containing all the model names that corresponds to
* StarDist models existing in the Bioimage.io online repository.
* @return list of StarDist model names from the Bioimage.io repository
* @throws InterruptedException if the thread is interrupted while looking for the model on the zoo
*/
public static List<String> fetchStarDistModelNamesFromBioImage() {
public static List<String> fetchStarDistModelNamesFromBioImage() throws InterruptedException {
BioimageioRepo br = BioimageioRepo.connect();
List<String> stardistModels = br.listAllModels(false).values().stream()
.filter(md -> md.getConfig().getSpecMap().keySet().contains(STARDIST_FIELD_KEY))
Expand All @@ -286,8 +292,9 @@ public static List<String> fetchStarDistModelNamesFromBioImage() {
* Returns a list containing all the model IDs that corresponds to
* StarDist models existing in the Bioimage.io online repository.
* @return list of StarDist model IDs from the Bioimage.io repository
* @throws InterruptedException if the thread is interrupted while looking for the model on the zoo
*/
public static List<String> fetchStarDistModelIdsFromBioImage() {
public static List<String> fetchStarDistModelIdsFromBioImage() throws InterruptedException {
BioimageioRepo br = BioimageioRepo.connect();
List<String> stardistModels = br.listAllModels(false).values().stream()
.filter(md -> md.getConfig().getSpecMap().keySet().contains(STARDIST_FIELD_KEY))
Expand Down

0 comments on commit 062b779

Please sign in to comment.