From 5921a985408638c31f9ef06cee3493479be9d4e7 Mon Sep 17 00:00:00 2001 From: ckunki Date: Fri, 22 Nov 2024 10:56:02 +0100 Subject: [PATCH] Formatted code --- .../context/proxy/bucketfs_location_proxy.py | 2 +- .../top_level_query_handler_context.py | 2 +- .../query_handler/deployment/deploy.py | 6 ++++- .../deployment/scripts_deployer.py | 2 +- .../analytics/query_handler/deployment/slc.py | 5 +++- .../query_handler/graph/execution_graph.py | 2 +- .../analytics/query_handler/graph/result.py | 8 +++--- .../graph/stage/sql/execution/input.py | 2 +- .../sql/execution/query_handler_state.py | 2 +- .../stage/sql/sql_stage_query_handler.py | 4 ++- .../query/result/python_query_result.py | 8 +++--- .../query/result/udf_query_result.py | 2 +- .../query_handler/udf/runner/call_udf.py | 2 +- .../analytics/query_handler/udf/runner/udf.py | 25 ++++++++----------- exasol/analytics/schema/__init__.py | 14 ++++++++--- exasol/analytics/schema/column_builder.py | 4 +-- exasol/analytics/schema/column_name.py | 7 +++--- .../analytics/schema/column_name_builder.py | 1 + exasol/analytics/schema/dbobject_name_impl.py | 3 ++- .../schema/dbobject_name_with_schema_impl.py | 2 +- exasol/analytics/schema/exasol_identifier.py | 1 + .../schema/exasol_identifier_impl.py | 2 +- exasol/analytics/schema/table_builder.py | 8 +++--- .../analytics/schema/table_like_name_impl.py | 4 ++- exasol/analytics/schema/table_name_builder.py | 3 ++- exasol/analytics/schema/udf_name_builder.py | 3 ++- exasol/analytics/schema/udf_name_impl.py | 4 ++- exasol/analytics/schema/view_name_builder.py | 3 ++- .../analytics/sql_executor/pyexasol_impl.py | 2 +- .../udf/communication/broadcast_operation.py | 1 - .../discovery/localhost/communicator.py | 8 ++++-- .../discovery/multi_node/communicator.py | 8 ++++-- .../udf/communication/gather_operation.py | 18 ++++++------- .../background_listener_interface.py | 25 ++++++++++++------- .../background_listener_thread.py | 19 +++++++------- .../peer_communicator/peer_communicator.py | 8 +++--- .../socket_factory/fault_injection.py | 2 +- .../socket_factory/zmq_wrapper.py | 2 +- exasol/analytics/udf/utils/context_wrapper.py | 2 +- exasol/analytics/udf/utils/iterators.py | 2 +- exasol/analytics/utils/errors.py | 2 +- 41 files changed, 132 insertions(+), 98 deletions(-) diff --git a/exasol/analytics/query_handler/context/proxy/bucketfs_location_proxy.py b/exasol/analytics/query_handler/context/proxy/bucketfs_location_proxy.py index cf5c8db1..5b821c09 100644 --- a/exasol/analytics/query_handler/context/proxy/bucketfs_location_proxy.py +++ b/exasol/analytics/query_handler/context/proxy/bucketfs_location_proxy.py @@ -1,6 +1,6 @@ import logging -import exasol.bucketfs as bfs # type: ignore[import-untyped] +import exasol.bucketfs as bfs # type: ignore[import-untyped] from exasol.analytics.query_handler.context.proxy.object_proxy import ObjectProxy diff --git a/exasol/analytics/query_handler/context/top_level_query_handler_context.py b/exasol/analytics/query_handler/context/top_level_query_handler_context.py index 98032858..9b767a67 100644 --- a/exasol/analytics/query_handler/context/top_level_query_handler_context.py +++ b/exasol/analytics/query_handler/context/top_level_query_handler_context.py @@ -3,7 +3,7 @@ from abc import ABC from typing import Callable, List, Set -import exasol.bucketfs as bfs # type: ignore[import-untyped] +import exasol.bucketfs as bfs # type: ignore[import-untyped] from exasol.analytics.query_handler.context.connection_name import ( ConnectionName, diff --git a/exasol/analytics/query_handler/deployment/deploy.py b/exasol/analytics/query_handler/deployment/deploy.py index 68187ac9..6a7e9e95 100644 --- a/exasol/analytics/query_handler/deployment/deploy.py +++ b/exasol/analytics/query_handler/deployment/deploy.py @@ -1,7 +1,11 @@ import logging import click -from exasol.python_extension_common.deployment.language_container_deployer_cli import ( CustomizableParameters, language_container_deployer_main, slc_parameter_formatters, ) # type: ignore[import-untyped] +from exasol.python_extension_common.deployment.language_container_deployer_cli import ( # type: ignore[import-untyped] + CustomizableParameters, + language_container_deployer_main, + slc_parameter_formatters, +) from exasol.analytics.query_handler.deployment import scripts_deployer_cli from exasol.analytics.query_handler.deployment.slc import ( diff --git a/exasol/analytics/query_handler/deployment/scripts_deployer.py b/exasol/analytics/query_handler/deployment/scripts_deployer.py index 877bd32f..65c83580 100644 --- a/exasol/analytics/query_handler/deployment/scripts_deployer.py +++ b/exasol/analytics/query_handler/deployment/scripts_deployer.py @@ -1,6 +1,6 @@ import logging -import pyexasol # type: ignore[import-untyped] +import pyexasol # type: ignore[import-untyped] from exasol.analytics.query_handler.deployment import constants, utils from exasol.analytics.query_handler.deployment.aaf_exasol_lua_script_generator import ( diff --git a/exasol/analytics/query_handler/deployment/slc.py b/exasol/analytics/query_handler/deployment/slc.py index 5178b13a..b23b9eeb 100644 --- a/exasol/analytics/query_handler/deployment/slc.py +++ b/exasol/analytics/query_handler/deployment/slc.py @@ -1,6 +1,9 @@ from contextlib import contextmanager -from exasol.python_extension_common.deployment.language_container_builder import ( LanguageContainerBuilder, find_path_backwards, ) # type: ignore[import-untyped] +from exasol.python_extension_common.deployment.language_container_builder import ( # type: ignore[import-untyped] + LanguageContainerBuilder, + find_path_backwards, +) LANGUAGE_ALIAS = "PYTHON3_AAF" SLC_NAME = "exasol_advanced_analytics_framework_container" diff --git a/exasol/analytics/query_handler/graph/execution_graph.py b/exasol/analytics/query_handler/graph/execution_graph.py index b10c6658..2a33eeb3 100644 --- a/exasol/analytics/query_handler/graph/execution_graph.py +++ b/exasol/analytics/query_handler/graph/execution_graph.py @@ -2,7 +2,7 @@ import typing from typing import Generic, List, Set, Tuple, TypeVar -import networkx as nx # type: ignore[import-untyped] +import networkx as nx # type: ignore[import-untyped] T = TypeVar("T") diff --git a/exasol/analytics/query_handler/graph/result.py b/exasol/analytics/query_handler/graph/result.py index 0aee2867..12242ea6 100644 --- a/exasol/analytics/query_handler/graph/result.py +++ b/exasol/analytics/query_handler/graph/result.py @@ -83,10 +83,10 @@ def _configured_new(cls: Type[_T]): """This function is called for subclasses of classes that declare _Meta as their metaclass.""" return _new(cls, result_type) - result_type.__new__ = _configured_new # type: ignore - result_type.__init__ = _init # type: ignore - result_type.__setattr__ = _setattr # type: ignore - result_type.__delattr__ = _delattr # type: ignore + result_type.__new__ = _configured_new # type: ignore + result_type.__init__ = _init # type: ignore + result_type.__setattr__ = _setattr # type: ignore + result_type.__delattr__ = _delattr # type: ignore return result_type diff --git a/exasol/analytics/query_handler/graph/stage/sql/execution/input.py b/exasol/analytics/query_handler/graph/stage/sql/execution/input.py index de59fcfe..697e7dc6 100644 --- a/exasol/analytics/query_handler/graph/stage/sql/execution/input.py +++ b/exasol/analytics/query_handler/graph/stage/sql/execution/input.py @@ -1,6 +1,6 @@ import dataclasses -import exasol.bucketfs as bfs # type: ignore[import-untyped] +import exasol.bucketfs as bfs # type: ignore[import-untyped] from exasol.analytics.query_handler.graph.stage.sql.input_output import ( SQLStageInputOutput, 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 78387263..5b97b042 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 @@ -60,7 +60,7 @@ def __init__( self._create_current_query_handler() def get_current_query_handler( - self + self, ) -> QueryHandler[List[SQLStageInputOutput], SQLStageInputOutput]: value = self._current_query_handler if value is None: 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 d4e11b00..1c986ae2 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 @@ -2,7 +2,9 @@ from abc import ABC from typing import List, Sized -from exasol_bucketfs_utils_python.abstract_bucketfs_location import AbstractBucketFSLocation # type: ignore[import-untyped] +from exasol_bucketfs_utils_python.abstract_bucketfs_location import ( # type: ignore[import-untyped] + AbstractBucketFSLocation, +) from exasol.analytics.query_handler.graph.stage.sql.input_output import ( SQLStageInputOutput, diff --git a/exasol/analytics/query_handler/query/result/python_query_result.py b/exasol/analytics/query_handler/query/result/python_query_result.py index 53cc2f32..57dee21b 100644 --- a/exasol/analytics/query_handler/query/result/python_query_result.py +++ b/exasol/analytics/query_handler/query/result/python_query_result.py @@ -1,7 +1,7 @@ from typing import Any, Iterator, List, Optional, Tuple, Union -import pandas as pd # type: ignore[import-untyped] -from exasol_udf_mock_python.column import Column # type: ignore[import-untyped] +import pandas as pd # type: ignore[import-untyped] +from exasol_udf_mock_python.column import Column # type: ignore[import-untyped] from exasol.analytics.query_handler.query.result.interface import QueryResult, Row @@ -52,9 +52,7 @@ def _range(self, num_rows: Union[int, str]) -> range: return range(num_rows - 1) if num_rows == "all": return range(len(self._data) - 1) - raise ValueError( - f'num_rows must be an int or str "all" but is {num_rows}' - ) + raise ValueError(f'num_rows must be an int or str "all" but is {num_rows}') def fetch_as_dataframe( self, num_rows: Union[int, str], start_col=0 diff --git a/exasol/analytics/query_handler/query/result/udf_query_result.py b/exasol/analytics/query_handler/query/result/udf_query_result.py index f9dbc657..0e36212c 100644 --- a/exasol/analytics/query_handler/query/result/udf_query_result.py +++ b/exasol/analytics/query_handler/query/result/udf_query_result.py @@ -51,7 +51,7 @@ def rowcount(self) -> int: def fetch_as_dataframe( self, num_rows: Union[str, int], start_col: int = 0 - ) -> "pandas.DataFrame": # type: ignore + ) -> "pandas.DataFrame": # type: ignore df = self._ctx.get_dataframe(num_rows, start_col=self._start_col) self._initialized = True if df is None: diff --git a/exasol/analytics/query_handler/udf/runner/call_udf.py b/exasol/analytics/query_handler/udf/runner/call_udf.py index 430e97c9..fb74a8ea 100644 --- a/exasol/analytics/query_handler/udf/runner/call_udf.py +++ b/exasol/analytics/query_handler/udf/runner/call_udf.py @@ -1,6 +1,6 @@ from exasol.analytics.query_handler.udf.runner.udf import QueryHandlerRunnerUDF -udf = QueryHandlerRunnerUDF(exa) # type: ignore +udf = QueryHandlerRunnerUDF(exa) # type: ignore def run(ctx): diff --git a/exasol/analytics/query_handler/udf/runner/udf.py b/exasol/analytics/query_handler/udf/runner/udf.py index 96a3fd40..f8b1d97f 100644 --- a/exasol/analytics/query_handler/udf/runner/udf.py +++ b/exasol/analytics/query_handler/udf/runner/udf.py @@ -8,11 +8,10 @@ from io import BytesIO from typing import Any, List, Optional, Tuple -import exasol.bucketfs as bfs # type: ignore[import-untyped] -import joblib # type: ignore[import-untyped] +import exasol.bucketfs as bfs # type: ignore[import-untyped] +import joblib # type: ignore[import-untyped] from exasol.analytics.query_handler.context.scope import ScopeQueryHandlerContext -from exasol.analytics.query_handler.udf.interface import UDFQueryHandlerFactory from exasol.analytics.query_handler.context.top_level_query_handler_context import ( TopLevelQueryHandlerContext, ) @@ -21,6 +20,7 @@ from exasol.analytics.query_handler.query.select import SelectQueryWithColumnDefinition from exasol.analytics.query_handler.result import Continue, Finish, Result from exasol.analytics.query_handler.udf.connection_lookup import UDFConnectionLookup +from exasol.analytics.query_handler.udf.interface import UDFQueryHandlerFactory from exasol.analytics.query_handler.udf.runner.state import QueryHandlerRunnerState from exasol.analytics.schema import ( Column, @@ -192,7 +192,9 @@ def handle_query_handler_result_continue( ) self.release_and_create_query_handler_context_if_input_query(current_state) if current_state.input_query_query_handler_context is None: - raise UninitializedAttributeError("Current state has no input query handler context.") + raise UninitializedAttributeError( + "Current state has no input query handler context." + ) udf_result.input_query_view, udf_result.input_query = self._wrap_return_query( current_state.input_query_query_handler_context, query_handler_result.input_query, @@ -230,9 +232,7 @@ def _get_parameter(self, ctx) -> UDFParameter: ) def _create_bucketfs_location(self) -> bfs.path.PathLike: - bfscon = self.exa.get_connection( - self.parameter.temporary_bfs_location_conn - ) + bfscon = self.exa.get_connection(self.parameter.temporary_bfs_location_conn) bfs_location = create_bucketfs_location_from_conn_object(bfscon) return bfs_location.joinpath( self.parameter.temporary_bfs_location_directory @@ -249,15 +249,11 @@ def _create_state_or_load_latest_state(self) -> QueryHandlerRunnerState: def _query_handler_factory(self) -> UDFQueryHandlerFactory: module_name = self.parameter.python_class_module if not module_name: - raise ValueError( - "UDFQueryHandler parameters must define a python module" - ) + raise ValueError("UDFQueryHandler parameters must define a python module") module = importlib.import_module(module_name) class_name = self.parameter.python_class_name if not class_name: - raise ValueError( - "UDFQueryHandler parameters must define a factory class" - ) + raise ValueError("UDFQueryHandler parameters must define a factory class") factory = getattr(module, class_name) if not factory: raise ValueError( @@ -277,7 +273,8 @@ def _create_state(self) -> QueryHandlerRunnerState: ) str_parameter = self.parameter.parameter or "" query_handler_obj = self._query_handler_factory.create( - str_parameter, context, + str_parameter, + context, ) query_handler_state = QueryHandlerRunnerState( top_level_query_handler_context=context, diff --git a/exasol/analytics/schema/__init__.py b/exasol/analytics/schema/__init__.py index 92826833..b8932b62 100644 --- a/exasol/analytics/schema/__init__.py +++ b/exasol/analytics/schema/__init__.py @@ -4,16 +4,22 @@ from exasol.analytics.schema.column_name_builder import ColumnNameBuilder from exasol.analytics.schema.column_type import ColumnType from exasol.analytics.schema.connection_object_name import ConnectionObjectName -from exasol.analytics.schema.connection_object_name_builder import ConnectionObjectNameBuilder +from exasol.analytics.schema.connection_object_name_builder import ( + ConnectionObjectNameBuilder, +) from exasol.analytics.schema.connection_object_name_impl import ConnectionObjectNameImpl from exasol.analytics.schema.dbobject import DBObject from exasol.analytics.schema.dbobject_name import DBObjectName from exasol.analytics.schema.dbobject_name_impl import DBObjectNameImpl from exasol.analytics.schema.dbobject_name_with_schema import DBObjectNameWithSchema -from exasol.analytics.schema.dbobject_name_with_schema_impl import DBObjectNameWithSchemaImpl +from exasol.analytics.schema.dbobject_name_with_schema_impl import ( + DBObjectNameWithSchemaImpl, +) from exasol.analytics.schema.exasol_identifier import ExasolIdentifier -from exasol.analytics.schema.exasol_identifier_impl import ExasolIdentifierImpl -from exasol.analytics.schema.exasol_identifier_impl import UnicodeCategories +from exasol.analytics.schema.exasol_identifier_impl import ( + ExasolIdentifierImpl, + UnicodeCategories, +) from exasol.analytics.schema.experiment_name import ExperimentName from exasol.analytics.schema.schema_name import SchemaName from exasol.analytics.schema.table import Table diff --git a/exasol/analytics/schema/column_builder.py b/exasol/analytics/schema/column_builder.py index bcd6c0b2..2e74b728 100644 --- a/exasol/analytics/schema/column_builder.py +++ b/exasol/analytics/schema/column_builder.py @@ -1,4 +1,5 @@ from typing import Union + from typeguard import TypeCheckError from exasol.analytics.schema.column import Column @@ -9,8 +10,7 @@ class ColumnBuilder: def __init__(self, column: Union[Column, None] = None): self._name, self._type = ( - (None, None) if column is None - else (column.name, column.type) + (None, None) if column is None else (column.name, column.type) ) def with_name(self, name: ColumnName) -> "ColumnBuilder": diff --git a/exasol/analytics/schema/column_name.py b/exasol/analytics/schema/column_name.py index 0f6d8e54..fa666e96 100644 --- a/exasol/analytics/schema/column_name.py +++ b/exasol/analytics/schema/column_name.py @@ -1,12 +1,13 @@ -from typeguard import typechecked from typing import Optional -from exasol.analytics.schema.exasol_identifier import ExasolIdentifier +from typeguard import typechecked + +from exasol.analytics.schema.exasol_identifier import ExasolIdentifier, qualified_name from exasol.analytics.schema.exasol_identifier_impl import ExasolIdentifierImpl from exasol.analytics.schema.table_like_name import TableLikeName from exasol.analytics.utils.hash_generation_for_object import generate_hash_for_object from exasol.analytics.utils.repr_generation_for_object import generate_repr_for_object -from exasol.analytics.schema.exasol_identifier import qualified_name + class ColumnName(ExasolIdentifierImpl): @typechecked diff --git a/exasol/analytics/schema/column_name_builder.py b/exasol/analytics/schema/column_name_builder.py index 298424c8..8ba4d1ef 100644 --- a/exasol/analytics/schema/column_name_builder.py +++ b/exasol/analytics/schema/column_name_builder.py @@ -1,6 +1,7 @@ from typing import Optional from typeguard import TypeCheckError + from exasol.analytics.schema.column_name import ColumnName from exasol.analytics.schema.table_like_name import TableLikeName diff --git a/exasol/analytics/schema/dbobject_name_impl.py b/exasol/analytics/schema/dbobject_name_impl.py index 2c3d1b0e..f4c3cefe 100644 --- a/exasol/analytics/schema/dbobject_name_impl.py +++ b/exasol/analytics/schema/dbobject_name_impl.py @@ -1,6 +1,7 @@ -from typeguard import typechecked from typing import Optional +from typeguard import typechecked + from exasol.analytics.schema.dbobject_name import DBObjectName from exasol.analytics.schema.exasol_identifier_impl import ExasolIdentifierImpl from exasol.analytics.utils.hash_generation_for_object import generate_hash_for_object diff --git a/exasol/analytics/schema/dbobject_name_with_schema_impl.py b/exasol/analytics/schema/dbobject_name_with_schema_impl.py index 8b537b87..a179e2a3 100644 --- a/exasol/analytics/schema/dbobject_name_with_schema_impl.py +++ b/exasol/analytics/schema/dbobject_name_with_schema_impl.py @@ -4,10 +4,10 @@ from exasol.analytics.schema.dbobject_name_impl import DBObjectNameImpl from exasol.analytics.schema.dbobject_name_with_schema import DBObjectNameWithSchema +from exasol.analytics.schema.exasol_identifier import qualified_name from exasol.analytics.schema.schema_name import SchemaName from exasol.analytics.utils.hash_generation_for_object import generate_hash_for_object from exasol.analytics.utils.repr_generation_for_object import generate_repr_for_object -from exasol.analytics.schema.exasol_identifier import qualified_name class DBObjectNameWithSchemaImpl(DBObjectNameImpl, DBObjectNameWithSchema): diff --git a/exasol/analytics/schema/exasol_identifier.py b/exasol/analytics/schema/exasol_identifier.py index 73b87575..8de45a67 100644 --- a/exasol/analytics/schema/exasol_identifier.py +++ b/exasol/analytics/schema/exasol_identifier.py @@ -1,6 +1,7 @@ from abc import ABC, abstractmethod from typing import Optional + class ExasolIdentifier(ABC): @property diff --git a/exasol/analytics/schema/exasol_identifier_impl.py b/exasol/analytics/schema/exasol_identifier_impl.py index 477b2fe4..c0e5bf7a 100644 --- a/exasol/analytics/schema/exasol_identifier_impl.py +++ b/exasol/analytics/schema/exasol_identifier_impl.py @@ -1,7 +1,7 @@ import unicodedata +from typing import Optional from typeguard import typechecked -from typing import Optional from exasol.analytics.schema.exasol_identifier import ExasolIdentifier diff --git a/exasol/analytics/schema/table_builder.py b/exasol/analytics/schema/table_builder.py index 994c4509..b694e997 100644 --- a/exasol/analytics/schema/table_builder.py +++ b/exasol/analytics/schema/table_builder.py @@ -1,17 +1,15 @@ from typing import List, Union +from typeguard import TypeCheckError + from exasol.analytics.schema.column import Column from exasol.analytics.schema.table import Table from exasol.analytics.schema.table_name import TableName -from typeguard import TypeCheckError class TableBuilder: def __init__(self, table: Union[Table, None] = None): - self._name, self._columns = ( - (table.name, table.columns) if table - else (None, []) - ) + self._name, self._columns = (table.name, table.columns) if table else (None, []) def with_name(self, name: TableName) -> "TableBuilder": self._name = name diff --git a/exasol/analytics/schema/table_like_name_impl.py b/exasol/analytics/schema/table_like_name_impl.py index d471376d..486c43f7 100644 --- a/exasol/analytics/schema/table_like_name_impl.py +++ b/exasol/analytics/schema/table_like_name_impl.py @@ -2,7 +2,9 @@ from typeguard import typechecked -from exasol.analytics.schema.dbobject_name_with_schema_impl import DBObjectNameWithSchemaImpl +from exasol.analytics.schema.dbobject_name_with_schema_impl import ( + DBObjectNameWithSchemaImpl, +) from exasol.analytics.schema.schema_name import SchemaName from exasol.analytics.schema.table_like_name import TableLikeName diff --git a/exasol/analytics/schema/table_name_builder.py b/exasol/analytics/schema/table_name_builder.py index 6ede6ab2..12d8520d 100644 --- a/exasol/analytics/schema/table_name_builder.py +++ b/exasol/analytics/schema/table_name_builder.py @@ -1,9 +1,10 @@ from typing import Optional, Union +from typeguard import TypeCheckError + from exasol.analytics.schema.schema_name import SchemaName from exasol.analytics.schema.table_name import TableName from exasol.analytics.schema.table_name_impl import TableNameImpl -from typeguard import TypeCheckError class TableNameBuilder: diff --git a/exasol/analytics/schema/udf_name_builder.py b/exasol/analytics/schema/udf_name_builder.py index bfab2412..8ccc9b28 100644 --- a/exasol/analytics/schema/udf_name_builder.py +++ b/exasol/analytics/schema/udf_name_builder.py @@ -1,9 +1,10 @@ from typing import Optional +from typeguard import TypeCheckError + from exasol.analytics.schema.schema_name import SchemaName from exasol.analytics.schema.udf_name import UDFName from exasol.analytics.schema.udf_name_impl import UDFNameImpl -from typeguard import TypeCheckError class UDFNameBuilder: diff --git a/exasol/analytics/schema/udf_name_impl.py b/exasol/analytics/schema/udf_name_impl.py index ed7c65ea..0d945af0 100644 --- a/exasol/analytics/schema/udf_name_impl.py +++ b/exasol/analytics/schema/udf_name_impl.py @@ -2,7 +2,9 @@ from typeguard import typechecked -from exasol.analytics.schema.dbobject_name_with_schema_impl import DBObjectNameWithSchemaImpl +from exasol.analytics.schema.dbobject_name_with_schema_impl import ( + DBObjectNameWithSchemaImpl, +) from exasol.analytics.schema.schema_name import SchemaName from exasol.analytics.schema.udf_name import UDFName diff --git a/exasol/analytics/schema/view_name_builder.py b/exasol/analytics/schema/view_name_builder.py index fc79cf6d..22c3775e 100644 --- a/exasol/analytics/schema/view_name_builder.py +++ b/exasol/analytics/schema/view_name_builder.py @@ -1,9 +1,10 @@ from typing import Optional +from typeguard import TypeCheckError + from exasol.analytics.schema.schema_name import SchemaName from exasol.analytics.schema.view_name import ViewName from exasol.analytics.schema.view_name_impl import ViewNameImpl -from typeguard import TypeCheckError class ViewNameBuilder: diff --git a/exasol/analytics/sql_executor/pyexasol_impl.py b/exasol/analytics/sql_executor/pyexasol_impl.py index 3a829261..9365abfb 100644 --- a/exasol/analytics/sql_executor/pyexasol_impl.py +++ b/exasol/analytics/sql_executor/pyexasol_impl.py @@ -1,6 +1,6 @@ from typing import Any, List, Tuple -import pyexasol # type: ignore[import-untyped] +import pyexasol # type: ignore[import-untyped] from pyexasol import ExaStatement from exasol.analytics.schema import Column, ColumnName, ColumnNameBuilder, ColumnType diff --git a/exasol/analytics/udf/communication/broadcast_operation.py b/exasol/analytics/udf/communication/broadcast_operation.py index 7424c6b7..9852bd89 100644 --- a/exasol/analytics/udf/communication/broadcast_operation.py +++ b/exasol/analytics/udf/communication/broadcast_operation.py @@ -16,7 +16,6 @@ ) from exasol.analytics.utils.errors import UninitializedAttributeError - _LOGGER: FilteringBoundLogger = structlog.getLogger() LOCALHOST_LEADER_RANK = 0 diff --git a/exasol/analytics/udf/communication/discovery/localhost/communicator.py b/exasol/analytics/udf/communication/discovery/localhost/communicator.py index 48c63c41..06be54b0 100644 --- a/exasol/analytics/udf/communication/discovery/localhost/communicator.py +++ b/exasol/analytics/udf/communication/discovery/localhost/communicator.py @@ -1,5 +1,9 @@ -from exasol.analytics.udf.communication.discovery.localhost.discovery_socket import DiscoverySocketFactory -from exasol.analytics.udf.communication.discovery.localhost.discovery_strategy import DiscoveryStrategy +from exasol.analytics.udf.communication.discovery.localhost.discovery_socket import ( + DiscoverySocketFactory, +) +from exasol.analytics.udf.communication.discovery.localhost.discovery_strategy import ( + DiscoveryStrategy, +) from exasol.analytics.udf.communication.ip_address import IPAddress, Port from exasol.analytics.udf.communication.peer_communicator import PeerCommunicator from exasol.analytics.udf.communication.peer_communicator.forward_register_peer_config import ( diff --git a/exasol/analytics/udf/communication/discovery/multi_node/communicator.py b/exasol/analytics/udf/communication/discovery/multi_node/communicator.py index c1d3812c..9306793f 100644 --- a/exasol/analytics/udf/communication/discovery/multi_node/communicator.py +++ b/exasol/analytics/udf/communication/discovery/multi_node/communicator.py @@ -1,5 +1,9 @@ -from exasol.analytics.udf.communication.discovery.multi_node.discovery_socket import DiscoverySocketFactory -from exasol.analytics.udf.communication.discovery.multi_node.discovery_strategy import DiscoveryStrategy +from exasol.analytics.udf.communication.discovery.multi_node.discovery_socket import ( + DiscoverySocketFactory, +) +from exasol.analytics.udf.communication.discovery.multi_node.discovery_strategy import ( + DiscoveryStrategy, +) from exasol.analytics.udf.communication.ip_address import IPAddress, Port from exasol.analytics.udf.communication.peer_communicator import PeerCommunicator from exasol.analytics.udf.communication.peer_communicator.forward_register_peer_config import ( diff --git a/exasol/analytics/udf/communication/gather_operation.py b/exasol/analytics/udf/communication/gather_operation.py index 0853ecca..57281b0c 100644 --- a/exasol/analytics/udf/communication/gather_operation.py +++ b/exasol/analytics/udf/communication/gather_operation.py @@ -29,13 +29,13 @@ class GatherOperation: def __init__( - self, - sequence_number: int, - value: bytes, - localhost_communicator: PeerCommunicator, - multi_node_communicator: Optional[PeerCommunicator], - socket_factory: SocketFactory, - number_of_instances_per_node: int, + self, + sequence_number: int, + value: bytes, + localhost_communicator: PeerCommunicator, + multi_node_communicator: Optional[PeerCommunicator], + socket_factory: SocketFactory, + number_of_instances_per_node: int, ): self._number_of_instances_per_node = number_of_instances_per_node self._socket_factory = socket_factory @@ -44,8 +44,8 @@ def __init__( self._multi_node_communicator = multi_node_communicator self._localhost_communicator = localhost_communicator if ( - multi_node_communicator is None - and localhost_communicator.rank <= LOCALHOST_LEADER_RANK + multi_node_communicator is None + and localhost_communicator.rank <= LOCALHOST_LEADER_RANK ): raise IllegalParametersError( "Trying to initialize GatherOperation" diff --git a/exasol/analytics/udf/communication/peer_communicator/background_listener_interface.py b/exasol/analytics/udf/communication/peer_communicator/background_listener_interface.py index 911e3f1e..1773ca4e 100644 --- a/exasol/analytics/udf/communication/peer_communicator/background_listener_interface.py +++ b/exasol/analytics/udf/communication/peer_communicator/background_listener_interface.py @@ -57,7 +57,6 @@ def create(self, socket_factory: SocketFactory, name: str) -> "SocketWithAddress return SocketWithAddress(socket, address) - class BackgroundListenerInterface: def __init__( @@ -77,8 +76,12 @@ def __init__( self._logger = LOGGER.bind( name=self._name, group_identifier=group_identifier, config=asdict(config) ) - self._out_control = SocketWithAddress.create(socket_factory, f"out_control_socket{id(self)}") - self._in_control = SocketWithAddress.create(socket_factory, f"in_control_socket{id(self)}") + self._out_control = SocketWithAddress.create( + socket_factory, f"out_control_socket{id(self)}" + ) + self._in_control = SocketWithAddress.create( + socket_factory, f"in_control_socket{id(self)}" + ) self._is_ready_to_stop = False self._background_listener_run = BackgroundListenerThread( name=self._name, @@ -104,7 +107,9 @@ def _get_my_connection_info(self) -> ConnectionInfo: generic = deserialize_message(received, messages.Message) message = generic.__root__ if not isinstance(message, messages.MyConnectionInfo): - raise UnexpectedMessageError(f"Unexpected message of type {type(message)}") + raise UnexpectedMessageError( + f"Unexpected message of type {type(message)}" + ) return message.my_connection_info except Exception as e: self._logger.exception("Exception", raw_message=received) @@ -127,11 +132,13 @@ def receive_messages( self, timeout_in_milliseconds: Optional[int] = 0 ) -> Iterator[Tuple[Message, List[Frame]]]: def poll() -> Set[PollerFlag]: - return self._out_control.socket.poll( - flags=PollerFlag.POLLIN, - timeout_in_ms=timeout_in_milliseconds, - ) or set() - + return ( + self._out_control.socket.poll( + flags=PollerFlag.POLLIN, + timeout_in_ms=timeout_in_milliseconds, + ) + or set() + ) while PollerFlag.POLLIN in poll(): message = None diff --git a/exasol/analytics/udf/communication/peer_communicator/background_listener_thread.py b/exasol/analytics/udf/communication/peer_communicator/background_listener_thread.py index 2dcc807d..ff71bd04 100644 --- a/exasol/analytics/udf/communication/peer_communicator/background_listener_thread.py +++ b/exasol/analytics/udf/communication/peer_communicator/background_listener_thread.py @@ -5,7 +5,6 @@ import structlog from structlog.types import FilteringBoundLogger -from exasol.analytics.utils.errors import UninitializedAttributeError from exasol.analytics.udf.communication import messages from exasol.analytics.udf.communication.connection_info import ConnectionInfo from exasol.analytics.udf.communication.ip_address import IPAddress, Port @@ -59,12 +58,13 @@ ) from exasol.analytics.udf.communication.socket_factory.abstract import ( Frame, + Poller, PollerFlag, Socket, SocketFactory, - Poller, SocketType, ) +from exasol.analytics.utils.errors import UninitializedAttributeError LOGGER: FilteringBoundLogger = structlog.get_logger() @@ -108,11 +108,11 @@ class RuntimeSockets: @classmethod def create( - cls, - socket_factory: SocketFactory, - name: str, - in_control_address: str, - out_control_address: str, + cls, + socket_factory: SocketFactory, + name: str, + in_control_address: str, + out_control_address: str, ) -> "RuntimeSockets": def listen_socket(): socket = socket_factory.create_socket(SocketType.ROUTER) @@ -445,7 +445,9 @@ def _create_register_peer_connection(self, message: messages.RegisterPeer): @property def register_peer_connection(self) -> RegisterPeerConnection: if self._register_peer_connection is None: - raise UninitializedAttributeError("Attribute _register_peer_connection is None") + raise UninitializedAttributeError( + "Attribute _register_peer_connection is None" + ) return self._register_peer_connection def _handle_acknowledge_register_peer_message( @@ -459,7 +461,6 @@ def _handle_acknowledge_register_peer_message( peer = message.peer self._peer_state[peer].received_acknowledge_register_peer() - def _handle_register_peer_complete_message( self, message: messages.RegisterPeerComplete ): diff --git a/exasol/analytics/udf/communication/peer_communicator/peer_communicator.py b/exasol/analytics/udf/communication/peer_communicator/peer_communicator.py index bd7897e0..d59faee0 100644 --- a/exasol/analytics/udf/communication/peer_communicator/peer_communicator.py +++ b/exasol/analytics/udf/communication/peer_communicator/peer_communicator.py @@ -38,7 +38,9 @@ def key_for_peer(peer: Peer): ) -def _compute_handle_message_timeout(start_time_ns: int, timeout_in_milliseconds: int) -> int: +def _compute_handle_message_timeout( + start_time_ns: int, timeout_in_milliseconds: int +) -> int: time_difference_ns = time.monotonic_ns() - start_time_ns time_difference_ms = time_difference_ns // 10**6 handle_message_timeout_ms = timeout_in_milliseconds - time_difference_ms @@ -156,9 +158,7 @@ def wait_for_peers(self, timeout_in_milliseconds: Optional[int] = None) -> bool: self._are_all_peers_connected, timeout_in_milliseconds ) - def peers( - self, timeout_in_milliseconds: Optional[int] = None - ) -> List[Peer]: + def peers(self, timeout_in_milliseconds: Optional[int] = None) -> List[Peer]: self.wait_for_peers(timeout_in_milliseconds) if self._are_all_peers_connected(): peers = [peer for peer in self._peer_states.keys()] + [ diff --git a/exasol/analytics/udf/communication/socket_factory/fault_injection.py b/exasol/analytics/udf/communication/socket_factory/fault_injection.py index c336ee72..1283b43a 100644 --- a/exasol/analytics/udf/communication/socket_factory/fault_injection.py +++ b/exasol/analytics/udf/communication/socket_factory/fault_injection.py @@ -64,7 +64,7 @@ def receive(self) -> bytes: def receive_multipart(self) -> List[abstract.Frame]: message = self._internal_socket.receive_multipart() converted_message = [Frame(frame) for frame in message] - return converted_message # type: ignore + return converted_message # type: ignore def send_multipart(self, message: List[abstract.Frame]): def convert_frame(frame: abstract.Frame): diff --git a/exasol/analytics/udf/communication/socket_factory/zmq_wrapper.py b/exasol/analytics/udf/communication/socket_factory/zmq_wrapper.py index f936e744..2691041b 100644 --- a/exasol/analytics/udf/communication/socket_factory/zmq_wrapper.py +++ b/exasol/analytics/udf/communication/socket_factory/zmq_wrapper.py @@ -149,7 +149,7 @@ def poll( self._sockets_map[zmq_socket]: _bitmask_to_flags(bitmask) for zmq_socket, bitmask in poll_result.items() } - return result # type: ignore + return result # type: ignore class ZMQSocketFactory(SocketFactory): diff --git a/exasol/analytics/udf/utils/context_wrapper.py b/exasol/analytics/udf/utils/context_wrapper.py index 45083652..20a73b46 100644 --- a/exasol/analytics/udf/utils/context_wrapper.py +++ b/exasol/analytics/udf/utils/context_wrapper.py @@ -1,7 +1,7 @@ from collections import OrderedDict from typing import Mapping, Optional, Union -import pandas as pd # type: ignore +import pandas as pd # type: ignore class UDFContextWrapper: diff --git a/exasol/analytics/udf/utils/iterators.py b/exasol/analytics/udf/utils/iterators.py index 2c3abbd5..ba4a97e3 100644 --- a/exasol/analytics/udf/utils/iterators.py +++ b/exasol/analytics/udf/utils/iterators.py @@ -1,6 +1,6 @@ from typing import Any, Callable -import pandas as pd # type: ignore +import pandas as pd # type: ignore def iterate_trough_dataset( diff --git a/exasol/analytics/utils/errors.py b/exasol/analytics/utils/errors.py index 917d40b9..7bc1dc80 100644 --- a/exasol/analytics/utils/errors.py +++ b/exasol/analytics/utils/errors.py @@ -1,10 +1,10 @@ - class UninitializedAttributeError(Exception): """ A method of a class accesses an attribute that has not been initialized dynamically before, e.g. in method run(). """ + class IllegalParametersError(Exception): """ Calling a function, method or iniinitializing a class with an illegal