def test_TopologyTransformCallableAddWithDrop(self): topo = Topology("test_TopologyTransformCallableAddWithDrop") source = topo.source(test_functions.int_strings_transform_with_drop) i1 = source.transform(test_functions.string_to_int_except68) i2 = i1.transform(test_functions.AddNum(17)) i2.sink(test_functions.check_int_strings_transform_with_drop) standalone(self, topo)
def test_TopologyTransform(self): topo = Topology("test_TopologyTransform") source = topo.source(test_functions.int_strings_transform) i1 = source.transform(int) i2 = i1.transform(test_functions.add17) i2.sink(test_functions.check_int_strings_transform) standalone(self, topo)
def test_TopologyTransformWithDrop(self): topo = Topology("test_TopologyTransformWithDrop") source = topo.source(test_functions.int_strings_transform_with_drop) i1 = source.map(test_functions.string_to_int_except68) i2 = i1.map(test_functions.add17) i2.sink(test_functions.check_int_strings_transform_with_drop) standalone(self, topo)
def test_TopologyLambdaModule(self): "Lambda using an imported module" topo = Topology("test_TopologyLambdaModule") hw = topo.source(test_functions.hello_world) hw = hw.map(lambda t: t + ":" + str(np.cos(0.4))) hw = hw.map(lambda t: t.split(":",1)[0]) hw.sink(test_functions.check_hello_world) standalone(self, topo)
def test_TopologyLambdaModule(self): "Lambda using an imported module" topo = Topology("test_TopologyLambdaModule") hw = topo.source(test_functions.hello_world) hw = hw.map(lambda t: t + ":" + str(np.cos(0.4))) hw = hw.map(lambda t: t.split(":", 1)[0]) hw.sink(test_functions.check_hello_world) standalone(self, topo)
def test_TopologyIsolatedFilter(self): topo = Topology("test_TopologyIsolatedFilter") hw = topo.source(test_functions.hello_world) iso1 = hw.isolate() hwf = iso1.filter(test_functions.filter) iso2 = hwf.isolate() iso2.sink(test_functions.check_hello_world_filter) standalone(self, topo)
def test_TopologyHashedParallel(self): topo = Topology("test_TopologyHashedParallel") hw = topo.source(test_functions.seedSource) hwp = hw.parallel(4,Routing.HASH_PARTITIONED) hwf = hwp.transform(test_functions.ProgramedSeed()) hwef = hwf.end_parallel() hwef.sink(test_functions.SeedSinkHashOrKey()) standalone(self, topo)
def test_TopologyParallel(self): topo = Topology("test_TopologyParallel") hw = topo.source(test_functions.seedSource) hwp = hw.parallel(4) hwf = hwp.transform(test_functions.ProgramedSeed()) hwef = hwf.end_parallel() hwef.sink(test_functions.SeedSinkRR()) standalone(self, topo)
def test_TopologyHashedParallel(self): topo = Topology("test_TopologyHashedParallel") hw = topo.source(test_functions.seedSource) hwp = hw.parallel(4, Routing.HASH_PARTITIONED) hwf = hwp.transform(test_functions.ProgramedSeed()) hwef = hwf.end_parallel() hwef.sink(test_functions.SeedSinkHashOrKey()) standalone(self, topo)
def test_TopologyHashedFuncParallel(self): topo = Topology("test_TopologyHashedFuncParallel") hw = topo.source(test_functions.seedSource) hwp = hw.parallel(4, Routing.HASH_PARTITIONED, test_functions.produceHash) hwf = hwp.map(test_functions.ProgramedSeed()) hwef = hwf.end_parallel() hwef.for_each(test_functions.SeedSinkHashOrKey()) standalone(self, topo)
def test_TopologyUnion(self): topo = Topology("test_TopologyUnion") h = topo.source(test_functions.hello) b = topo.source(test_functions.beautiful) c = topo.source(test_functions.crazy) w = topo.source(test_functions.world) streamSet = {h, w, b, c} hwu = h.union(streamSet) hwu.sink(test_functions.check_union_hello_world) standalone(self, topo)
def test_TopologyImportModuleWithDependencies(self): import test_functions2 try: topo = Topology("test_TopologyImportModuleWithDependencies") hw = topo.source(test_functions2.hello_world) hwf = hw.filter(test_functions2.filter) hwf.sink(test_functions2.check_hello_world_filter) standalone(self, topo) finally: del test_functions2
def test_TopologyImportPackage(self): import test_package.test_subpackage.test_module try: topo = Topology("test_TopologyImportPackage") hw = topo.source(test_package.test_subpackage.test_module.SourceTuples(["Hello", "World!"])) hwf = hw.filter(test_package.test_subpackage.test_module.filter) hwf.sink(test_package.test_subpackage.test_module.CheckTuples(["Hello"])) standalone(self, topo) finally: pass
def test_TopologyImportNamespacePackage(self): from test_namespace_package.test_subpackage import test_module as test_ns_module try: topo = Topology("test_TopologyImportNamespacePackage") hw = topo.source(test_ns_module.SourceTuples(["Hello", "World!"])) hwf = hw.filter(test_functions.filter) hwf.sink(test_ns_module.CheckTuples(["World!"])) standalone(self, topo) finally: del test_ns_module
def test_TopologyLowLatency(self): topo = Topology("test_TopologyLowLatency") hw = topo.source(test_functions.hello_world) low1 = hw.low_latency() hwf1 = low1.filter(test_functions.filter) hwf2 = hwf1.filter(test_functions.filter) elow1 = hwf2.end_low_latency() hwf3 = elow1.filter(test_functions.filter) hwf3.sink(test_functions.check_hello_world_filter) standalone(self, topo) streamsx.topology.context.submit("BUNDLE", topo.graph)
def test_TopologyParallelUnion(self): topo = Topology("test_TopologyParallelUnion") hw = topo.source(test_functions.seedSource) hwp = hw.parallel(4) hwf = hwp.transform(test_functions.ProgramedSeed()) hwf2 = hwp.transform(test_functions.ProgramedSeed()) streamSet = {hwf2} hwu = hwf.union(streamSet) hwup = hwu.end_parallel() hwup.sink(test_functions.SeedSinkRRPU()) standalone(self, topo)
def test_TopologyImportPackage(self): import test_package.test_subpackage.test_module try: topo = Topology("test_TopologyImportPackage") hw = topo.source( test_package.test_subpackage.test_module.SourceTuples( ["Hello", "World!"])) hwf = hw.filter(test_package.test_subpackage.test_module.filter) hwf.sink( test_package.test_subpackage.test_module.CheckTuples(["Hello" ])) standalone(self, topo) finally: pass
def test_TopologyImportCommonNamespacePackage(self): sys.path.extend([ 'test_common_namespace/package1', 'test_common_namespace/package2' ]) import common_namespace.module1 import common_namespace.module2 try: topo = Topology("test_TopologyImportCommonNamespacePackage") hw = topo.source( common_namespace.module1.SourceTuples(["Hello", "World!"])) hwf = hw.filter(common_namespace.module2.filter) hwf.sink(common_namespace.module2.CheckTuples(["World!"])) standalone(self, topo) finally: sys.path.remove('test_common_namespace/package1') sys.path.remove('test_common_namespace/package2') del common_namespace.module1, common_namespace.module2
def test_TopologyImportCommonNamespacePackage(self): this_dir = os.path.dirname(os.path.realpath(__file__)) tcn = os.path.join(this_dir, 'test_common_namespace') tcn_paths = [os.path.join(tcn, 'package1'), os.path.join(tcn,'package2')] sys.path.extend(tcn_paths) import common_namespace.module1 import common_namespace.module2 try: topo = Topology("test_TopologyImportCommonNamespacePackage") hw = topo.source(common_namespace.module1.SourceTuples(["Hello", "World!"])) hwf = hw.filter(common_namespace.module2.filter) hwf.sink(common_namespace.module2.CheckTuples(["World!"])) standalone(self, topo) finally: for p in tcn_paths: sys.path.remove(p) del common_namespace.module1, common_namespace.module2
def test_TopologyImportCommonNamespacePackage(self): this_dir = os.path.dirname(os.path.realpath(__file__)) tcn = os.path.join(this_dir, 'test_common_namespace') tcn_paths = [ os.path.join(tcn, 'package1'), os.path.join(tcn, 'package2') ] sys.path.extend(tcn_paths) import common_namespace.module1 import common_namespace.module2 try: topo = Topology("test_TopologyImportCommonNamespacePackage") hw = topo.source( common_namespace.module1.SourceTuples(["Hello", "World!"])) hwf = hw.filter(common_namespace.module2.filter) hwf.sink(common_namespace.module2.CheckTuples(["World!"])) standalone(self, topo) finally: for p in tcn_paths: sys.path.remove(p) del common_namespace.module1, common_namespace.module2
def test_TopologyLengthFilter(self): topo = Topology("test_TopologyLengthFilter") hw = topo.source(test_functions.strings_length_filter) hwf = hw.filter(test_functions.LengthFilter(5)) hwf.sink(test_functions.check_strings_length_filter) standalone(self, topo)
def test_TopologyMultiTransformCallableIncMaxSplit(self): topo = Topology("test_TopologyMultiTransformCallableIncMaxSplit") source = topo.source(test_functions.strings_multi_transform) i1 = source.flat_map(test_functions.IncMaxSplitWords(1)) i1.sink(test_functions.check_strings_multi_transform_inc_max_split) standalone(self, topo)
def test_TopologySourceAndSinkCallable(self): topo = Topology("test_TopologySourceAndSinkCallable") hw = topo.source(test_functions.SourceTuplesAppendIndex(["a", "b", "c", "d"])) hw.sink(test_functions.CheckTuples(["a0", "b1", "c2", "d3"])) standalone(self, topo)
def test_TopologySourceAndSinkCallable(self): topo = Topology("test_TopologySourceAndSinkCallable") hw = topo.source( test_functions.SourceTuplesAppendIndex(["a", "b", "c", "d"])) hw.sink(test_functions.CheckTuples(["a0", "b1", "c2", "d3"])) standalone(self, topo)
def test_TopologyIsolate(self): topo = Topology("test_TopologyIsolate") hw = topo.source(test_functions.hello_world) iso = hw.isolate() iso.sink(test_functions.check_hello_world) standalone(self, topo)
def test_TopologyMultiTransform(self): topo = Topology("test_TopologyMultiTransform") source = topo.source(test_functions.strings_multi_transform) i1 = source.multi_transform(test_functions.split_words) i1.sink(test_functions.check_strings_multi_transform) standalone(self, topo)
def test_TopologySourceAndSink(self): topo = Topology("test_TopologySourceAndSink") hw = topo.source(test_functions.hello_world) hw.sink(test_functions.check_hello_world) standalone(self, topo)
def test_TopologyFilter(self): topo = Topology("test_TopologyFilter") hw = topo.source(test_functions.hello_world) hwf = hw.filter(test_functions.filter) hwf.for_each(test_functions.check_hello_world_filter) standalone(self, topo)
def test_TopologyLambdaFilter(self): topo = Topology("test_TopologyLambdaFilter") hw = topo.source(test_functions.hello_world) hwf = hw.filter(lambda t: "Wor" in t) hwf.sink(test_functions.check_hello_world_filter) standalone(self, topo)
def test_TopologyLambdaFilter(self): topo = Topology("test_TopologyLambdaFilter") hw = topo.source(test_functions.hello_world) hwf = hw.filter(lambda t : "Wor" in t) hwf.sink(test_functions.check_hello_world_filter) standalone(self, topo)