-
Notifications
You must be signed in to change notification settings - Fork 27
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
Proposal, add new top level environment
field to manifest
#163
Comments
At a high level I really like this idea. I think its a good way to move the community towards standardization and cross compatibility, while also allowing development to occur outside of this approach if there is strong need
I'm also ok with the optimistic approach. If something breaks because people aren't using I wouldn't require, but would also be happy if this plugin style of plugin were to live in napari GitHub org, so at
Something that wasn't clear to me is if they are using
I'm curious @tlambert03 @nclack if you have ideas about other environments we might want? |
my understanding is that if plugin A and plugin B both need to provide a classpath added to the JVM when it starts, then if plugin A just started the JVM via napari-scyjava, then scyjava needs some way to know that plugin B also existed, and include their required paths as well on startup... |
Yup, this is right. By and large, I think this is a nice plan. I have a couple of questions.
|
just a library for now. you're correct, it would only need to be a plugin if it required an activation event.
correct, there is currently no option for activating "on startup"
I leave that to you guys to decide. From our perspective, we'll gather some static metadata and hand it to whoever asks for it. You (the java community) can agree on what that thing is. |
I'm sure @ctrueden and I will just use scyjava. Just wanted to see if you napari guys had an opinion! |
It does not: >>> import scyjava
>>> scyjava.start_jvm()
>>> System = scyjava.jimport('java.lang.System')
>>> System.getProperty('java.class.path')
'' The scyjava project is (ironically) not intended to be "SciJava-specific". Maybe we should rename it.
Why not call it
👍 👍
Hmm, I hadn't thought about that... but then, later we want napari-scyjava (or napari-java or whatever we call it) to provide an option in napari for setting the path to the JVM, so that was going to be another reason for napari-java to exist. So then, if we're going to need a napari-java plugin anyway, why not also leverage the npe2 manifest infrastructure, rather than me needing to implement some other parallel discovery mechanism in scyjava itself? |
Here is a summary I wrote up after today's discussion: How we want to do Java-based plugins from napari in general such that they can work together, register Maven artifacts for a common classpath, etc.
|
Oh, good. I just assumed that it was leaning on scyjava because some of the utility functions import
Can we do that? It's already post 1.0...
I like
Hmm, I don't think you need a plugin to do this. It was my impression that @tlambert03 planned support for somehting like this without the need for a plugin. But I might be misremembering... |
My main question will be again:
Talley respond to some concern in #163 (comment) above, But the problem I see is that if a library want to opt-in to say exposing a java call path, they have to opt-in in npe2 manifest and potentially have npe2 as a dependency. So really I think that adding this in manifest is removing a lot of potential flexibility, and does actually cut standardisation possibilities.
I would be much more incline to bake some understanding of entry_points in npe2, so that you could use npe2 to list values in entry_points than in manifest file. For example a "please re-expose those entry points" key/values pair. For me this is a similar problem than folks asking for package requirements of notebook files to be put in notebooks. It's great if Jupyter support it and auto-install packages, but that forces conda, pip, and many other tools to bake knowledge of Jupyter in them. |
@Carreau I'm willing to bake in a discovery mechanism to scyjava, but am not a Python software ecosystem expert, so would need some advice on how best to make scyjava discover all requested Java classpath elements. E.g. the scyjava library, before starting Java, could walk through everything under My questions about this approach would be:
|
And a third question:
Edit: I guess if |
That would be https://packaging.python.org/en/latest/specifications/core-metadata/ Which can be queried at runtime with importlib.metadata https://docs.python.org/3/library/importlib.metadata.html entry_points are typically used to point to a module or something, and they are often used as a plugin discovery mechanism. It's what we use in npe2 to find all of the napari.yaml manifests in the environment. You could conceivably use that mechanism to gather this info (though it's really designed to point to a python namespace, not so much a generic string) |
@tlambert03 Awesome! That sounds very appropriate, and I love that it's part of the standard library. I'll try to dig into it soon. |
Kinda wonder whether Requires-External could be "abused" for this?
|
Had a very fruitful chat with @ctrueden about how to address #136 and #149 and have a new proposal for how to move forward.
Summary of challenge:
Some plugins will need to agree/communicate about shared resources, such as singletons (think Java virtual machine or QApp). Without communication/agreement, one plugin has the ability to accidentally break another plugin by being the first to "claim" or initialize the shared resource (for example: the first to call
jpype.startJVM
gets to set the classpaths).Proposal:
environment
field in the manifest that can be populated with subfields (such asjvm_classpath
)napari-scyjava
would be a very thin package that just queries the classpaths gathered by npe2 and initializes the JVM accordingly with scyjavanapari-scyjava
, rather than directly callingjpype.startJVM
Example manifest
Potential problems with this proposal
Assuming we stick with the lazy activation pattern (meaning a plugin is only imported when a user requests functionality from that plugin), this still means that a "rogue" plugin could be activated/called first, breaking all the other plugins. This will most likely pop up as a bug report either to napari or to a "well-behaving" plugin like
napari-imagej
.We could "fix" this possibility by having napari-scyjava use an "on-startup" activation event to make sure that that package is poised. (This might involve actually
jpype.startJVM
... with potential unintended side-effects ... but maybe not.). If we enable on-startup activation though, then we need to implement more tooling to i) allow users to opt-in to that activation and ii) make clear what is breaking if an exception occurs.@ctrueden suggests we start with the optimistic approach: just document the preferred pattern well, and encourage people to use scyjava – moving to more aggressive fixes only if bugs start popping up.
Alternate proposals
#149 proposed adding a
properties
field that would allow arbitrary key/value fields that could follow various conventions. The benefit there is that communities could iterate without any involvement fromnpe2
(since keys/values are not validate). The problem though is that keys and values are not validated 😆 ... so it has the potential for abuse and is harder to impose correctness. By providing an explicitjvm_classpath
field in theenvironment
section here, we do take on some domain awareness... but we don't expect this to happen terribly often (maybe again for R, or julia, or something like that...)Feedback requested
CC @ctrueden, @gselzer, @nclack, @Carreau, @jni, @sofroniewn
The text was updated successfully, but these errors were encountered: