Skip to content

Commit 7c0e85e

Browse files
committed
Update PythonEnvironmentManagerUI and ApposeUtils to use Appose builders for environment configuration
* This is to reflect cellpose3, cellpose4 and stardist use pixi and trackastra uses mamba
1 parent 50a7736 commit 7c0e85e

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

src/main/java/org/mastodon/mamut/util/appose/ApposeUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import javax.swing.SwingUtilities;
4747

4848
import org.apache.commons.lang3.tuple.Pair;
49-
import org.apposed.appose.Appose;
49+
import org.apposed.appose.Builder;
5050
import org.apposed.appose.builder.Builders;
5151
import org.apposed.appose.util.Environments;
5252
import org.mastodon.mamut.util.ByteFormatter;
@@ -71,9 +71,9 @@ private ApposeUtils()
7171
* to set up the environment.
7272
* @throws IOException If an I/O error occurs during the installation process.
7373
*/
74-
public static void installEnvironment( final String envContent ) throws IOException
74+
public static void installEnvironment(final String envContent, final Builder<?> envBuilder) throws IOException
7575
{
76-
Appose.mamba().content( envContent ).scheme( "environment.yml" ).logDebug().rebuild();
76+
envBuilder.content( envContent ).logDebug().rebuild();
7777
}
7878

7979
/**

src/main/java/org/mastodon/mamut/util/appose/PythonEnvironmentManagerUI.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060

6161
import net.miginfocom.swing.MigLayout;
6262

63+
import org.apposed.appose.Appose;
64+
import org.apposed.appose.Builder;
6365
import org.apposed.appose.util.Environments;
6466
import org.mastodon.app.MastodonIcons;
6567
import org.mastodon.mamut.detection.cellpose.Cellpose3;
@@ -104,10 +106,10 @@ public PythonEnvironmentManagerUI( JFrame owner )
104106
private void initEnvironmentPanels()
105107
{
106108
environmentPanels = new ArrayList<>();
107-
environmentPanels.add( new EnvironmentPanel( Cellpose3.ENV_NAME, Cellpose3.ENV_FILE_CONTENT ) );
108-
environmentPanels.add( new EnvironmentPanel( Cellpose4.ENV_NAME, Cellpose4.ENV_FILE_CONTENT ) );
109-
environmentPanels.add( new EnvironmentPanel( StarDist.ENV_NAME, StarDist.ENV_FILE_CONTENT ) );
110-
environmentPanels.add( new EnvironmentPanel( TrackastraUtils.ENV_NAME, TrackastraUtils.ENV_FILE_CONTENT ) );
109+
environmentPanels.add( new EnvironmentPanel( Cellpose3.ENV_NAME, Cellpose3.ENV_FILE_CONTENT, Appose.pixi() ) );
110+
environmentPanels.add( new EnvironmentPanel( Cellpose4.ENV_NAME, Cellpose4.ENV_FILE_CONTENT, Appose.pixi() ) );
111+
environmentPanels.add( new EnvironmentPanel( StarDist.ENV_NAME, StarDist.ENV_FILE_CONTENT, Appose.pixi() ) );
112+
environmentPanels.add( new EnvironmentPanel( TrackastraUtils.ENV_NAME, TrackastraUtils.ENV_FILE_CONTENT, Appose.mamba().scheme( "environment.yml" ) ) );
111113
}
112114

113115
private void initLayout()
@@ -163,6 +165,8 @@ private class EnvironmentPanel extends JPanel
163165

164166
private final String envContent;
165167

168+
private final Builder< ? > envBuilder;
169+
166170
private final JLabel statusIcon;
167171

168172
private final JLabel statusLabel;
@@ -173,11 +177,12 @@ private class EnvironmentPanel extends JPanel
173177

174178
private final JLabel sizeValueLabel;
175179

176-
private EnvironmentPanel( String envName, String envContent )
180+
private EnvironmentPanel( final String envName, final String envContent, final Builder< ? > envBuilder )
177181
{
178182
super( new MigLayout( "fill, insets 8", "[][80!][grow][]", "[]5[]5[]" ) );
179183
this.envName = envName;
180184
this.envContent = envContent;
185+
this.envBuilder = envBuilder;
181186

182187
statusIcon = new JLabel();
183188
statusLabel = new JLabel();
@@ -358,7 +363,7 @@ private void installEnvironmentUI()
358363
() -> {
359364
try
360365
{
361-
ApposeUtils.installEnvironment( envContent );
366+
ApposeUtils.installEnvironment( envContent, envBuilder );
362367
}
363368
catch ( IOException e )
364369
{

src/test/java/org/mastodon/mamut/util/appose/ApposeUtilsTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import java.nio.charset.StandardCharsets;
3939
import java.nio.file.Files;
4040

41+
import org.apposed.appose.Appose;
42+
import org.apposed.appose.Builder;
4143
import org.junit.jupiter.api.Test;
4244

4345
class ApposeUtilsTest
@@ -51,8 +53,9 @@ void testInstallDeleteExistsSize() throws IOException
5153
+ " - conda-forge\n"
5254
+ "dependencies:\n"
5355
+ " - python=3.10\n";
56+
Builder<?> envBuilder = Appose.mamba().scheme( "environment.yml" );
5457

55-
ApposeUtils.installEnvironment( testEnvContent );
58+
ApposeUtils.installEnvironment( testEnvContent, envBuilder );
5659
assertTrue( ApposeUtils.checkEnvironmentInstalled( testEnvName ) );
5760
String size = ApposeUtils.calculateEnvironmentSize( testEnvName );
5861
String numberPart = size.split( " " )[ 0 ]; // "123,4"

0 commit comments

Comments
 (0)