Skip to content

Commit

Permalink
add java docs
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Dec 13, 2023
1 parent e1ca318 commit b736953
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@
* </p>
* <p>
* Appose comes with built-in support for two worker implementations:
* {@code python_worker} to run Python scripts, and {@link GroovyWorker}
* {@code python_worker} to run Python scripts,
* to run Groovy scripts. These workers can be created easily by invoking
* the {@link Environment#python} and {@link Environment#groovy} methods
* the {@link Environment#python} methods
* respectively.
* </p>
* <p>
Expand Down
26 changes: 22 additions & 4 deletions src/main/java/io/bioimage/modelrunner/apposed/appose/Conda.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ private ProcessBuilder getBuilder( final boolean isInheritIO )
* If the current thread is interrupted by another thread while it
* is waiting, then the wait is ended and an InterruptedException is
* thrown.
* @throws ArchiveException
* @throws URISyntaxException
* @throws ArchiveException if there is any error decompressing the micromamba files
* @throws URISyntaxException if the micromamba install link is wrong or does not work or there is no internet connection
*/
public Conda() throws IOException, InterruptedException, ArchiveException, URISyntaxException
{
Expand Down Expand Up @@ -178,8 +178,8 @@ public Conda() throws IOException, InterruptedException, ArchiveException, URISy
* If the current thread is interrupted by another thread while it
* is waiting, then the wait is ended and an InterruptedException is
* thrown.
* @throws ArchiveException
* @throws URISyntaxException
* @throws ArchiveException if there is any error decompressing the micromamba files
* @throws URISyntaxException if the micromamba install link is wrong or does not work or there is no internet connection
*/
public Conda( final String rootdir ) throws IOException, InterruptedException, ArchiveException, URISyntaxException
{
Expand Down Expand Up @@ -784,6 +784,8 @@ public void runConda(Consumer<String> consumer, final String... args ) throws Ru
* One or more arguments for the Conda command.
* @throws IOException
* If an I/O error occurs.
* @throws RuntimeException
* If the Conda command does not run properly
* @throws InterruptedException
* If the current thread is interrupted by another thread while it
* is waiting, then the wait is ended and an InterruptedException is
Expand Down Expand Up @@ -876,6 +878,15 @@ public List< String > getEnvironmentNames() throws IOException
return envs;
}

/**
* TODO
* Check whether an environment has the wanted deps installed
* @param envDir
* directory of the environment
* @param dependencies
* lsit of wanted deps
* @return true if the wanted deps are installed or false otherwise
*/
public static boolean checkDependenciesInEnv(String envDir, List<String> dependencies) {
if (!(new File(envDir).isDirectory()))
return false;
Expand All @@ -884,6 +895,13 @@ public static boolean checkDependenciesInEnv(String envDir, List<String> depende
return false;
}

/**
* TODO
* Check the environment defined by this yaml file exists
* @param envYaml
* path to the Conda/Mamba env yaml file
* @return true if it exists and false otherwise
*/
public boolean checkEnvFromYamlExists(String envYaml) {
if (envYaml == null || new File(envYaml).isFile() == false
|| (envYaml.endsWith(".yaml") && envYaml.endsWith(".yml"))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public interface Environment {
* </p>
*
* @return The newly created service.
* @see #groovy To create a service for Groovy script execution.
* @throws IOException If something goes wrong starting the worker process.
*/
default Service python() throws IOException {
Expand Down Expand Up @@ -125,7 +124,6 @@ default Service java(String mainClass, List<String> classPath,
* @param args Command line arguments to pass to the worker process
* (e.g. <code>{"-v", "--enable-everything"}</code>.
* @return The newly created service.
* @see #groovy To create a service for Groovy script execution.
* @see #python() To create a service for Python script execution.
* @throws IOException If something goes wrong starting the worker process.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ public static void unBZip2(File source, File destination) throws FileNotFoundExc
*
* @param inputFile the input .tar file
* @param outputDir the output directory file.
* @throws IOException
* @throws FileNotFoundException
* @throws ArchiveException
* @throws IOException reding, writting or creating the target or source files
* @throws FileNotFoundException if the file that needs to be untared is not found
* @throws ArchiveException if there is any error decompressing the tar file
*/
public static void unTar(final File inputFile, final File outputDir) throws FileNotFoundException, IOException, ArchiveException {

Expand Down Expand Up @@ -126,6 +126,15 @@ public static void unTar(final File inputFile, final File outputDir) throws File

}

/**
* Example main method
* @param args
* no args are required
* @throws FileNotFoundException if some file is not found
* @throws IOException if there is any error reading or writting
* @throws ArchiveException if there is any error decompressing
* @throws URISyntaxException if the url is wrong or there is no internet connection
*/
public static void main(String[] args) throws FileNotFoundException, IOException, ArchiveException, URISyntaxException {
String url = Conda.MICROMAMBA_URL;
final File tempFile = File.createTempFile( "miniconda", ".tar.bz2" );
Expand Down Expand Up @@ -156,11 +165,9 @@ public static void main(String[] args) throws FileNotFoundException, IOException
* has been redirected
* @param url
* original url. Connecting to that url must give a 301, 302 or 303 response code
* @param conn
* connection to the url
* @return the redirected url
* @throws MalformedURLException
* @throws URISyntaxException
* @throws MalformedURLException if the url does not fulfil the requirements for an url to be correct
* @throws URISyntaxException if the url is incorrect or there is no internet connection
*/
public static URL redirectedURL(URL url) throws MalformedURLException, URISyntaxException {
int statusCode;
Expand Down

0 comments on commit b736953

Please sign in to comment.