You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ops/doc/SearchingForOps.md
+38-25Lines changed: 38 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,37 @@
1
1
# Searching for Ops in the Environment
2
2
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 Opsis always to obtain an `OpEnvironment`: your gateway to all Ops functionality.
4
4
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:
6
6
7
-
## Searching for operations
7
+
```
8
+
#@ OpEnvironment ops
9
+
```
8
10
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:
10
12
11
-
```groovy
13
+
```
12
14
import org.scijava.ops.api.OpEnvironment
13
15
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**.
14
23
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
+
```
15
29
print(ops.help())
16
30
```
17
31
18
-
This gives the following printout:
32
+
Might print output such as:
19
33
20
-
```
34
+
```text
21
35
Namespaces:
22
36
> coloc
23
37
> convert
@@ -45,19 +59,18 @@ Namespaces:
45
59
> types
46
60
```
47
61
48
-
## Interrogating a Namespace
62
+
These namespace categories can then be interrogated further to explore the particular Ops in each.
49
63
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
54
65
66
+
You can choose one of the above namespaces, and `ops.help()` will give you information about the algorithms contained within:
67
+
```
55
68
print(ops.help("filter"))
56
69
```
57
70
58
-
This gives the following printout:
71
+
Prints the current list of `filter` ops in the `OpEnvironment`:
59
72
60
-
```
73
+
```text
61
74
Names:
62
75
> filter.dog
63
76
> filter.addNoise
@@ -96,35 +109,33 @@ Names:
96
109
> filter.variance
97
110
```
98
111
99
-
## Signatures for Op Names
112
+
## Querying Op Signatures
100
113
101
114
Finally, you can use `OpEnvironment.help()` on any Op name to see the list of signatures:
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
119
129
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()`:
123
131
132
+
```
124
133
print(ops.helpVerbose("filter.gauss"))
125
134
```
126
135
127
-
```
136
+
Gives us actual typing and usage notes for the parameters:
0 commit comments