Skip to content

Commit c1395ee

Browse files
committed
Make use of Conditiontype.None to support dangling outputs
Signed-off-by: M Q <mingmelvinq@nvidia.com>
1 parent f81c905 commit c1395ee

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

examples/apps/simple_imaging_app/gaussian_operator.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from skimage.filters import gaussian
1515
from skimage.io import imsave
1616

17-
from monai.deploy.core import Operator, OperatorSpec
17+
from monai.deploy.core import ConditionType, Operator, OperatorSpec
1818

1919

2020
# If `pip_packages` is specified, the definition will be aggregated with the package dependency list of other
@@ -29,19 +29,22 @@ class GaussianOperator(Operator):
2929
DEFAULT_OUTPUT_FOLDER = Path.cwd() / "output"
3030

3131
def __init__(self, *args, output_folder: Path, **kwargs):
32+
self.output_folder = output_folder if output_folder else GaussianOperator.DEFAULT_OUTPUT_FOLDER
33+
self.index = 0
34+
3235
# If `self.sigma_default` is set here (e.g., `self.sigma_default = 0.2`), then
3336
# the default value by `param()` in `setup()` will be ignored.
3437
# (you can just call `spec.param("sigma_default")` in `setup()` to use the
3538
# default value)
36-
self.output_folder = output_folder if output_folder else GaussianOperator.DEFAULT_OUTPUT_FOLDER
37-
self.index = 0
39+
self.sigma_default = 0.2
40+
self.channel_axis = 2
3841

3942
# Need to call the base class constructor last
4043
super().__init__(*args, **kwargs)
4144

4245
def setup(self, spec: OperatorSpec):
4346
spec.input("in1")
44-
# spec.output("out1") # Cannot have a output without having downstream receiver
47+
spec.output("out1").condition(ConditionType.NONE) # This condition type allows for no or not-ready receiver.
4548
spec.param("sigma_default", 0.2)
4649
spec.param("channel_axis", 2)
4750

@@ -57,4 +60,4 @@ def compute(self, op_input, op_output, context):
5760
output_path = self.output_folder / "final_output.png"
5861
imsave(output_path, data_out)
5962

60-
# op_input.emit(data_out, "out1") # CANNOT emit a dangling output!!!
63+
op_output.emit(data_out, "out1")

0 commit comments

Comments
 (0)