diff --git a/doc/changes/changes_0.2.0.md b/doc/changes/changes_0.2.0.md index ac7e03c1..3c753f97 100644 --- a/doc/changes/changes_0.2.0.md +++ b/doc/changes/changes_0.2.0.md @@ -20,4 +20,5 @@ Code name: * #217: Rename dataflow abstraction files * #219: Applied PTB checks and fixes * #221: Fixed mypy warnings -* #233: Upgraded pydantic to version 2 \ No newline at end of file +* #233: Upgraded pydantic to version 2 +* #231: Renamed `TrainQueryHandler` to `SQLStageQueryHandler` diff --git a/exasol/analytics/query_handler/graph/stage/sql/execution/query_handler_state.py b/exasol/analytics/query_handler/graph/stage/sql/execution/query_handler_state.py index e6935e0d..7b63a214 100644 --- a/exasol/analytics/query_handler/graph/stage/sql/execution/query_handler_state.py +++ b/exasol/analytics/query_handler/graph/stage/sql/execution/query_handler_state.py @@ -17,7 +17,7 @@ ) from exasol.analytics.query_handler.graph.stage.sql.sql_stage import SQLStage from exasol.analytics.query_handler.graph.stage.sql.sql_stage_query_handler import ( - SQLStageTrainQueryHandlerInput, + SQLStageQueryHandlerInput, ) from exasol.analytics.query_handler.query_handler import QueryHandler from exasol.analytics.query_handler.result import Continue, Finish @@ -135,11 +135,11 @@ def _create_current_query_handler(self): result_bucketfs_location = self._result_bucketfs_location.joinpath( str(self._current_stage_index) ) - stage_input = SQLStageTrainQueryHandlerInput( + stage_input = SQLStageQueryHandlerInput( result_bucketfs_location=result_bucketfs_location, sql_stage_inputs=stage_inputs, ) - self._current_query_handler = self._checked_current_stage.create_train_query_handler( + self._current_query_handler = self._checked_current_stage.create_query_handler( stage_input, self._current_qh_context ) diff --git a/exasol/analytics/query_handler/graph/stage/sql/sql_stage.py b/exasol/analytics/query_handler/graph/stage/sql/sql_stage.py index ffc5e79a..8715e7f0 100644 --- a/exasol/analytics/query_handler/graph/stage/sql/sql_stage.py +++ b/exasol/analytics/query_handler/graph/stage/sql/sql_stage.py @@ -3,16 +3,16 @@ from exasol.analytics.query_handler.context.scope import ScopeQueryHandlerContext from exasol.analytics.query_handler.graph.stage.sql.sql_stage_query_handler import ( SQLStageQueryHandler, - SQLStageTrainQueryHandlerInput, + SQLStageQueryHandlerInput, ) from exasol.analytics.query_handler.graph.stage.stage import Stage class SQLStage(Stage): @abc.abstractmethod - def create_train_query_handler( + def create_query_handler( self, - stage_input: SQLStageTrainQueryHandlerInput, + stage_input: SQLStageQueryHandlerInput, query_handler_context: ScopeQueryHandlerContext, ) -> SQLStageQueryHandler: pass diff --git a/exasol/analytics/query_handler/graph/stage/sql/sql_stage_query_handler.py b/exasol/analytics/query_handler/graph/stage/sql/sql_stage_query_handler.py index 2f9b96e4..ffbdb460 100644 --- a/exasol/analytics/query_handler/graph/stage/sql/sql_stage_query_handler.py +++ b/exasol/analytics/query_handler/graph/stage/sql/sql_stage_query_handler.py @@ -17,7 +17,7 @@ def is_empty(obj: Sized): @dataclasses.dataclass(eq=True) -class SQLStageTrainQueryHandlerInput: +class SQLStageQueryHandlerInput: sql_stage_inputs: List[SQLStageInputOutput] result_bucketfs_location: AbstractBucketFSLocation @@ -27,6 +27,6 @@ def __post_init__(self): class SQLStageQueryHandler( - QueryHandler[SQLStageTrainQueryHandlerInput, SQLStageInputOutput], ABC + QueryHandler[SQLStageQueryHandlerInput, SQLStageInputOutput], ABC ): pass diff --git a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/assert_helper.py b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/assert_helper.py index de1814b0..a275cfed 100644 --- a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/assert_helper.py +++ b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/assert_helper.py @@ -4,7 +4,7 @@ SQLStageInputOutput, ) from exasol.analytics.query_handler.graph.stage.sql.sql_stage_query_handler import ( - SQLStageTrainQueryHandlerInput, + SQLStageQueryHandlerInput, ) from tests.utils.mock_cast import mock_cast from tests.unit_tests.sql_stage_graph.stage_graph_execution_query_handler.state_test_setup import ( @@ -38,12 +38,12 @@ def assert_parent_query_handler_context_not_called(test_setup: TestSetup): def assert_stage_not_called(test_setup: TestSetup, *, stage_index: int): stage_setup = test_setup.stage_setups[stage_index] - mock_cast(stage_setup.stage.create_train_query_handler).assert_not_called() - assert stage_setup.train_query_handler.mock_calls == [] + mock_cast(stage_setup.stage.create_query_handler).assert_not_called() + assert stage_setup.query_handler.mock_calls == [] assert stage_setup.child_query_handler_context.mock_calls == [] -def assert_stage_train_query_handler_created( +def assert_stage_query_handler_created( test_setup: TestSetup, *, stage_index: int, stage_inputs: List[SQLStageInputOutput] ): stage_setup = test_setup.stage_setups[stage_index] @@ -56,13 +56,13 @@ def assert_stage_train_query_handler_created( result_bucketfs_location = test_setup.stage_setups[ stage_index ].result_bucketfs_location - stage_input = SQLStageTrainQueryHandlerInput( + stage_input = SQLStageQueryHandlerInput( result_bucketfs_location=result_bucketfs_location, sql_stage_inputs=stage_inputs ) - mock_cast(stage_setup.stage.create_train_query_handler).assert_called_once_with( + mock_cast(stage_setup.stage.create_query_handler).assert_called_once_with( stage_input, stage_setup.child_query_handler_context ) - assert stage_setup.train_query_handler.mock_calls == [] + assert stage_setup.query_handler.mock_calls == [] assert stage_setup.child_query_handler_context.mock_calls == [] @@ -70,6 +70,6 @@ def assert_release_on_query_handler_context_for_stage( test_setup: TestSetup, *, stage_index: int ): stage_setup = test_setup.stage_setups[stage_index] - assert stage_setup.train_query_handler.mock_calls == [] + assert stage_setup.query_handler.mock_calls == [] mock_cast(stage_setup.child_query_handler_context.release).assert_called_once() - mock_cast(stage_setup.stage.create_train_query_handler).assert_not_called() + mock_cast(stage_setup.stage.create_query_handler).assert_not_called() diff --git a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/state_test_setup.py b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/state_test_setup.py index 618672e6..76860a61 100644 --- a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/state_test_setup.py +++ b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/state_test_setup.py @@ -30,7 +30,7 @@ from tests.utils.mock_cast import mock_cast MockScopeQueryHandlerContext = Union[ScopeQueryHandlerContext, MagicMock] -MockSQLStageTrainQueryHandler = Union[SQLStageQueryHandler, MagicMock] +MockSQLStageQueryHandler = Union[SQLStageQueryHandler, MagicMock] MockQueryHandlerResult = Union[Continue, Finish, MagicMock] MockSQLStageInputOutput = Union[SQLStageInputOutput, MagicMock] MockSQLStage = Union[SQLStage, MagicMock] @@ -47,14 +47,14 @@ class StageSetup: index: int child_query_handler_context: MockScopeQueryHandlerContext - train_query_handler: MockSQLStageTrainQueryHandler + query_handler: MockSQLStageQueryHandler stage: MockSQLStage results: List[MockQueryHandlerResult] result_bucketfs_location: MockBucketFSLocation def reset_mock(self): self.child_query_handler_context.reset_mock() - self.train_query_handler.reset_mock() + self.query_handler.reset_mock() self.stage.reset_mock() self.result_bucketfs_location.reset_mock() for result in self.results: @@ -173,15 +173,15 @@ def create_mocks_for_stage( result: List[MockQueryHandlerResult] = [ create_autospec(result_prototype) for result_prototype in result_prototypes ] - train_query_handler: MockSQLStageTrainQueryHandler = create_autospec(QueryHandler) - sql_stage.create_train_query_handler.return_value = train_query_handler + query_handler: MockSQLStageQueryHandler = create_autospec(QueryHandler) + sql_stage.create_query_handler.return_value = query_handler mock_result_bucketfs_location: MockBucketFSLocation = create_autospec( AbstractBucketFSLocation ) return StageSetup( index=stage_index, child_query_handler_context=child_scoped_query_handler_context, - train_query_handler=train_query_handler, + query_handler=query_handler, stage=sql_stage, results=result, result_bucketfs_location=mock_result_bucketfs_location, diff --git a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_query_handler_integration.py b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_query_handler_integration.py index 4f069394..289adee8 100644 --- a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_query_handler_integration.py +++ b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_query_handler_integration.py @@ -29,7 +29,7 @@ from exasol.analytics.query_handler.graph.stage.sql.sql_stage_graph import SQLStageGraph from exasol.analytics.query_handler.graph.stage.sql.sql_stage_query_handler import ( SQLStageQueryHandler, - SQLStageTrainQueryHandlerInput, + SQLStageQueryHandlerInput, ) from exasol.analytics.query_handler.query.result.interface import QueryResult from exasol.analytics.query_handler.query.select import SelectQueryWithColumnDefinition @@ -45,11 +45,11 @@ ) -class StartOnlyForwardInputTestSQLStageTrainQueryHandler(SQLStageQueryHandler): +class StartOnlyForwardInputTestSQLStageQueryHandler(SQLStageQueryHandler): def __init__( self, - parameter: SQLStageTrainQueryHandlerInput, + parameter: SQLStageQueryHandlerInput, query_handler_context: ScopeQueryHandlerContext, ): super().__init__(parameter, query_handler_context) @@ -64,11 +64,11 @@ def handle_query_result( raise NotImplementedError() -class StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler(SQLStageQueryHandler): +class StartOnlyCreateNewOutputTestSQLStageQueryHandler(SQLStageQueryHandler): def __init__( self, - parameter: SQLStageTrainQueryHandlerInput, + parameter: SQLStageQueryHandlerInput, query_handler_context: ScopeQueryHandlerContext, ): super().__init__(parameter, query_handler_context) @@ -94,13 +94,13 @@ def handle_query_result( raise NotImplementedError() -class HandleQueryResultCreateNewOutputTestSQLStageTrainQueryHandler( +class HandleQueryResultCreateNewOutputTestSQLStageQueryHandler( SQLStageQueryHandler ): def __init__( self, - parameter: SQLStageTrainQueryHandlerInput, + parameter: SQLStageQueryHandlerInput, query_handler_context: ScopeQueryHandlerContext, ): super().__init__(parameter, query_handler_context) @@ -131,8 +131,8 @@ def handle_query_result( return Finish[SQLStageInputOutput](self.stage_input_output) -TrainQueryHandlerFactory = Callable[ - [SQLStageTrainQueryHandlerInput, ScopeQueryHandlerContext], SQLStageQueryHandler +SQLStageQueryHandlerFactory = Callable[ + [SQLStageQueryHandlerInput, ScopeQueryHandlerContext], SQLStageQueryHandler ] @@ -140,21 +140,21 @@ class TestSQLStage(SQLStage): __test__ = False def __init__( - self, *, index: int, train_query_handler_factory: TrainQueryHandlerFactory + self, *, index: int, query_handler_factory: SQLStageQueryHandlerFactory ): - self._train_query_handler_factory = train_query_handler_factory - self.sql_stage_train_query_handler: Optional[SQLStageQueryHandler] = None + self._query_handler_factory = query_handler_factory + self.sql_stage_query_handler: Optional[SQLStageQueryHandler] = None self._index = index - def create_train_query_handler( + def create_query_handler( self, - query_handler_input: SQLStageTrainQueryHandlerInput, + query_handler_input: SQLStageQueryHandlerInput, query_handler_context: ScopeQueryHandlerContext, ) -> SQLStageQueryHandler: - self.sql_stage_train_query_handler = self._train_query_handler_factory( + self.sql_stage_query_handler = self._query_handler_factory( query_handler_input, query_handler_context ) - return self.sql_stage_train_query_handler + return self.sql_stage_query_handler def __eq__(self, other): if isinstance(other, TestSQLStage): @@ -251,12 +251,12 @@ def create_test_setup( ) -def test_start_with_single_stage_with_start_only_forward_train_query_handler( +def test_start_with_single_stage_with_start_only_forward_query_handler( top_level_query_handler_context_mock, tmp_path ): """ This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler - on a SQLStageGraph with a single stage which returns a StartOnlyForwardInputTestSQLStageTrainQueryHandler. + on a SQLStageGraph with a single stage which returns a StartOnlyForwardInputTestSQLStageQueryHandler. It expects: - that the dataset of the result is the dataset we initialed the SQLStageGraphExecutionQueryHandler with - that context.cleanup_released_object_proxies() directly @@ -268,7 +268,7 @@ def test_start_with_single_stage_with_start_only_forward_train_query_handler( def arrange() -> TestSetup: stage1 = TestSQLStage( index=1, - train_query_handler_factory=StartOnlyForwardInputTestSQLStageTrainQueryHandler, + query_handler_factory=StartOnlyForwardInputTestSQLStageQueryHandler, ) sql_stage_graph = SQLStageGraph(start_node=stage1, end_node=stage1, edges=[]) test_setup = create_test_setup( @@ -301,12 +301,12 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]: ) -def test_start_with_two_stages_with_start_only_forward_train_query_handler( +def test_start_with_two_stages_with_start_only_forward_query_handler( top_level_query_handler_context_mock, tmp_path ): """ This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler - on a SQLStageGraph with two stages which return a StartOnlyForwardInputTestSQLStageTrainQueryHandler. + on a SQLStageGraph with two stages which return a StartOnlyForwardInputTestSQLStageQueryHandler. It expects: - that the dataset of the result is the dataset we initialized the SQLStageGraphExecutionQueryHandler with - that context.cleanup_released_object_proxies() directly @@ -318,11 +318,11 @@ def test_start_with_two_stages_with_start_only_forward_train_query_handler( def arrange() -> TestSetup: stage1 = TestSQLStage( index=1, - train_query_handler_factory=StartOnlyForwardInputTestSQLStageTrainQueryHandler, + query_handler_factory=StartOnlyForwardInputTestSQLStageQueryHandler, ) stage2 = TestSQLStage( index=2, - train_query_handler_factory=StartOnlyForwardInputTestSQLStageTrainQueryHandler, + query_handler_factory=StartOnlyForwardInputTestSQLStageQueryHandler, ) sql_stage_graph = SQLStageGraph( start_node=stage1, end_node=stage2, edges=[(stage1, stage2)] @@ -365,16 +365,16 @@ def not_raises(exception): raise pytest.fail(f"DID RAISE {exception}") -def test_start_with_single_stage_with_start_only_create_new_output_train_query_handler( +def test_start_with_single_stage_with_start_only_create_new_output_query_handler( top_level_query_handler_context_mock, tmp_path ): """ This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler - on a SQLStageGraph with a single stage which return a StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler. + on a SQLStageGraph with a single stage which return a StartOnlyCreateNewOutputTestSQLStageQueryHandler. It expects: - that the dataset of the result is the dataset created by the - StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler of the single stage - - that input_table_like_name of the StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler is not None + StartOnlyCreateNewOutputTestSQLStageQueryHandler of the single stage + - that input_table_like_name of the StartOnlyCreateNewOutputTestSQLStageQueryHandler is not None - that context.cleanup_released_object_proxies() directly after the call to start, returns no cleanup queries - that context.cleanup_released_object_proxies() after a call to @@ -384,7 +384,7 @@ def test_start_with_single_stage_with_start_only_create_new_output_train_query_h def arrange() -> TestSetup: stage1 = TestSQLStage( index=1, - train_query_handler_factory=StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler, + query_handler_factory=StartOnlyCreateNewOutputTestSQLStageQueryHandler, ) sql_stage_graph = SQLStageGraph(start_node=stage1, end_node=stage1, edges=[]) test_setup = create_test_setup( @@ -402,18 +402,18 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]: test_setup = arrange() result = act(test_setup) - stage_1_train_query_handler = test_setup.stages[0].sql_stage_train_query_handler + stage_1_query_handler = test_setup.stages[0].sql_stage_query_handler assert ( isinstance(result, Finish) and isinstance(result.result, SQLStageInputOutput) and result.result.dataset != test_setup.stage_input_output.dataset and isinstance( - stage_1_train_query_handler, - StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler, + stage_1_query_handler, + StartOnlyCreateNewOutputTestSQLStageQueryHandler, ) and result.result.dataset - == stage_1_train_query_handler.stage_input_output.dataset - and stage_1_train_query_handler.input_table_like_name is not None + == stage_1_query_handler.stage_input_output.dataset + and stage_1_query_handler.input_table_like_name is not None and len(top_level_query_handler_context_mock.cleanup_released_object_proxies()) == 0 ) @@ -430,16 +430,16 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]: ) -def test_start_with_two_stages_with_start_only_create_new_output_train_query_handler( +def test_start_with_two_stages_with_start_only_create_new_output_query_handler( top_level_query_handler_context_mock, tmp_path ): """ This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler - on a SQLStageGraph with two stages which return a StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler. + on a SQLStageGraph with two stages which return a StartOnlyCreateNewOutputTestSQLStageQueryHandler. It expects: - that the dataset of the result is the dataset created by the - StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler of the second stage - - that input_table_like_name of the StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler is not None + StartOnlyCreateNewOutputTestSQLStageQueryHandler of the second stage + - that input_table_like_name of the StartOnlyCreateNewOutputTestSQLStageQueryHandler is not None - that context.cleanup_released_object_proxies() directly after the call to start, returns a single cleanup query - that context.cleanup_released_object_proxies() after a call to @@ -449,11 +449,11 @@ def test_start_with_two_stages_with_start_only_create_new_output_train_query_han def arrange() -> TestSetup: stage1 = TestSQLStage( index=1, - train_query_handler_factory=StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler, + query_handler_factory=StartOnlyCreateNewOutputTestSQLStageQueryHandler, ) stage2 = TestSQLStage( index=2, - train_query_handler_factory=StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler, + query_handler_factory=StartOnlyCreateNewOutputTestSQLStageQueryHandler, ) sql_stage_graph = SQLStageGraph( start_node=stage1, end_node=stage2, edges=[(stage1, stage2)] @@ -473,24 +473,24 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]: test_setup = arrange() result = act(test_setup) - stage_1_train_query_handler = test_setup.stages[0].sql_stage_train_query_handler - stage_2_train_query_handler = test_setup.stages[1].sql_stage_train_query_handler + stage_1_query_handler = test_setup.stages[0].sql_stage_query_handler + stage_2_query_handler = test_setup.stages[1].sql_stage_query_handler assert ( isinstance(result, Finish) and isinstance(result.result, SQLStageInputOutput) and result.result.dataset != test_setup.stage_input_output.dataset and isinstance( - stage_1_train_query_handler, - StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler, + stage_1_query_handler, + StartOnlyCreateNewOutputTestSQLStageQueryHandler, ) and isinstance( - stage_2_train_query_handler, - StartOnlyCreateNewOutputTestSQLStageTrainQueryHandler, + stage_2_query_handler, + StartOnlyCreateNewOutputTestSQLStageQueryHandler, ) and result.result.dataset - == stage_2_train_query_handler.stage_input_output.dataset - and stage_1_train_query_handler.input_table_like_name is not None - and stage_2_train_query_handler.input_table_like_name is not None + == stage_2_query_handler.stage_input_output.dataset + and stage_1_query_handler.input_table_like_name is not None + and stage_2_query_handler.input_table_like_name is not None and len(top_level_query_handler_context_mock.cleanup_released_object_proxies()) == 1 ) @@ -507,15 +507,15 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]: ) -def test_start_with_single_stage_with_handle_query_result_create_new_output_train_query_handler_part1( +def test_start_with_single_stage_with_handle_query_result_create_new_output_query_handler_part1( top_level_query_handler_context_mock, tmp_path ): """ This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler - on a SQLStageGraph with a single stage which return a HandleQueryResultCreateNewOutputTestSQLStageTrainQueryHandler. + on a SQLStageGraph with a single stage which return a HandleQueryResultCreateNewOutputTestSQLStageQueryHandler. It expects: - - that the result of start is the same as the continue of the train query handler of the stage - - that stage_input_output of train query handler of the stage is None + - that the result of start is the same as the continue of the query handler of the stage + - that stage_input_output of query handler of the stage is None - that context.cleanup_released_object_proxies() directly after the call to start, returns a single cleanup query """ @@ -523,7 +523,7 @@ def test_start_with_single_stage_with_handle_query_result_create_new_output_trai def arrange() -> TestSetup: stage1 = TestSQLStage( index=1, - train_query_handler_factory=HandleQueryResultCreateNewOutputTestSQLStageTrainQueryHandler, + query_handler_factory=HandleQueryResultCreateNewOutputTestSQLStageQueryHandler, ) sql_stage_graph = SQLStageGraph(start_node=stage1, end_node=stage1, edges=[]) test_setup = create_test_setup( @@ -541,30 +541,30 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]: test_setup = arrange() result = act(test_setup) - stage_1_train_query_handler = test_setup.stages[0].sql_stage_train_query_handler + stage_1_query_handler = test_setup.stages[0].sql_stage_query_handler assert ( isinstance( - stage_1_train_query_handler, - HandleQueryResultCreateNewOutputTestSQLStageTrainQueryHandler, + stage_1_query_handler, + HandleQueryResultCreateNewOutputTestSQLStageQueryHandler, ) - and result == stage_1_train_query_handler.continue_result - and stage_1_train_query_handler.stage_input_output is None - and stage_1_train_query_handler.query_result is None + and result == stage_1_query_handler.continue_result + and stage_1_query_handler.stage_input_output is None + and stage_1_query_handler.query_result is None and len(top_level_query_handler_context_mock.cleanup_released_object_proxies()) == 0 ) -def test_handle_query_result_with_single_stage_with_handle_query_result_create_new_output_train_query_handler_part2( +def test_handle_query_result_with_single_stage_with_handle_query_result_create_new_output_query_handler_part2( top_level_query_handler_context_mock, tmp_path ): """ - This test uses test_start_with_single_stage_with_handle_query_result_create_new_output_train_query_handler_part1 + This test uses test_start_with_single_stage_with_handle_query_result_create_new_output_query_handler_part1 as setup and runs handle_query_result on the SQLStageGraphExecutionQueryHandler. It expects: - that the result of handle_query_result is the same as the stage_input_output - of the train query handler of the stage - - that recorded query_result in the train query handler is the same as we put into the handle_query_result call + of the query handler of the stage + - that recorded query_result in the query handler is the same as we put into the handle_query_result call - that context.cleanup_released_object_proxies() directly after the call to start, returns no cleanup query - that context.cleanup_released_object_proxies() after a call to @@ -574,7 +574,7 @@ def test_handle_query_result_with_single_stage_with_handle_query_result_create_n def arrange() -> Tuple[TestSetup, QueryResult]: stage1 = TestSQLStage( index=1, - train_query_handler_factory=HandleQueryResultCreateNewOutputTestSQLStageTrainQueryHandler, + query_handler_factory=HandleQueryResultCreateNewOutputTestSQLStageQueryHandler, ) sql_stage_graph = SQLStageGraph(start_node=stage1, end_node=stage1, edges=[]) test_setup = create_test_setup( @@ -596,15 +596,15 @@ def act( test_setup, query_result = arrange() result = act(test_setup, query_result) - stage_1_train_query_handler = test_setup.stages[0].sql_stage_train_query_handler + stage_1_query_handler = test_setup.stages[0].sql_stage_query_handler assert ( isinstance(result, Finish) and isinstance( - stage_1_train_query_handler, - HandleQueryResultCreateNewOutputTestSQLStageTrainQueryHandler, + stage_1_query_handler, + HandleQueryResultCreateNewOutputTestSQLStageQueryHandler, ) - and result.result == stage_1_train_query_handler.stage_input_output - and query_result == stage_1_train_query_handler.query_result + and result.result == stage_1_query_handler.stage_input_output + and query_result == stage_1_query_handler.query_result and len(top_level_query_handler_context_mock.cleanup_released_object_proxies()) == 0 ) diff --git a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_query_handler_using_mock_state.py b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_query_handler_using_mock_state.py index 92cf5597..fa740682 100644 --- a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_query_handler_using_mock_state.py +++ b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_query_handler_using_mock_state.py @@ -29,7 +29,7 @@ SQLStageGraphExecutionQueryHandlerState, MagicMock ] MockScopeQueryHandlerContext = Union[ScopeQueryHandlerContext, MagicMock] -MockSQLStageTrainQueryHandler = Union[SQLStageQueryHandler, MagicMock] +MockSQLStageQueryHandler = Union[SQLStageQueryHandler, MagicMock] MockQueryHandlerResult = Union[Continue, Finish, MagicMock] MockSQLStageGraphExecutionInput = Union[SQLStageGraphExecutionInput, MagicMock] MockSQLStageInputOutput = Union[SQLStageInputOutput, MagicMock] @@ -40,71 +40,71 @@ @dataclasses.dataclass -class TrainQueryHandlerMockSetup: +class SQLStageQueryHandlerMockSetup: results: List[MockQueryHandlerResult] - train_query_handler: MockSQLStageTrainQueryHandler + query_handler: MockSQLStageQueryHandler def reset_mock(self): - self.train_query_handler.reset_mock() + self.query_handler.reset_mock() for result in self.results: result.reset_mock() @dataclasses.dataclass -class TrainQueryHandlerSetupDefinition: +class SQLStageQueryHandlerSetupDefinition: result_prototypes: List[Union[Continue, Finish]] - def create_mock_setup(self) -> TrainQueryHandlerMockSetup: + def create_mock_setup(self) -> SQLStageQueryHandlerMockSetup: results: List[MockQueryHandlerResult] = [ create_autospec(result_prototype) for result_prototype in self.result_prototypes ] - train_query_handler: MockSQLStageTrainQueryHandler = create_autospec( + query_handler: MockSQLStageQueryHandler = create_autospec( QueryHandler ) - train_query_handler.start.side_effect = [results[0]] - train_query_handler.handle_query_result.side_effect = results[1:] - return TrainQueryHandlerMockSetup(results, train_query_handler) + query_handler.start.side_effect = [results[0]] + query_handler.handle_query_result.side_effect = results[1:] + return SQLStageQueryHandlerMockSetup(results, query_handler) @dataclasses.dataclass class StateMockSetup: - train_query_handler_mock_setups: List[TrainQueryHandlerMockSetup] + query_handler_mock_setups: List[SQLStageQueryHandlerMockSetup] state: MockSQLStageGraphExecutionQueryHandlerState def reset_mock(self): self.state.reset_mock() - for train_query_handler_mock_setup in self.train_query_handler_mock_setups: - train_query_handler_mock_setup.reset_mock() + for query_handler_mock_setup in self.query_handler_mock_setups: + query_handler_mock_setup.reset_mock() @dataclasses.dataclass class StateSetupDefinition: - train_query_handler_setup_definitions: List[TrainQueryHandlerSetupDefinition] + query_handler_setup_definitions: List[SQLStageQueryHandlerSetupDefinition] def create_mock_setup(self) -> StateMockSetup: - train_query_handler_mock_setups = [ - train_query_handler_setup_definition.create_mock_setup() - for train_query_handler_setup_definition in self.train_query_handler_setup_definitions + query_handler_mock_setups = [ + query_handler_setup_definition.create_mock_setup() + for query_handler_setup_definition in self.query_handler_setup_definitions ] state: MockSQLStageGraphExecutionQueryHandlerState = create_autospec( SQLStageGraphExecutionQueryHandlerState ) - train_query_handlers = [ - train_query_handler_mock_setup.train_query_handler - for train_query_handler_mock_setup in train_query_handler_mock_setups - for _ in train_query_handler_mock_setup.results + query_handlers = [ + query_handler_mock_setup.query_handler + for query_handler_mock_setup in query_handler_mock_setups + for _ in query_handler_mock_setup.results ] - state.get_current_query_handler.side_effect = train_query_handlers + state.get_current_query_handler.side_effect = query_handlers result_handler_return_values = [ self._create_result_handler_return_value(result) - for train_query_handler_mock_setup in train_query_handler_mock_setups - for result in train_query_handler_mock_setup.results + for query_handler_mock_setup in query_handler_mock_setups + for result in query_handler_mock_setup.results ] result_handler_return_values[-1] = ResultHandlerReturnValue.RETURN_RESULT state.handle_result.side_effect = result_handler_return_values return StateMockSetup( - train_query_handler_mock_setups=train_query_handler_mock_setups, state=state + query_handler_mock_setups=query_handler_mock_setups, state=state ) @staticmethod @@ -159,18 +159,18 @@ def create_test_setup(state_setup_definition: StateSetupDefinition) -> TestSetup ) -def create_test_setup_with_two_train_query_handler_returning_continue_finish() -> ( +def create_test_setup_with_two_query_handler_returning_continue_finish() -> ( TestSetup ): state_setup_definition = StateSetupDefinition( - train_query_handler_setup_definitions=[ - TrainQueryHandlerSetupDefinition( + query_handler_setup_definitions=[ + SQLStageQueryHandlerSetupDefinition( result_prototypes=[ Continue(query_list=None, input_query=None), Finish(result=None), ] ), - TrainQueryHandlerSetupDefinition( + SQLStageQueryHandlerSetupDefinition( result_prototypes=[ Continue(query_list=None, input_query=None), Finish(result=None), @@ -192,8 +192,8 @@ def test_init(): def arrange() -> StateSetupDefinition: state_setup_definition = StateSetupDefinition( - train_query_handler_setup_definitions=[ - TrainQueryHandlerSetupDefinition( + query_handler_setup_definitions=[ + SQLStageQueryHandlerSetupDefinition( result_prototypes=[Finish(result=None)] ) ] @@ -211,26 +211,26 @@ def act(state_setup_definition: StateSetupDefinition) -> TestSetup: test_setup.mock_execution_input, test_setup.mock_scope_query_handler_context ) test_setup.state_mock_setup.state.assert_not_called() - test_setup.state_mock_setup.train_query_handler_mock_setups[ + test_setup.state_mock_setup.query_handler_mock_setups[ 0 - ].train_query_handler.assert_not_called() + ].query_handler.assert_not_called() -def test_start_single_train_query_handler_returning_finish(): +def test_start_single_query_handler_returning_finish(): """ This test calls start on a newly created SQLStageGraphExecutionQueryHandler - which was initialized with a state that has a train_query_handler which returns Finish. + which was initialized with a state that has a query_handler which returns Finish. It expects: - that get_current_query_handler is called on the state - - that handle_result is called on the state with the result of the train_query_handler - - that start is called on the train_query_handler - - that the result is equal to the result of train_query_handler.start + - that handle_result is called on the state with the result of the query_handler + - that start is called on the query_handler + - that the result is equal to the result of query_handler.start """ def arrange() -> TestSetup: state_setup_definition = StateSetupDefinition( - train_query_handler_setup_definitions=[ - TrainQueryHandlerSetupDefinition( + query_handler_setup_definitions=[ + SQLStageQueryHandlerSetupDefinition( result_prototypes=[Finish(result=None)] ) ] @@ -246,37 +246,37 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]: test_setup = arrange() result = act(test_setup) - train_query_handler_mock_setup = ( - test_setup.state_mock_setup.train_query_handler_mock_setups[0] + query_handler_mock_setup = ( + test_setup.state_mock_setup.query_handler_mock_setups[0] ) test_setup.state_mock_setup.state.assert_has_calls( [ call.get_current_query_handler(), - call.handle_result(train_query_handler_mock_setup.results[0]), + call.handle_result(query_handler_mock_setup.results[0]), ] ) - train_query_handler_mock_setup.train_query_handler.assert_has_calls([call.start()]) + query_handler_mock_setup.query_handler.assert_has_calls([call.start()]) mock_cast( - train_query_handler_mock_setup.train_query_handler.handle_query_result + query_handler_mock_setup.query_handler.handle_query_result ).assert_not_called() - assert result == train_query_handler_mock_setup.results[0] + assert result == query_handler_mock_setup.results[0] -def test_start_single_train_query_handler_returning_continue(): +def test_start_single_query_handler_returning_continue(): """ This test calls start on a newly created SQLStageGraphExecutionQueryHandler - which was initialized with a state that has a train_query_handler which returns Continue. + which was initialized with a state that has a query_handler which returns Continue. It expects: - that get_current_query_handler is called on the state - - that handle_result is called on the state with the result of the train_query_handler - - that start is called on the train_query_handler - - that the result is equal to the result of train_query_handler.start + - that handle_result is called on the state with the result of the query_handler + - that start is called on the query_handler + - that the result is equal to the result of query_handler.start """ def arrange() -> TestSetup: state_setup_definition = StateSetupDefinition( - train_query_handler_setup_definitions=[ - TrainQueryHandlerSetupDefinition( + query_handler_setup_definitions=[ + SQLStageQueryHandlerSetupDefinition( result_prototypes=[ Continue(query_list=None, input_query=None), ] @@ -294,40 +294,40 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]: test_setup = arrange() result = act(test_setup) - train_query_handler_mock_setup = ( - test_setup.state_mock_setup.train_query_handler_mock_setups[0] + query_handler_mock_setup = ( + test_setup.state_mock_setup.query_handler_mock_setups[0] ) test_setup.state_mock_setup.state.assert_has_calls( [ call.get_current_query_handler(), - call.handle_result(train_query_handler_mock_setup.results[0]), + call.handle_result(query_handler_mock_setup.results[0]), ] ) mock_cast( - train_query_handler_mock_setup.train_query_handler.start + query_handler_mock_setup.query_handler.start ).assert_called_once() mock_cast( - train_query_handler_mock_setup.train_query_handler.handle_query_result + query_handler_mock_setup.query_handler.handle_query_result ).assert_not_called() - assert result == train_query_handler_mock_setup.results[0] + assert result == query_handler_mock_setup.results[0] -def test_handle_query_result_single_train_query_handler_returning_continue_finish(): +def test_handle_query_result_single_query_handler_returning_continue_finish(): """ This test calls handle_query_result on a SQLStageGraphExecutionQueryHandler - which was initialized with a state that has a train_query_handler which returns first Finish + which was initialized with a state that has a query_handler which returns first Finish and then Continue. It expects: - that get_current_query_handler is called on the state - - that handle_result is called on the state with the result of the train_query_handler - - that handle_query_result is called on the train_query_handler - - that the result is equal to the result of train_query_handler.handle_query_result + - that handle_result is called on the state with the result of the query_handler + - that handle_query_result is called on the query_handler + - that the result is equal to the result of query_handler.handle_query_result """ def arrange() -> Tuple[TestSetup, MockQueryResult]: state_setup_definition = StateSetupDefinition( - train_query_handler_setup_definitions=[ - TrainQueryHandlerSetupDefinition( + query_handler_setup_definitions=[ + SQLStageQueryHandlerSetupDefinition( result_prototypes=[ Continue(query_list=None, input_query=None), Finish(result=None), @@ -350,45 +350,45 @@ def act( test_setup, query_result = arrange() result = act(test_setup, query_result) - train_query_handler_mock_setup = ( - test_setup.state_mock_setup.train_query_handler_mock_setups[0] + query_handler_mock_setup = ( + test_setup.state_mock_setup.query_handler_mock_setups[0] ) test_setup.state_mock_setup.state.assert_has_calls( [ call.get_current_query_handler(), - call.handle_result(train_query_handler_mock_setup.results[1]), + call.handle_result(query_handler_mock_setup.results[1]), ] ) mock_cast( - train_query_handler_mock_setup.train_query_handler.handle_query_result + query_handler_mock_setup.query_handler.handle_query_result ).assert_called_once_with(query_result) mock_cast( - train_query_handler_mock_setup.train_query_handler.start + query_handler_mock_setup.query_handler.start ).assert_not_called() - assert result == train_query_handler_mock_setup.results[1] + assert result == query_handler_mock_setup.results[1] -def test_start_two_train_query_handler_returning_finish(): +def test_start_two_query_handler_returning_finish(): """ This test calls start on a newly created SQLStageGraphExecutionQueryHandler - which was initialized with a state that has two train_query_handler which return Finish + which was initialized with a state that has two query_handler which return Finish It expects: - that get_current_query_handler is called on the state - - that handle_result is called on the state with the result of the first train_query_handler + - that handle_result is called on the state with the result of the first query_handler - that get_current_query_handler is called on the state - - that handle_result is called on the state with the result of the second train_query_handler - - that start is called on the first train_query_handler - - that start is called on the second train_query_handler - - that the result is equal to the result of the second train_query_handler.start + - that handle_result is called on the state with the result of the second query_handler + - that start is called on the first query_handler + - that start is called on the second query_handler + - that the result is equal to the result of the second query_handler.start """ def arrange() -> TestSetup: state_setup_definition = StateSetupDefinition( - train_query_handler_setup_definitions=[ - TrainQueryHandlerSetupDefinition( + query_handler_setup_definitions=[ + SQLStageQueryHandlerSetupDefinition( result_prototypes=[Finish(result=None)] ), - TrainQueryHandlerSetupDefinition( + SQLStageQueryHandlerSetupDefinition( result_prototypes=[Finish(result=None)] ), ] @@ -404,41 +404,41 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]: test_setup = arrange() result = act(test_setup) - train_query_handler_mock_setups = ( - test_setup.state_mock_setup.train_query_handler_mock_setups + query_handler_mock_setups = ( + test_setup.state_mock_setup.query_handler_mock_setups ) test_setup.state_mock_setup.state.assert_has_calls( [ call.get_current_query_handler(), - call.handle_result(train_query_handler_mock_setups[0].results[0]), + call.handle_result(query_handler_mock_setups[0].results[0]), call.get_current_query_handler(), - call.handle_result(train_query_handler_mock_setups[1].results[0]), + call.handle_result(query_handler_mock_setups[1].results[0]), ] ) mock_cast( - train_query_handler_mock_setups[0].train_query_handler.start + query_handler_mock_setups[0].query_handler.start ).assert_called_once() mock_cast( - train_query_handler_mock_setups[1].train_query_handler.start + query_handler_mock_setups[1].query_handler.start ).assert_called_once() - assert result == train_query_handler_mock_setups[1].results[0] + assert result == query_handler_mock_setups[1].results[0] -def test_start_two_train_query_handler_returning_continue_finish_part1(): +def test_start_two_query_handler_returning_continue_finish_part1(): """ This test calls start on a newly created SQLStageGraphExecutionQueryHandler - which was initialized with a state that has two train_query_handler which returns first Continue + which was initialized with a state that has two query_handler which returns first Continue and then Finish. It expects: - that get_current_query_handler is called on the state - - that handle_result is called on the state with the first result of the first train_query_handler - - that start is called on the first train_query_handler - - that the result is equal to the result of the second train_query_handler.start + - that handle_result is called on the state with the first result of the first query_handler + - that start is called on the first query_handler + - that the result is equal to the result of the second query_handler.start """ def arrange() -> TestSetup: test_setup = ( - create_test_setup_with_two_train_query_handler_returning_continue_finish() + create_test_setup_with_two_query_handler_returning_continue_finish() ) test_setup.reset_mock() return test_setup @@ -450,44 +450,44 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]: test_setup = arrange() result = act(test_setup) - train_query_handler_mock_setups = ( - test_setup.state_mock_setup.train_query_handler_mock_setups + query_handler_mock_setups = ( + test_setup.state_mock_setup.query_handler_mock_setups ) test_setup.state_mock_setup.state.assert_has_calls( [ call.get_current_query_handler(), - call.handle_result(train_query_handler_mock_setups[0].results[0]), + call.handle_result(query_handler_mock_setups[0].results[0]), ] ) mock_cast( - train_query_handler_mock_setups[0].train_query_handler.start + query_handler_mock_setups[0].query_handler.start ).assert_called_once() mock_cast( - train_query_handler_mock_setups[1].train_query_handler.start + query_handler_mock_setups[1].query_handler.start ).assert_not_called() mock_cast( - train_query_handler_mock_setups[1].train_query_handler.handle_query_result + query_handler_mock_setups[1].query_handler.handle_query_result ).assert_not_called() - assert result == train_query_handler_mock_setups[0].results[0] + assert result == query_handler_mock_setups[0].results[0] -def test_handle_query_result_two_train_query_handler_returning_continue_finish_part2(): +def test_handle_query_result_two_query_handler_returning_continue_finish_part2(): """ - This test uses test_start_two_train_query_handler_returning_continue_finish_part1 as setup and + This test uses test_start_two_query_handler_returning_continue_finish_part1 as setup and calls again handle_query_result. It expects: - that get_current_query_handler is called on the state - - that handle_result is called on the state with the second result of the first train_query_handler + - that handle_result is called on the state with the second result of the first query_handler - that get_current_query_handler is called on the state - - that handle_result is called on the state with the first result of the second train_query_handler - - that handle_query_result is called on the first train_query_handler - - that start is called on the second train_query_handler - - that the result is equal to the result of the second train_query_handler.start + - that handle_result is called on the state with the first result of the second query_handler + - that handle_query_result is called on the first query_handler + - that start is called on the second query_handler + - that the result is equal to the result of the second query_handler.start """ def arrange() -> Tuple[TestSetup, QueryResult]: test_setup = ( - create_test_setup_with_two_train_query_handler_returning_continue_finish() + create_test_setup_with_two_query_handler_returning_continue_finish() ) test_setup.execution_query_handler.start() test_setup.reset_mock() @@ -503,46 +503,46 @@ def act( test_setup, query_result = arrange() result = act(test_setup, query_result) - train_query_handler_mock_setups = ( - test_setup.state_mock_setup.train_query_handler_mock_setups + query_handler_mock_setups = ( + test_setup.state_mock_setup.query_handler_mock_setups ) test_setup.state_mock_setup.state.assert_has_calls( [ call.get_current_query_handler(), - call.handle_result(train_query_handler_mock_setups[0].results[1]), + call.handle_result(query_handler_mock_setups[0].results[1]), call.get_current_query_handler(), - call.handle_result(train_query_handler_mock_setups[1].results[0]), + call.handle_result(query_handler_mock_setups[1].results[0]), ] ) mock_cast( - train_query_handler_mock_setups[0].train_query_handler.start + query_handler_mock_setups[0].query_handler.start ).assert_not_called() mock_cast( - train_query_handler_mock_setups[0].train_query_handler.handle_query_result + query_handler_mock_setups[0].query_handler.handle_query_result ).assert_called_once() mock_cast( - train_query_handler_mock_setups[1].train_query_handler.start + query_handler_mock_setups[1].query_handler.start ).assert_called_once() mock_cast( - train_query_handler_mock_setups[1].train_query_handler.handle_query_result + query_handler_mock_setups[1].query_handler.handle_query_result ).assert_not_called() - assert result == train_query_handler_mock_setups[1].results[0] + assert result == query_handler_mock_setups[1].results[0] -def test_handle_query_result_two_train_query_handler_returning_continue_finish_part3(): +def test_handle_query_result_two_query_handler_returning_continue_finish_part3(): """ - This test uses test_start_two_train_query_handler_returning_continue_finish_part2 as setup and + This test uses test_start_two_query_handler_returning_continue_finish_part2 as setup and calls again handle_query_result. It expects: - that get_current_query_handler is called on the state - - that handle_result is called on the state with the second result of the second train_query_handler - - that handle_query_result is called on the second train_query_handler - - that the result is equal to the result of the second train_query_handler.handle_query_result + - that handle_result is called on the state with the second result of the second query_handler + - that handle_query_result is called on the second query_handler + - that the result is equal to the result of the second query_handler.handle_query_result """ def arrange() -> Tuple[TestSetup, QueryResult]: test_setup = ( - create_test_setup_with_two_train_query_handler_returning_continue_finish() + create_test_setup_with_two_query_handler_returning_continue_finish() ) query_result1: MockQueryResult = create_autospec(QueryResult) test_setup.execution_query_handler.start() @@ -560,25 +560,25 @@ def act( test_setup, query_result = arrange() result = act(test_setup, query_result) - train_query_handler_mock_setups = ( - test_setup.state_mock_setup.train_query_handler_mock_setups + query_handler_mock_setups = ( + test_setup.state_mock_setup.query_handler_mock_setups ) test_setup.state_mock_setup.state.assert_has_calls( [ call.get_current_query_handler(), - call.handle_result(train_query_handler_mock_setups[1].results[1]), + call.handle_result(query_handler_mock_setups[1].results[1]), ] ) mock_cast( - train_query_handler_mock_setups[0].train_query_handler.start + query_handler_mock_setups[0].query_handler.start ).assert_not_called() mock_cast( - train_query_handler_mock_setups[0].train_query_handler.handle_query_result + query_handler_mock_setups[0].query_handler.handle_query_result ).assert_not_called() mock_cast( - train_query_handler_mock_setups[1].train_query_handler.start + query_handler_mock_setups[1].query_handler.start ).assert_not_called() mock_cast( - train_query_handler_mock_setups[1].train_query_handler.handle_query_result + query_handler_mock_setups[1].query_handler.handle_query_result ).assert_called_once_with(query_result) - assert result == train_query_handler_mock_setups[1].results[1] + assert result == query_handler_mock_setups[1].results[1] diff --git a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_state_diamond.py b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_state_diamond.py index 8f6ccee6..f50ec023 100644 --- a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_state_diamond.py +++ b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_state_diamond.py @@ -18,7 +18,7 @@ assert_reference_counting_bag_not_called, assert_release_on_query_handler_context_for_stage, assert_stage_not_called, - assert_stage_train_query_handler_created, + assert_stage_query_handler_created, ) from tests.unit_tests.sql_stage_graph.stage_graph_execution_query_handler.state_test_setup import ( TestSetup, @@ -94,7 +94,7 @@ def act( result = act(test_setup) assert_reference_counting_bag_creation(test_setup) - assert_stage_train_query_handler_created( + assert_stage_query_handler_created( test_setup, stage_index=0, stage_inputs=[test_setup.state_setup.sql_stage_input_output], @@ -102,7 +102,7 @@ def act( assert_stage_not_called(test_setup, stage_index=1) assert_stage_not_called(test_setup, stage_index=2) assert_stage_not_called(test_setup, stage_index=3) - assert result == test_setup.stage_setups[0].train_query_handler + assert result == test_setup.stage_setups[0].query_handler def test_handle_result_diamond_return_finish_part2(): @@ -110,7 +110,7 @@ def test_handle_result_diamond_return_finish_part2(): Test handle_result after the creation of a state with stages arranged in a diamond where the stages return directly Finish, after the first call to handle_result. Note: The state creates for the second stage a new - train_query_handler which gets the output of the first + query_handler which gets the output of the first stage as input, this is important because also the third stage got the output of the first stage as input. """ @@ -135,7 +135,7 @@ def act(test_setup: TestSetup) -> ResultHandlerReturnValue: assert_reference_counting_bag_not_called(test_setup) assert_release_on_query_handler_context_for_stage(test_setup, stage_index=0) - assert_stage_train_query_handler_created( + assert_stage_query_handler_created( test_setup, stage_index=1, stage_inputs=[test_setup.stage_setups[0].results[0].result], @@ -181,7 +181,7 @@ def act( assert_stage_not_called(test_setup, stage_index=1) assert_stage_not_called(test_setup, stage_index=2) assert_stage_not_called(test_setup, stage_index=3) - assert result == test_setup.stage_setups[1].train_query_handler + assert result == test_setup.stage_setups[1].query_handler def test_handle_result_diamond_return_finish_part4(): @@ -189,7 +189,7 @@ def test_handle_result_diamond_return_finish_part4(): Test handle_result on a state with stages arranged in a diamond where the stages return directly Finish, after the first call to handle_result. Note: The state creates for the third stage a new - train_query_handler which gets the output of the first + query_handler which gets the output of the first stage as input, this is important because also the second stage got the output of the first stage as input. """ @@ -219,7 +219,7 @@ def act(test_setup: TestSetup) -> ResultHandlerReturnValue: assert_reference_counting_bag_not_called(test_setup) assert_stage_not_called(test_setup, stage_index=0) assert_release_on_query_handler_context_for_stage(test_setup, stage_index=1) - assert_stage_train_query_handler_created( + assert_stage_query_handler_created( test_setup, stage_index=2, stage_inputs=[test_setup.stage_setups[0].results[0].result], @@ -268,7 +268,7 @@ def act( assert_stage_not_called(test_setup, stage_index=1) assert_stage_not_called(test_setup, stage_index=2) assert_stage_not_called(test_setup, stage_index=3) - assert result == test_setup.stage_setups[2].train_query_handler + assert result == test_setup.stage_setups[2].query_handler def test_handle_result_diamond_return_finish_part6(): @@ -276,7 +276,7 @@ def test_handle_result_diamond_return_finish_part6(): Test handle_result on a state with stages arranged in a diamond where the stages return directly Finish, after the second call to handle_result. Note: The state creates for the third stage a new - train_query_handler which gets the output of the second + query_handler which gets the output of the second and third stage as input, """ @@ -310,7 +310,7 @@ def act(test_setup: TestSetup) -> ResultHandlerReturnValue: assert_stage_not_called(test_setup, stage_index=0) assert_stage_not_called(test_setup, stage_index=1) assert_release_on_query_handler_context_for_stage(test_setup, stage_index=2) - assert_stage_train_query_handler_created( + assert_stage_query_handler_created( test_setup, stage_index=3, stage_inputs=[ @@ -365,7 +365,7 @@ def act( assert_stage_not_called(test_setup, stage_index=1) assert_stage_not_called(test_setup, stage_index=2) assert_stage_not_called(test_setup, stage_index=3) - assert result == test_setup.stage_setups[3].train_query_handler + assert result == test_setup.stage_setups[3].query_handler def test_handle_result_diamond_return_finish_part8(): diff --git a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_state_single_stage.py b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_state_single_stage.py index 0d13cfd6..f0a41edc 100644 --- a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_state_single_stage.py +++ b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_state_single_stage.py @@ -18,7 +18,7 @@ assert_reference_counting_bag_not_called, assert_release_on_query_handler_context_for_stage, assert_stage_not_called, - assert_stage_train_query_handler_created, + assert_stage_query_handler_created, ) from tests.unit_tests.sql_stage_graph.stage_graph_execution_query_handler.state_test_setup import ( TestSetup, @@ -63,12 +63,12 @@ def act( result = act(test_setup) assert_reference_counting_bag_creation(test_setup) - assert_stage_train_query_handler_created( + assert_stage_query_handler_created( test_setup, stage_index=0, stage_inputs=[test_setup.state_setup.sql_stage_input_output], ) - assert test_setup.stage_setups[0].train_query_handler == result + assert test_setup.stage_setups[0].query_handler == result def test_handle_result_single_stage_return_finish(): @@ -160,12 +160,12 @@ def act( result = act(test_setup) assert_reference_counting_bag_creation(test_setup) - assert_stage_train_query_handler_created( + assert_stage_query_handler_created( test_setup, stage_index=0, stage_inputs=[test_setup.state_setup.sql_stage_input_output], ) - assert test_setup.stage_setups[0].train_query_handler == result + assert test_setup.stage_setups[0].query_handler == result def test_handle_result_single_stage_return_continue_finish_part1(): @@ -242,7 +242,7 @@ def act( assert_reference_counting_bag_not_called(test_setup) assert_parent_query_handler_context_not_called(test_setup) assert_stage_not_called(test_setup, stage_index=0) - assert result == test_setup.stage_setups[0].train_query_handler + assert result == test_setup.stage_setups[0].query_handler def test_handle_result_single_stage_return_continue_finish_part3(): diff --git a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_state_two_stage.py b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_state_two_stage.py index 26e3bce9..00474100 100644 --- a/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_state_two_stage.py +++ b/tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_state_two_stage.py @@ -18,7 +18,7 @@ assert_reference_counting_bag_not_called, assert_release_on_query_handler_context_for_stage, assert_stage_not_called, - assert_stage_train_query_handler_created, + assert_stage_query_handler_created, ) from tests.unit_tests.sql_stage_graph.stage_graph_execution_query_handler.state_test_setup import ( TestSetup, @@ -70,13 +70,13 @@ def act( result = act(test_setup) assert_reference_counting_bag_creation(test_setup) - assert_stage_train_query_handler_created( + assert_stage_query_handler_created( test_setup, stage_index=0, stage_inputs=[test_setup.state_setup.sql_stage_input_output], ) assert_stage_not_called(test_setup, stage_index=1) - assert result == test_setup.stage_setups[0].train_query_handler + assert result == test_setup.stage_setups[0].query_handler def test_handle_result_two_stage_return_finish_part2(): @@ -85,7 +85,7 @@ def test_handle_result_two_stage_return_finish_part2(): where the stages return directly Finish and a single call to get_current_query_handler. Note: The state creates for the second stage a new - train_query_handler which gets the output of the previous + query_handler which gets the output of the previous stage as input. """ @@ -112,7 +112,7 @@ def act(test_setup: TestSetup) -> ResultHandlerReturnValue: assert_reference_counting_bag_not_called(test_setup) assert_release_on_query_handler_context_for_stage(test_setup, stage_index=0) - assert_stage_train_query_handler_created( + assert_stage_query_handler_created( test_setup, stage_index=1, stage_inputs=[test_setup.stage_setups[0].results[0].result], @@ -157,7 +157,7 @@ def act( assert_parent_query_handler_context_not_called(test_setup) assert_stage_not_called(test_setup, stage_index=0) assert_stage_not_called(test_setup, stage_index=1) - assert result == test_setup.stage_setups[1].train_query_handler + assert result == test_setup.stage_setups[1].query_handler def test_handle_result_two_stage_return_finish_part4(): diff --git a/tests/unit_tests/sql_stage_graph/test_sql_stage_train_query_handler_input.py b/tests/unit_tests/sql_stage_graph/test_sql_stage_train_query_handler_input.py index ee074d57..d7a47aed 100644 --- a/tests/unit_tests/sql_stage_graph/test_sql_stage_train_query_handler_input.py +++ b/tests/unit_tests/sql_stage_graph/test_sql_stage_train_query_handler_input.py @@ -10,7 +10,7 @@ SQLStageInputOutput, ) from exasol.analytics.query_handler.graph.stage.sql.sql_stage_query_handler import ( - SQLStageTrainQueryHandlerInput, + SQLStageQueryHandlerInput, ) @@ -19,7 +19,7 @@ def test_empty_stage_inputs(): AbstractBucketFSLocation ) with pytest.raises(AssertionError, match="Empty sql_stage_inputs not allowed."): - SQLStageTrainQueryHandlerInput( + SQLStageQueryHandlerInput( sql_stage_inputs=[], result_bucketfs_location=bucketfs_location ) @@ -31,7 +31,7 @@ def test_non_empty_stage_inputs(): sql_stage_input: Union[SQLStageInputOutput, MagicMock] = create_autospec( SQLStageInputOutput ) - obj = SQLStageTrainQueryHandlerInput( + obj = SQLStageQueryHandlerInput( sql_stage_inputs=[sql_stage_input], result_bucketfs_location=bucketfs_location ) assert ( @@ -47,10 +47,10 @@ def test_equality(): sql_stage_input: Union[SQLStageInputOutput, MagicMock] = create_autospec( SQLStageInputOutput ) - obj1 = SQLStageTrainQueryHandlerInput( + obj1 = SQLStageQueryHandlerInput( sql_stage_inputs=[sql_stage_input], result_bucketfs_location=bucketfs_location ) - obj2 = SQLStageTrainQueryHandlerInput( + obj2 = SQLStageQueryHandlerInput( sql_stage_inputs=[sql_stage_input], result_bucketfs_location=bucketfs_location ) assert obj1 == obj2 @@ -66,10 +66,10 @@ def test_inequality_sql_stage_input(): sql_stage_input2: Union[SQLStageInputOutput, MagicMock] = create_autospec( SQLStageInputOutput ) - obj1 = SQLStageTrainQueryHandlerInput( + obj1 = SQLStageQueryHandlerInput( sql_stage_inputs=[sql_stage_input1], result_bucketfs_location=bucketfs_location ) - obj2 = SQLStageTrainQueryHandlerInput( + obj2 = SQLStageQueryHandlerInput( sql_stage_inputs=[sql_stage_input2], result_bucketfs_location=bucketfs_location ) assert obj1 != obj2 @@ -85,10 +85,10 @@ def test_inequality_bucketfs_location(): sql_stage_input: Union[SQLStageInputOutput, MagicMock] = create_autospec( SQLStageInputOutput ) - obj1 = SQLStageTrainQueryHandlerInput( + obj1 = SQLStageQueryHandlerInput( sql_stage_inputs=[sql_stage_input], result_bucketfs_location=bucketfs_location1 ) - obj2 = SQLStageTrainQueryHandlerInput( + obj2 = SQLStageQueryHandlerInput( sql_stage_inputs=[sql_stage_input], result_bucketfs_location=bucketfs_location2 ) assert obj1 != obj2