GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Accessing an environment in a platform independent way. · Issue #2 · scijava/scripting-appose-python

Accessing an environment in a platform independent way. #2

New issue
Copy link
New issue
Copy link
Open
Open
Accessing an environment in a platform independent way.#2
Copy link

Description

@odinsbane
odinsbane
opened on Nov 5, 2026
Issue body actions

If I want to run a script, then I need to know the environment.

#@script(env="/Users/username/.local/share/appose/fiji-cellpose/pixi.toml")

import cellpose
from cellpose import models
import numpy

#@Img image
#@output Img masks
#@output Img flows
print(image.shape)
print(numpy.sum(image))
model = models.CellposeModel(gpu=True)
masks, flows, _ = model.eval(image, z_axis=0, do_3D=False, normalize=True, diameter=150)

flows = flows[0]
flows = numpy.rollaxis(flows, -1)

This works, but I know the existence of the pixi.toml. I could also build an environment using the following java program.

import org.apposed.appose.*;
import java.util.*;

public class ApposeBuilder{
    //Toml to create a cellpose environment.
    static final String toml = """
[workspace]
    authors = [
                "Smith, MB",     
                ]
    channels = ["conda-forge"]
    name = "example-appose"
    platforms = ["osx-arm64", "win-64", "linux-64", "osx-64"]
    version = "0.1.0"
                
                [dependencies]
                python = ">3.10.3"
                
                [pypi-dependencies]
                cellpose = ">=4"
                appose = ">=0.10.1"
""";
    final static String command = """
import cellpose, sys, pathlib

ex = pathlib.Path(sys.executable)
#I could use this value with "wrap"
env = ex.parent.parent
#I can use this value with script parameter.
toml = env.parent.parent.parent / "pixi.toml"
"%s"%(toml, )
""";

	public static void main(String[] args) throws Exception{
	    try( Service python = Appose.pixi().content(toml).build().python() ){
            Map<String, Object> inputs = new HashMap<>();
            Service.Task task = python.task(command, inputs);
            task.start();
            task.waitFor();
            System.out.println(task.result());
        } 
	}
}

If I run that java program, then I will have a python environment with cellpose, and I know the location of the the pixi.toml that I need to point the script engine at. It would be nice if there was a consistent, platform independent way of naming/referencing an environment.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.