Skip to content

Commit 3695717

Browse files
author
dmirizzi
committed
run precommit
1 parent 72bff75 commit 3695717

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

target_elasticsearch/sinks.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def __init__(
3232
):
3333
super().__init__(target, stream_name, schema, key_properties)
3434
self.client = self._authenticated_client()
35-
self.index_schema_fields = self.config.get("index_schema_fields", {}).get(self.stream_name, {})
35+
self.index_schema_fields = self.config.get("index_schema_fields", {}).get(
36+
self.stream_name, {}
37+
)
3638
self.metadata_fields = self.config.get("metadata_fields", {}).get(self.stream_name, {})
3739
self.index_mappings = self.config.get("index_mappings", {}).get(self.stream_name, {})
3840
self.index_name = None
@@ -97,7 +99,9 @@ def _build_fields(
9799
for k, v in mapping.items():
98100
match = jsonpath_ng.parse(v).find(record)
99101
if len(match) == 0:
100-
self.logger.warning(f"schema key {k} with json path {v} could not be found in record: {record}")
102+
self.logger.warning(
103+
f"schema key {k} with json path {v} could not be found in record: {record}"
104+
)
101105
schemas[k] = v
102106
else:
103107
if len(match) > 1:
@@ -153,9 +157,13 @@ def create_index(self, index: str) -> None:
153157
index=index, fields=list(self.index_mappings.keys())
154158
)[index]["mappings"].items()
155159
}
156-
if not all(self.index_mappings[key]["type"] == value for key, value in mappings.items()):
160+
if not all(
161+
self.index_mappings[key]["type"] == value for key, value in mappings.items()
162+
):
157163
try:
158-
self.client.indices.put_mapping(index=index, body={"properties": self.index_mappings})
164+
self.client.indices.put_mapping(
165+
index=index, body={"properties": self.index_mappings}
166+
)
159167
except elasticsearch.exceptions.BadRequestError as e:
160168
if e.message == "illegal_argument_exception":
161169
self.logger.warning(
@@ -209,7 +217,9 @@ def process_batch(self, context: dict[str, Any]) -> None:
209217
Args:
210218
context: Dictionary containing batch processing context including records.
211219
"""
212-
updated_records, distinct_indices = self.build_request_body_and_distinct_indices(context["records"])
220+
updated_records, distinct_indices = self.build_request_body_and_distinct_indices(
221+
context["records"]
222+
)
213223
for index in distinct_indices:
214224
self.create_index(index)
215225
try:

target_elasticsearch/target.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,12 @@ def __init__(
154154
validate_config=validate_config,
155155
setup_mapper=setup_mapper,
156156
)
157-
assert bool(self.config.get("username") is None) == bool(self.config.get("password") is None)
158-
assert bool(self.config.get("api_key_id") is None) == bool(self.config.get("api_key") is None)
157+
assert bool(self.config.get("username") is None) == bool(
158+
self.config.get("password") is None
159+
)
160+
assert bool(self.config.get("api_key_id") is None) == bool(
161+
self.config.get("api_key") is None
162+
)
159163

160164
@property
161165
def state(self) -> Dict:

0 commit comments

Comments
 (0)