Skip to content
This repository was archived by the owner on Oct 26, 2026. It is now read-only.

Wrap Numpy in Ops - #68

Closed
gselzer wants to merge 4 commits into
mainfrom
scijava/scijava-ops-python/init
Closed

gselzer wants to merge 4 commits into
mainfrom
scijava/scijava-ops-python/init

Conversation

@gselzer

@gselzer gselzer commented Dec 28, 2022

Copy link
Copy Markdown
Member

This PR is a hacky first cut at exposing Python functionality through Ops.

Fundamentally, Python access is provided through jep. This PR creates a single jep.Interpreter, configured within a utility class. This ensures that we have control over the configuration, and only have to do it once (although there is still more configuration that needs to be done.)

Ops themselves are declared in the ops.yaml resource file, and are discovered by an extension of the YAMLOpInfoDiscoverer created in #67. The discovered PythonOpInfos use javassist to create a FunctionalInterface implementation that:

  • Transfers the input data into Python
  • Executes the Python functionality
  • Transfers the output data from Python

What this PR does (currently):

  • Shows what it might look like to wrap Python functionality in Ops
  • Creates the foundations for actually wrapping it

What this PR doesn't do:

  • Wrap NumPy extensively - it includes only a couple of functions as a proof-of-concept. We'd eventually want to come up with a way (Python script?) to automate the YAML generation, and also to provide a configuration mechanism (especially aliases - I think it would be nice to e.g. alias numpy.zeros to create.img, numpy.add to math.add, etc.). It might also be cool to add a LANGUAGE preference to Hints.
  • Access Python cleanly - there are many bugs in this code, and it is very much a draft.
  • Add any conversions - we can only call Python Ops on Python data structures, which, right now isn't very much.

Benefits to this approach:

  • It's internal to Java - Java users get access to Python!

Drawbacks to this approach:

  • We do not (currently) share/use any scyjava functionality - the converters, especially, could be useful for simplification fallbacks. It might be a good idea to port the scyjava conversion functionality to ops somewhere down the line, if we like this approach.

@gselzer gselzer added the enhancement New feature or request label Dec 28, 2022
@gselzer
gselzer requested review from ctrueden and hinerm December 28, 2022 19:47
@gselzer gselzer self-assigned this Dec 28, 2022
@gselzer
gselzer force-pushed the scijava/scijava-ops-python/init branch from 81b4961 to 5553012 Compare January 6, 2023 20:46
@ctrueden

ctrueden commented May 2, 2024

Copy link
Copy Markdown
Member

This branch will continue in https://github.com/scijava/scijava. For now: closed!

@ctrueden ctrueden closed this May 2, 2024
@ctrueden
ctrueden deleted the scijava/scijava-ops-python/init branch May 2, 2024 19:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

Development

Successfully merging this pull request may close these issues.

2 participants