From d8fb7bcf52f9fc0597bea26893b2a00fb3b0a0f8 Mon Sep 17 00:00:00 2001 From: Michele Dolfi Date: Wed, 7 Aug 2024 13:05:50 +0200 Subject: [PATCH] update to black 24.8.0 Signed-off-by: Michele Dolfi --- deepsearch/__init__.py | 1 + deepsearch/cps/client/components/data_indices.py | 6 +++--- deepsearch/cps/client/components/elastic.py | 8 ++++---- deepsearch/cps/client/components/knowledge_graphs.py | 10 ++++++---- deepsearch/cps/client/queries/query.py | 6 ++---- deepsearch/cps/client/queries/task.py | 12 ++++-------- deepsearch/documents/core/create_report.py | 6 +++++- deepsearch/documents/core/export.py | 8 +++++--- deepsearch/documents/core/lookup.py | 6 +++--- deepsearch/model/server/model_app.py | 12 ++++++------ 10 files changed, 39 insertions(+), 36 deletions(-) diff --git a/deepsearch/__init__.py b/deepsearch/__init__.py index 8ef5a951..3aab3a07 100644 --- a/deepsearch/__init__.py +++ b/deepsearch/__init__.py @@ -1,6 +1,7 @@ """ DeepSearch Toolkit """ + from .core import DeepSearchBearerTokenAuth, DeepSearchConfig, DeepSearchKeyAuth from .core.util._version import version from .cps import CpsApi, CpsApiClient diff --git a/deepsearch/cps/client/components/data_indices.py b/deepsearch/cps/client/components/data_indices.py index a8357c3e..2a3635b0 100644 --- a/deepsearch/cps/client/components/data_indices.py +++ b/deepsearch/cps/client/components/data_indices.py @@ -34,9 +34,9 @@ def __init__(self, api: CpsApi) -> None: self.sw_api = sw_client.DataIndicesApi(self.api.client.swagger_client) def list(self, proj_key: str) -> List[DataIndex]: - response: list[ - sw_client.ProjectDataIndexWithStatus - ] = self.sw_api.get_project_data_indices(proj_key=proj_key) + response: list[sw_client.ProjectDataIndexWithStatus] = ( + self.sw_api.get_project_data_indices(proj_key=proj_key) + ) # filter out saved searchs index return [ diff --git a/deepsearch/cps/client/components/elastic.py b/deepsearch/cps/client/components/elastic.py index 0995d816..964ffccf 100644 --- a/deepsearch/cps/client/components/elastic.py +++ b/deepsearch/cps/client/components/elastic.py @@ -25,10 +25,10 @@ def __init__(self, api: CpsApi) -> None: self.sw_api = sw_client.ElasticApi(self.api.client.swagger_client) def list(self, domain: str = "all") -> List[ElasticDataCollection]: - response: list[ - sw_client.DataCollection - ] = self.sw_api.list_indices_from_elastic_instance( - index_type="all", index_domain=domain + response: list[sw_client.DataCollection] = ( + self.sw_api.list_indices_from_elastic_instance( + index_type="all", index_domain=domain + ) ) return [ diff --git a/deepsearch/cps/client/components/knowledge_graphs.py b/deepsearch/cps/client/components/knowledge_graphs.py index 7774b6fa..2fbf3636 100644 --- a/deepsearch/cps/client/components/knowledge_graphs.py +++ b/deepsearch/cps/client/components/knowledge_graphs.py @@ -129,10 +129,12 @@ def save_snapshot_of_data_flow( if name is not None: body["snapshot"]["name"] = name - task: ProjectTask = self.api.knowledge_graphs.sw_api.backend_create_project_kg_snapshot_from_data_flow_assembly( - proj_key=self.project, - bag_key=self.key, - body=body, + task: ProjectTask = ( + self.api.knowledge_graphs.sw_api.backend_create_project_kg_snapshot_from_data_flow_assembly( + proj_key=self.project, + bag_key=self.key, + body=body, + ) ) return task diff --git a/deepsearch/cps/client/queries/query.py b/deepsearch/cps/client/queries/query.py index c7b15682..79999368 100644 --- a/deepsearch/cps/client/queries/query.py +++ b/deepsearch/cps/client/queries/query.py @@ -12,8 +12,7 @@ def __init__(self) -> None: self.paginated_task: Optional[Task] = None @overload - def add(self, kind_or_task: TTask) -> TTask: - ... + def add(self, kind_or_task: TTask) -> TTask: ... @overload def add( @@ -24,8 +23,7 @@ def add( parameters: Optional[Dict[str, Any]] = None, inputs: Optional[TaskInputs] = None, coordinates: Optional[TaskCoordinates] = None, - ) -> Task: - ... + ) -> Task: ... def add( self, diff --git a/deepsearch/cps/client/queries/task.py b/deepsearch/cps/client/queries/task.py index 0448c5f0..3d096a18 100644 --- a/deepsearch/cps/client/queries/task.py +++ b/deepsearch/cps/client/queries/task.py @@ -15,8 +15,7 @@ class Resource(Protocol): """Models which implement this Protocol can be passed as coordinates to tasks""" - def to_resource(self) -> Dict[str, Any]: - ... + def to_resource(self) -> Dict[str, Any]: ... class Output: @@ -49,8 +48,7 @@ def __init__(self, value: Any) -> None: class TaskWithWellKnownOutputs(Protocol[TOutputs]): @property - def outputs(self) -> TOutputs: - ... + def outputs(self) -> TOutputs: ... class Task: @@ -111,12 +109,10 @@ def _build_inputs(self) -> Dict[str, Any]: def _build_coordinates(self) -> Dict[str, Any]: @overload - def _build(value: Dict[str, Any]) -> Dict[str, Any]: - ... + def _build(value: Dict[str, Any]) -> Dict[str, Any]: ... @overload - def _build(value: TaskCoordinates) -> Dict[str, Any]: - ... + def _build(value: TaskCoordinates) -> Dict[str, Any]: ... def _build(value: Any) -> Any: if isinstance(value, tuple): diff --git a/deepsearch/documents/core/create_report.py b/deepsearch/documents/core/create_report.py index 976c13c2..12c74843 100644 --- a/deepsearch/documents/core/create_report.py +++ b/deepsearch/documents/core/create_report.py @@ -60,7 +60,11 @@ def get_multiple_reports( Generates reports for multiple tasks_ids and associated documents. """ reports = [] - count, count_doc, count_failed_doc, = ( + ( + count, + count_doc, + count_failed_doc, + ) = ( 0, 0, 0, diff --git a/deepsearch/documents/core/export.py b/deepsearch/documents/core/export.py index 245908ab..b6a73a91 100644 --- a/deepsearch/documents/core/export.py +++ b/deepsearch/documents/core/export.py @@ -734,9 +734,11 @@ def write_table(self, item): table_min_bbox_str = " ".join( [ - 'data-min-{}="{}"'.format(k, v) - if k != "page" - else 'data-{}="{}"'.format(k, v) + ( + 'data-min-{}="{}"'.format(k, v) + if k != "page" + else 'data-{}="{}"'.format(k, v) + ) for k, v in table_bbox.items() ] ) diff --git a/deepsearch/documents/core/lookup.py b/deepsearch/documents/core/lookup.py index 5ea9a74d..3d71f7d3 100644 --- a/deepsearch/documents/core/lookup.py +++ b/deepsearch/documents/core/lookup.py @@ -35,9 +35,9 @@ class _MatchedEntry(BaseModel): def __init__(self, document: Dict[str, Any]): self.document = document - self._lookup: Dict[ - str, Dict[str, List[EntitiesLookup._MatchedEntry]] - ] = {} # {entity_type: {entity_instance: [reference, ...]}} + self._lookup: Dict[str, Dict[str, List[EntitiesLookup._MatchedEntry]]] = ( + {} + ) # {entity_type: {entity_instance: [reference, ...]}} self._build() def _build(self): diff --git a/deepsearch/model/server/model_app.py b/deepsearch/model/server/model_app.py index 3f8a69f9..054626de 100644 --- a/deepsearch/model/server/model_app.py +++ b/deepsearch/model/server/model_app.py @@ -100,12 +100,12 @@ async def predict( "MY_POD_NAME", "local" ) result.headers["X-Request-Arrival-Time"] = str(request_arrival_time) - result.headers[ - "X-Request-Attempt-Number" - ] = request.metadata.annotations.deepsearch_res_ibm_com_x_attempt_number - result.headers[ - "X-Request-Transaction-Id" - ] = request.metadata.annotations.deepsearch_res_ibm_com_x_transaction_id + result.headers["X-Request-Attempt-Number"] = ( + request.metadata.annotations.deepsearch_res_ibm_com_x_attempt_number + ) + result.headers["X-Request-Transaction-Id"] = ( + request.metadata.annotations.deepsearch_res_ibm_com_x_transaction_id + ) return result except (asyncio.TimeoutError, HTTPException) as e: