Skip to content

Let descriptions method operate on entire namespaces #136

Closed

Description

@elevans

Context: Jython script

Suppose I want to run a gaussian blur on an net.imglib2.img.Img but I don't know the op signature filter.gauss. Let's say that I know that the gaussian blur op is in the filter namespace but I'm unsure if its gauss or gaussian. In this scenario it would be great to have a mechanism to return all ops in a given namespace.

Current behavior:

# get op environment
from org.scijava.ops.api import OpEnvironment
ops = OpEnvironment.getEnvironment()

print(ops.descriptions("filter"))

Output:

[]

Proposed behavior:

# get op environment
from org.scijava.ops.api import OpEnvironment
ops = OpEnvironment.getEnvironment()

print(ops.descriptions("filter"))

Output:

[filter.addNoise(), filter.bilateral(), filter.convolve(), filter.gauss(), filter.hessian(), filter.ifft(), filter.max(), ...]

With this behavior I can easily find that the op signature I want in the filter namespace is filter.gauss(). I don't think we need to return all the possible input parameters for the ops as that will create an unruly list. Instead I think just returning the signature is fine. The user can get the description of the specific op for parameter information if they desire.

Activity

  1. changed the title [-]Improving searching/discovery for Ops[/-] [+]Improve searching/discovery for Ops[/+] on Sep 26, 2023
  2. changed the title [-]Improve searching/discovery for Ops[/-] [+]Improve Op searching/discovery[/+] on Sep 26, 2023
  3. added this to the 1.0.0 milestone on Sep 26, 2023
  4. changed the title [-]Improve Op searching/discovery[/-] [+]Lets descriptions method operate on entire namespaces[/+] on Sep 26, 2023
  5. ctrueden commented on Sep 26, 2023

    @ctrueden
    Member

    For more advanced cases like substring searching, you could do ops.descriptions().stream().filter(...). I.e., let's not make the descriptions function too clever. I think only the following cases should work:

    • ops.descriptions("ns.op") – i.e. the fully qualified name of the op with namespace
    • ops.descriptions("ns") – i.e. the namespace name alone
    • ops.descriptions("op") – i.e. the short name of the op
    • ops.descriptions() – i.e. all ops
  6. changed the title [-]Lets descriptions method operate on entire namespaces[/-] [+]Let descriptions method operate on entire namespaces[/+] on Nov 16, 2023
  7. ctrueden commented on Nov 16, 2023

    @ctrueden
    Member

    Another possibility would be to support the wildcard symbol * to match as a glob.

  8. gselzer commented on Nov 16, 2023

    @gselzer
    Member

    Here's my opinions:

    • ops.descriptions() returning all Ops would be too much to read. What if we just return the namespace?
    ops.help()
    >> namespaces: ["create", "filter", ...]
    >> names: [
    

    Implementation-wise, I think that the following is the way to go:

    Set<String> set = new HashSet<>();
    for (String s : opNames) {
      String prefix = s.substring(s.indexOf('.')); // if no dot then the whole thing
      set.add(prefix)
    }
    • ops.descriptions(String name) will return:
      • First, each name contained within the namespace, like @elevans suggested in the initial comment.
      • Below that, all Ops named name.
    ops.help("create")
    
    >> namespaces: ['create.img', 'create.type', ... ]
    >> create( input: RAI<.....)
    

    We probably also want to return a single string, not a List<String>.

  9. gselzer commented on Nov 28, 2023

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions