def test_get_summary__multiple_sources(self): other_project_config = mock.MagicMock() other_project_config.source.__str__.return_value = "other source" flow = FlowCoordinator.from_steps( self.project_config, [ StepSpec( "1/1", "other:test1", {}, None, other_project_config, from_flow="test", ), StepSpec("1/2", "test2", {}, None, self.project_config, from_flow="test"), ], ) assert ("1) flow: test" + "\n 1) task: other:test1 [from other source]" + "\n 2) task: test2 [from current folder]" ) == flow.get_summary()
def run(self, ctx, plan, steps, org): flow_coordinator = FlowCoordinator.from_steps( ctx.project_config, steps, name="default", callbacks=JobFlowCallback(self)) flow_coordinator.run(org)
def get_flow_from_plan(self, plan: Plan, ctx: WorkableModel, skip: List[str] = None): steps = [ step.to_spec(skip=step.path in skip) for step in plan.steps.all() ] if isinstance(ctx, PreflightResult): flow_config = self.project_config.get_flow( plan.preflight_flow_name) return FlowCoordinator( self.project_config, flow_config, name=plan.preflight_flow_name, callbacks=PreflightFlowCallback(ctx), ) elif isinstance(ctx, Job): return FlowCoordinator.from_steps( self.project_config, steps, name="default", callbacks=JobFlowCallback(ctx), ) else: # pragma: no cover raise AttributeError(f"ctx must be either a PreflightResult " f"or Job, but was passed {type(ctx)}.")
def test_get_summary__substeps(self): flow = FlowCoordinator.from_steps( self.project_config, [ StepSpec("1", "test", {}, None, self.project_config, from_flow="test") ], ) assert flow.get_summary() == ""
def test_from_steps(self): steps = [StepSpec("1", "test", {}, _TaskReturnsStuff)] flow = FlowCoordinator.from_steps(self.project_config, steps) self.assertEqual(1, len(flow.steps))