Skip to content

Commit a36b6c1

Browse files
committed
Flesh out Op Searching doc
Add some info on creating an OpEnvironment and add more words to clarify API usage.
1 parent bab193d commit a36b6c1

1 file changed

Lines changed: 38 additions & 25 deletions

File tree

docs/ops/doc/SearchingForOps.md

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
11
# Searching for Ops in the Environment
22

3-
As the `OpEnvironment` is fully extensible, different `OpEnvironment`s might contain different Ops, and it is important to be able to query an `OpEnvironment` about the available Ops.
3+
The first step when workin with Ops is always to obtain an `OpEnvironment`: your gateway to all Ops functionality.
44

5-
The `OpEnvironment.help()` API allows you to query an `OpEnvironment` about the types of Ops it contains, as we show in the following sections. **Note that the example printouts from the help API may not reflect the Ops available in *your* Op environment**.
5+
If you're working in a [Fiji script](ScriptingInFiji) then this is done with a script parameter:
66

7-
## Searching for operations
7+
```
8+
#@ OpEnvironment ops
9+
```
810

9-
The no-argument method `OpEnvironment.help()` is designed to give you a broad overview over the *categories* of Ops available within the `OpEnvironment`:
11+
Otherwise we can import and build one ourselves:
1012

11-
```groovy
13+
```
1214
import org.scijava.ops.api.OpEnvironment
1315
ops = OpEnvironment.build()
16+
```
17+
18+
Typically we would only want to do this once per application, to avoid diverging environments and recurring the performance cost of the build. All code examples in this section will assume we have created an `OpEnvironment` named `ops`.
19+
20+
As the `OpEnvironment` is fully extensible, different `OpEnvironment`s might contain different Ops, so it is important to be able to query an `OpEnvironment` about its available Ops. We also need to be able to get information about the usage of these Ops, to know what parameters may be required.
21+
22+
The `OpEnvironment.help()` API is your window into the `OpEnvironment`. In the following sections we cover the different types of information that can be obtained. **Note that the exact printouts from the help API may be different from the Ops available in *your* environment**.
1423

24+
## Listing Namespaces
25+
26+
The no-argument method `OpEnvironment.help()` is designed to give you a broad overview over the *categories* (namespaces) of Ops available within the `OpEnvironment`:
27+
28+
```
1529
print(ops.help())
1630
```
1731

18-
This gives the following printout:
32+
Might print output such as:
1933

20-
```
34+
```text
2135
Namespaces:
2236
> coloc
2337
> convert
@@ -45,19 +59,18 @@ Namespaces:
4559
> types
4660
```
4761

48-
## Interrogating a Namespace
62+
These namespace categories can then be interrogated further to explore the particular Ops in each.
4963

50-
You can choose one of the above namespaces, and `ops.help()` will give you information about the algorithms contained within:
51-
```groovy
52-
import org.scijava.ops.api.OpEnvironment
53-
ops = OpEnvironment.build()
64+
## Querying a Namespace
5465

66+
You can choose one of the above namespaces, and `ops.help()` will give you information about the algorithms contained within:
67+
```
5568
print(ops.help("filter"))
5669
```
5770

58-
This gives the following printout:
71+
Prints the current list of `filter` ops in the `OpEnvironment`:
5972

60-
```
73+
```text
6174
Names:
6275
> filter.dog
6376
> filter.addNoise
@@ -96,35 +109,33 @@ Names:
96109
> filter.variance
97110
```
98111

99-
## Signatures for Op Names
112+
## Querying Op Signatures
100113

101114
Finally, you can use `OpEnvironment.help()` on any Op name to see the list of signatures:
102115

103-
```groovy
104-
import org.scijava.ops.api.OpEnvironment
105-
ops = OpEnvironment.build()
106-
116+
```
107117
print(ops.help("filter.gauss"))
108118
```
109119

110-
```
120+
```text
111121
filter.gauss:
112122
- (input, sigmas, @CONTAINER container1) -> None
113123
- (input, sigmas, outOfBounds = null, @CONTAINER container1) -> None
114124
- (input, sigma, @CONTAINER container1) -> None
115125
- (input, sigma, outOfBounds = null, @CONTAINER container1) -> None
116126
```
117127

118-
Note that these descriptions are simple, and you can obtain more verbose descriptions by instead using the method `OpEnvironment.helpVerbose()`:
128+
## In-depth Op Information
119129

120-
```groovy
121-
import org.scijava.ops.api.OpEnvironment
122-
ops = OpEnvironment.build()
130+
The basic descriptions from `OpEnvironment.help()` are intentionally simplified to avoid providing overwhelming amounts of information. However, you can obtain more complete descriptions, including documentation (if available), from `OpEnvironment.helpVerbose()`:
123131

132+
```
124133
print(ops.helpVerbose("filter.gauss"))
125134
```
126135

127-
```
136+
Gives us actual typing and usage notes for the parameters:
137+
138+
```text
128139
filter.gauss:
129140
- org.scijava.ops.image.filter.gauss.Gaussians.defaultGaussRAI(net.imglib2.RandomAccessibleInterval<I>,double[],net.imglib2.outofbounds.OutOfBoundsFactory<I, net.imglib2.RandomAccessibleInterval<I>>,net.imglib2.RandomAccessibleInterval<O>)
130141
> input : net.imglib2.RandomAccessibleInterval<I>
@@ -147,3 +158,5 @@ filter.gauss:
147158
> container1 : @CONTAINER net.imglib2.RandomAccessibleInterval<O>
148159
the preallocated output image
149160
```
161+
162+
`OpEnvironment.helpVerbose()` can be used interchangeably whenever you would use `OpEnvironment.help()`, as needed.

0 commit comments

Comments
 (0)