Skip to content
Snippets Groups Projects
Commit 71d69093 authored by Martin Lange's avatar Martin Lange
Browse files

add a test for sjipped pushes in multiple links between components

parent 4462fbca
No related branches found
No related tags found
1 merge request!208Schedule dependencies based on time in outputs
Pipeline #132104 passed with stages
in 3 minutes and 20 seconds
......@@ -716,7 +716,7 @@ class TestComposition(unittest.TestCase):
module1.outputs["Out"] >> Scale(1.0) >> module2.inputs["In"]
composition.connect(datetime(2000, 1, 1))
composition.connect()
self.assertEqual(updates, ["A", "B"])
composition.run(t_max=datetime(2000, 1, 2))
......@@ -734,6 +734,72 @@ class TestComposition(unittest.TestCase):
],
)
def test_dependencies_schedule_no_push_double(self):
start = datetime(2000, 1, 1)
info = fm.Info(time=start, grid=fm.NoGrid())
updates = []
def lambda_generator_1(t):
updates.append("A1")
return t.day
def lambda_generator_2(t):
if (t.day - 1) % 5 != 0:
return None
updates.append("A2")
return t.day
def lambda_component(inp, t):
updates.append("B")
return {"Out": inp["In1"]}
module1 = CallbackGenerator(
callbacks={
"Out1": (lambda_generator_1, info),
"Out2": (lambda_generator_2, info),
},
start=start,
step=timedelta(days=1),
)
module2 = CallbackComponent(
inputs={
"In1": fm.Info(time=None, grid=fm.NoGrid()),
"In2": fm.Info(time=None, grid=fm.NoGrid()),
},
outputs={
"Out": fm.Info(time=None, grid=fm.NoGrid()),
},
callback=lambda_component,
start=start,
step=timedelta(days=1),
)
composition = Composition([module1, module2])
composition.initialize()
module1.outputs["Out1"] >> Scale(1.0) >> module2.inputs["In1"]
module1.outputs["Out2"] >> Scale(1.0) >> module2.inputs["In2"]
composition.connect()
self.assertEqual(updates, ["A1", "A2", "B"])
composition.run(t_max=datetime(2000, 1, 2))
self.assertEqual(
updates,
[
"A1",
"A2",
"B", # Connect
"A1",
"A1",
"A1",
"A1",
"A1",
"A2",
"B", # Update B to 5
],
)
def test_dependency_fail(self):
start = datetime(2000, 1, 1)
info = fm.Info(time=start, grid=fm.NoGrid())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment