Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable temporary directory when running macros #129

Open
k-dominik opened this issue Nov 18, 2024 · 4 comments
Open

Configurable temporary directory when running macros #129

k-dominik opened this issue Nov 18, 2024 · 4 comments

Comments

@k-dominik
Copy link
Contributor

k-dominik commented Nov 18, 2024

Use-case

When running ilastik via the Fiji plugin in BARD, it is desirable to run ilastik from a different container (to avoid duplication). The plugin writes temporary files per default into /tmp on linux, which is inside the container - so that plugin in and ilastik cannot exchange data.

A solution would be to write to a path in the home folder that is mounted on both the Fiji and the ilastik container

path = Files.createTempDirectory(Objects.requireNonNull(prefix));

I tried

  • setting env variables TMP, TEMP, TMP_DIR but it doesn't have an effect
  • stating fiji passing the option to the jvm: ImageJ-macosx -- -Djava.io.tempdir=/Users/kutra/scratch but also no effect

cc: @sunyi000

@emilmelnikov
Copy link
Member

emilmelnikov commented Nov 18, 2024

Setting java.io.tmpdir should definitely work. I tried to run the following test program:

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class TempDirExample {

    public static void main(String[] args) {
        // Get the value of the "java.io.tmpdir" system property
        String tmpdir = System.getProperty("java.io.tmpdir");
        System.out.println("Temporary directory path (java.io.tmpdir): " + tmpdir);
        
        // Create a temporary directory and handle potential IOExceptions
        try {
            // Create a temporary directory
            Path tempDirectory = Files.createTempDirectory("myTempDirPrefix");
            
            // Print the path of the created temporary directory
            System.out.println("Temporary directory created at: " + tempDirectory.toString());
            
        } catch (IOException e) {
            // Handle any I/O error that might occur
            System.err.println("Error while creating a temporary directory: " + e.getMessage());
        }
    }
}
$ java TempDirExample.java
Temporary directory path (java.io.tmpdir): /var/folders/9p/b9r84sb110l14gcn7_3qd4p00000gn/T/
Temporary directory created at: /var/folders/9p/b9r84sb110l14gcn7_3qd4p00000gn/T/myTempDirPrefix12787915166943295779

$ mkdir mytmpdir
$ java -Djava.io.tmpdir=$(realpath mytmpdir) TempDirExample.java
Temporary directory path (java.io.tmpdir): /Users/em/projects/mytmpdir
Temporary directory created at: /Users/em/projects/mytmpdir/myTempDirPrefix11257023116559662220

I suspect that either ImageJ-macosx wrapper script doesn't pass arguments to java, or ImageJ messes with this property itself.

@k-dominik
Copy link
Contributor Author

Hi @emilmelnikov,

thank you so much for looking into this. I guess then I'll try zulip with the Fiji team...

@k-dominik
Copy link
Contributor Author

k-dominik commented Nov 19, 2024

./ImageJ-macosx -Djava.io.tmpdir=/Users/kutra/scratch -- (I had the order wrong (option before the -- and also an extra e in tmpdir...) will set the temporary directory correctly (thank you @ctrueden). @sunyi000, would this work for your use-case?

@sunyi000
Copy link

./ImageJ-macosx -Djava.io.tmpdir=/Users/kutra/scratch -- (I had the order wrong (option before the -- and also an extra e in tmpdir...) will set the temporary directory correctly (thank you @ctrueden). @sunyi000, would this work for your use-case?

I will test it out. I think this could fix it. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants