Skip to content

Commit

Permalink
Add new test for a variation on nv-morpheus#360 when a module has bee…
Browse files Browse the repository at this point in the history
…n loaded and added to the segment [no ci]
  • Loading branch information
dagardner-nv committed Jan 22, 2024
1 parent c9eccac commit 66d3b07
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions python/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import pytest

import mrc
# Required to register sample modules with the ModuleRegistry
import mrc.tests.sample_modules
import mrc.tests.test_edges_cpp as m

# from mrc.core.options import PlacementStrategy
Expand Down Expand Up @@ -484,10 +486,64 @@ def on_next(input):
executor.join()


def test_module_init_error():
"""
Test for variation on issue #360 where the error is raised in the module init function
Reproduces Morpheus issue #953
"""

def gen_data():
for i in range(10):
yield i

def init(builder: mrc.Builder):

def on_next(input):
pass

def on_error():
pass

def on_complete():
pass

config = {"config_key_1": True}

registry = mrc.ModuleRegistry

source1 = builder.make_source("src1", gen_data)
source2 = builder.make_source("src2", gen_data)
fn_constructor = registry.get_module_constructor("SimpleModule", "mrc_unittest")
simple_mod = fn_constructor("ModuleInitializationTest_mod2", config)
sink = builder.make_sink("sink", on_next, on_error, on_complete)

builder.init_module(simple_mod)
builder.make_edge(source1, simple_mod.input_port("input1"))
builder.make_edge(source2, simple_mod.input_port("input2"))
builder.make_edge(simple_mod.output_port("output1"), sink)
builder.make_edge(simple_mod.output_port("output2"), sink)

raise RuntimeError("Test for #360")

pipe = mrc.Pipeline()

pipe.make_segment("segment", init)

options = mrc.Options()

executor = mrc.Executor(options)
executor.register_pipeline(pipe)

with pytest.raises(RuntimeError):
executor.start()
executor.join()


if (__name__ in ("__main__", )):
test_dynamic_port_creation_good()
test_dynamic_port_creation_bad()
test_ingress_egress_custom_type_construction()
test_dynamic_port_get_ingress_egress()
test_dynamic_port_with_type_get_ingress_egress()
test_segment_init_error()
test_module_init_error()

0 comments on commit 66d3b07

Please sign in to comment.