def test_localassert_should_assert_dependencies_properly_at_exec(tmpdir): data_inputs = np.array([0, 1, 2, 3]) context = ExecutionContext(root=tmpdir) p = Pipeline([ RegisterServiceDynamically(), SomeStep().assert_has_services_at_execution(SomeBaseService) ]).with_context(context=context) p.transform(data_inputs=data_inputs) service = context.get_service(SomeBaseService) assert np.array_equal(service.data, data_inputs)
def test_auto_ml_should_assert_dependecies_properly_at_exec(tmpdir): data_inputs = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) expected_outputs = data_inputs * 2 p = Pipeline([ RegisterServiceDynamically(), SomeStep().assert_has_services_at_execution(SomeBaseService), ]) context = ExecutionContext(root=tmpdir) auto_ml: AutoML = _make_autoML_loop(tmpdir, p) auto_ml: StepWithContext = auto_ml.with_context(context=context) assert isinstance(auto_ml, StepWithContext) auto_ml.fit(data_inputs, expected_outputs) service = context.get_service(SomeBaseService) assert np.array_equal(service.data, data_inputs)
def _will_process(self, data_container: DataContainer, context: ExecutionContext): data_container, context = super()._will_process(data_container, context) service = context.get_service(SomeBaseService) service.service_method(data_container.data_inputs) return data_container, context
def _transform_data_container(self, data_container: DataContainer, context: ExecutionContext): service: BaseService = context.get_service(BaseService) service.service_method(data_container.data_inputs) return data_container
def _will_process(self, data_container: DataContainer, context: ExecutionContext): data_container, context = super()._will_process( data_container, context) service = context.get_service(BaseService) return data_container, context
def _fit_data_container(self, data_container: DataContainer, context: ExecutionContext): service: SomeBaseService = context.get_service(SomeBaseService) service.service_method(data_container.data_inputs) return self