Skip to content

Commit

Permalink
update to black 24.8.0
Browse files Browse the repository at this point in the history
Signed-off-by: Michele Dolfi <[email protected]>
  • Loading branch information
dolfim-ibm committed Aug 7, 2024
1 parent 8ce7941 commit d8fb7bc
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 36 deletions.
1 change: 1 addition & 0 deletions deepsearch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
DeepSearch Toolkit
"""

from .core import DeepSearchBearerTokenAuth, DeepSearchConfig, DeepSearchKeyAuth
from .core.util._version import version
from .cps import CpsApi, CpsApiClient
Expand Down
6 changes: 3 additions & 3 deletions deepsearch/cps/client/components/data_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
8 changes: 4 additions & 4 deletions deepsearch/cps/client/components/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
10 changes: 6 additions & 4 deletions deepsearch/cps/client/components/knowledge_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions deepsearch/cps/client/queries/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down
12 changes: 4 additions & 8 deletions deepsearch/cps/client/queries/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 5 additions & 1 deletion deepsearch/documents/core/create_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions deepsearch/documents/core/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
]
)
Expand Down
6 changes: 3 additions & 3 deletions deepsearch/documents/core/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 6 additions & 6 deletions deepsearch/model/server/model_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d8fb7bc

Please sign in to comment.