apache-airflow-providers-elasticsearch 5.0.1rc1__py3-none-any.whl → 5.0.2rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,7 @@ import packaging.version
28
28
 
29
29
  __all__ = ["__version__"]
30
30
 
31
- __version__ = "5.0.1"
31
+ __version__ = "5.0.2"
32
32
 
33
33
  try:
34
34
  from airflow import __version__ as airflow_version
@@ -29,6 +29,7 @@ def get_provider_info():
29
29
  "description": "`Elasticsearch <https://www.elastic.co/elasticsearch>`__\n",
30
30
  "suspended": False,
31
31
  "versions": [
32
+ "5.0.2",
32
33
  "5.0.1",
33
34
  "5.0.0",
34
35
  "4.5.1",
@@ -19,16 +19,18 @@ from __future__ import annotations
19
19
 
20
20
  import warnings
21
21
  from functools import cached_property
22
- from typing import Any
22
+ from typing import TYPE_CHECKING, Any
23
23
  from urllib import parse
24
24
 
25
25
  from elasticsearch import Elasticsearch
26
26
 
27
27
  from airflow.exceptions import AirflowProviderDeprecationWarning
28
28
  from airflow.hooks.base import BaseHook
29
- from airflow.models.connection import Connection as AirflowConnection
30
29
  from airflow.providers.common.sql.hooks.sql import DbApiHook
31
30
 
31
+ if TYPE_CHECKING:
32
+ from airflow.models.connection import Connection as AirflowConnection
33
+
32
34
 
33
35
  def connect(
34
36
  host: str = "localhost",
@@ -92,13 +94,13 @@ class ElasticsearchSQLHook(DbApiHook):
92
94
  conn_id = getattr(self, self.conn_name_attr)
93
95
  conn = self.connection or self.get_connection(conn_id)
94
96
 
95
- conn_args = dict(
96
- host=conn.host,
97
- port=conn.port,
98
- user=conn.login or None,
99
- password=conn.password or None,
100
- scheme=conn.schema or "http",
101
- )
97
+ conn_args = {
98
+ "host": conn.host,
99
+ "port": conn.port,
100
+ "user": conn.login or None,
101
+ "password": conn.password or None,
102
+ "scheme": conn.schema or "http",
103
+ }
102
104
 
103
105
  if conn.extra_dejson.get("http_compress", False):
104
106
  conn_args["http_compress"] = bool(["http_compress"])
@@ -116,11 +118,11 @@ class ElasticsearchSQLHook(DbApiHook):
116
118
 
117
119
  login = ""
118
120
  if conn.login:
119
- login = "{conn.login}:{conn.password}@".format(conn=conn)
121
+ login = f"{conn.login}:{conn.password}@"
120
122
  host = conn.host
121
123
  if conn.port is not None:
122
124
  host += f":{conn.port}"
123
- uri = "{conn.conn_type}+{conn.schema}://{login}{host}/".format(conn=conn, login=login, host=host)
125
+ uri = f"{conn.conn_type}+{conn.schema}://{login}{host}/"
124
126
 
125
127
  extras_length = len(conn.extra_dejson)
126
128
  if not extras_length:
@@ -38,7 +38,7 @@ class AttributeList:
38
38
  return _wrap(val)
39
39
 
40
40
  def __iter__(self):
41
- return map(lambda i: _wrap(i), self._l_)
41
+ return (_wrap(i) for i in self._l_)
42
42
 
43
43
  def __bool__(self):
44
44
  return bool(self._l_)
@@ -17,11 +17,11 @@
17
17
  # under the License.
18
18
  from __future__ import annotations
19
19
 
20
+ import inspect
20
21
  import logging
21
22
  import sys
22
23
  import warnings
23
24
  from collections import defaultdict
24
- from datetime import datetime
25
25
  from operator import attrgetter
26
26
  from time import time
27
27
  from typing import TYPE_CHECKING, Any, Callable, List, Tuple
@@ -31,11 +31,11 @@ from urllib.parse import quote, urlparse
31
31
  import elasticsearch
32
32
  import pendulum
33
33
  from elasticsearch.exceptions import NotFoundError
34
+ from typing_extensions import Literal
34
35
 
35
36
  from airflow.configuration import conf
36
37
  from airflow.exceptions import AirflowProviderDeprecationWarning
37
38
  from airflow.models.dagrun import DagRun
38
- from airflow.models.taskinstance import TaskInstance
39
39
  from airflow.providers.elasticsearch.log.es_json_formatter import ElasticsearchJSONFormatter
40
40
  from airflow.providers.elasticsearch.log.es_response import ElasticSearchResponse, Hit
41
41
  from airflow.utils import timezone
@@ -43,6 +43,11 @@ from airflow.utils.log.file_task_handler import FileTaskHandler
43
43
  from airflow.utils.log.logging_mixin import ExternalLoggingMixin, LoggingMixin
44
44
  from airflow.utils.session import create_session
45
45
 
46
+ if TYPE_CHECKING:
47
+ from datetime import datetime
48
+
49
+ from airflow.models.taskinstance import TaskInstance
50
+
46
51
  LOG_LINE_DEFAULTS = {"exc_text": "", "stack_info": ""}
47
52
  # Elasticsearch hosted log type
48
53
  EsLogMsgType = List[Tuple[str, str]]
@@ -53,6 +58,32 @@ EsLogMsgType = List[Tuple[str, str]]
53
58
  USE_PER_RUN_LOG_ID = hasattr(DagRun, "get_log_template")
54
59
 
55
60
 
61
+ VALID_ES_CONFIG_KEYS = set(inspect.signature(elasticsearch.Elasticsearch.__init__).parameters.keys())
62
+ # Remove `self` from the valid set of kwargs
63
+ VALID_ES_CONFIG_KEYS.remove("self")
64
+
65
+
66
+ def get_es_kwargs_from_config() -> dict[str, Any]:
67
+ elastic_search_config = conf.getsection("elasticsearch_configs")
68
+ kwargs_dict = (
69
+ {key: value for key, value in elastic_search_config.items() if key in VALID_ES_CONFIG_KEYS}
70
+ if elastic_search_config
71
+ else {}
72
+ )
73
+ # For elasticsearch>8 retry_timeout have changed for elasticsearch to retry_on_timeout
74
+ # in Elasticsearch() compared to previous versions.
75
+ # Read more at: https://elasticsearch-py.readthedocs.io/en/v8.8.2/api.html#module-elasticsearch
76
+ if (
77
+ elastic_search_config
78
+ and "retry_timeout" in elastic_search_config
79
+ and not kwargs_dict.get("retry_on_timeout")
80
+ ):
81
+ retry_timeout = elastic_search_config.get("retry_timeout")
82
+ if retry_timeout is not None:
83
+ kwargs_dict["retry_on_timeout"] = retry_timeout
84
+ return kwargs_dict
85
+
86
+
56
87
  class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMixin):
57
88
  """
58
89
  ElasticsearchTaskHandler is a python log handler that reads logs from Elasticsearch.
@@ -92,17 +123,14 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
92
123
  host: str = "http://localhost:9200",
93
124
  frontend: str = "localhost:5601",
94
125
  index_patterns: str | None = conf.get("elasticsearch", "index_patterns", fallback="_all"),
95
- es_kwargs: dict | None = conf.getsection("elasticsearch_configs"),
126
+ es_kwargs: dict | None | Literal["default_es_kwargs"] = "default_es_kwargs",
96
127
  *,
97
128
  filename_template: str | None = None,
98
129
  log_id_template: str | None = None,
99
130
  ):
100
131
  es_kwargs = es_kwargs or {}
101
- # For elasticsearch>8,arguments like retry_timeout have changed for elasticsearch to retry_on_timeout
102
- # in Elasticsearch() compared to previous versions.
103
- # Read more at: https://elasticsearch-py.readthedocs.io/en/v8.8.2/api.html#module-elasticsearch
104
- if es_kwargs.get("retry_timeout"):
105
- es_kwargs["retry_on_timeout"] = es_kwargs.pop("retry_timeout")
132
+ if es_kwargs == "default_es_kwargs":
133
+ es_kwargs = get_es_kwargs_from_config()
106
134
  host = self.format_url(host)
107
135
  super().__init__(base_log_folder, filename_template)
108
136
  self.closed = False
@@ -361,7 +389,7 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
361
389
  if self.json_format:
362
390
  self.formatter = ElasticsearchJSONFormatter(
363
391
  fmt=self.formatter._fmt,
364
- json_fields=self.json_fields + [self.offset_field],
392
+ json_fields=[*self.json_fields, self.offset_field],
365
393
  extras={
366
394
  "dag_id": str(ti.dag_id),
367
395
  "task_id": str(ti.task_id),
@@ -1,14 +1,14 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: apache-airflow-providers-elasticsearch
3
- Version: 5.0.1rc1
3
+ Version: 5.0.2rc1
4
4
  Summary: Provider for Apache Airflow. Implements apache-airflow-providers-elasticsearch package
5
5
  Home-page: https://airflow.apache.org/
6
6
  Download-URL: https://archive.apache.org/dist/airflow/providers
7
7
  Author: Apache Software Foundation
8
8
  Author-email: dev@airflow.apache.org
9
9
  License: Apache License 2.0
10
- Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.0.1/
11
- Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.0.1/changelog.html
10
+ Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.0.2/
11
+ Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.0.2/changelog.html
12
12
  Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
13
13
  Project-URL: Source Code, https://github.com/apache/airflow
14
14
  Project-URL: Slack Chat, https://s.apache.org/airflow-slack
@@ -75,7 +75,7 @@ Requires-Dist: apache-airflow-providers-common-sql ; extra == 'common.sql'
75
75
 
76
76
  Package ``apache-airflow-providers-elasticsearch``
77
77
 
78
- Release: ``5.0.1rc1``
78
+ Release: ``5.0.2rc1``
79
79
 
80
80
 
81
81
  `Elasticsearch <https://www.elastic.co/elasticsearch>`__
@@ -88,7 +88,7 @@ This is a provider package for ``elasticsearch`` provider. All classes for this
88
88
  are in ``airflow.providers.elasticsearch`` python package.
89
89
 
90
90
  You can find package information and changelog for the provider
91
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.0.1/>`_.
91
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.0.2/>`_.
92
92
 
93
93
 
94
94
  Installation
@@ -131,4 +131,4 @@ Dependent package
131
131
  ============================================================================================================ ==============
132
132
 
133
133
  The changelog for the provider package can be found in the
134
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.0.1/changelog.html>`_.
134
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.0.2/changelog.html>`_.
@@ -0,0 +1,15 @@
1
+ airflow/providers/elasticsearch/__init__.py,sha256=pfeNE3S4fPn5x9VoC5yExvm6mm1gaQxnXW2PmkOD1qM,1582
2
+ airflow/providers/elasticsearch/get_provider_info.py,sha256=jWyHVfIRIhk9gKlhk92mUPKebrKEwaDF1aMNsQocaow,7680
3
+ airflow/providers/elasticsearch/hooks/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
4
+ airflow/providers/elasticsearch/hooks/elasticsearch.py,sha256=qgpyV4pjPj8b2EwjWHm8eGcewubQBTHY32K_xjBDeP8,6472
5
+ airflow/providers/elasticsearch/log/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
6
+ airflow/providers/elasticsearch/log/es_json_formatter.py,sha256=IBCC6U8XUIfZ1vZKeDAQWCwNCXhP5yG2oOjSJesuGV0,1640
7
+ airflow/providers/elasticsearch/log/es_response.py,sha256=txtpMOadBbuiV91nCw16hgTurTOdawv0DrjDVsedVF4,5369
8
+ airflow/providers/elasticsearch/log/es_task_handler.py,sha256=9XcgfW5N4sg-_mNCcO3Ty-ymea_hK6FZKMYzZypKI3Q,23850
9
+ apache_airflow_providers_elasticsearch-5.0.2rc1.dist-info/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
10
+ apache_airflow_providers_elasticsearch-5.0.2rc1.dist-info/METADATA,sha256=lZAnKAhKyo0jywfOJTDoVYFJocIgfNtbRqCLKZJyFoQ,5951
11
+ apache_airflow_providers_elasticsearch-5.0.2rc1.dist-info/NOTICE,sha256=m-6s2XynUxVSUIxO4rVablAZCvFq-wmLrqV91DotRBw,240
12
+ apache_airflow_providers_elasticsearch-5.0.2rc1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
13
+ apache_airflow_providers_elasticsearch-5.0.2rc1.dist-info/entry_points.txt,sha256=dAJ1Ib0gGGXb1p2Gd9pMCFzyIXRCqHax_eno9jpWDWk,110
14
+ apache_airflow_providers_elasticsearch-5.0.2rc1.dist-info/top_level.txt,sha256=OeMVH5md7fr2QQWpnZoOWWxWO-0WH1IP70lpTVwopPg,8
15
+ apache_airflow_providers_elasticsearch-5.0.2rc1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.1)
2
+ Generator: bdist_wheel (0.41.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,15 +0,0 @@
1
- airflow/providers/elasticsearch/__init__.py,sha256=txdMTGaxqJAdwftO-0rvZHI1JIyvGxNZpXOHY-AX3aI,1582
2
- airflow/providers/elasticsearch/get_provider_info.py,sha256=HkjZldBjbIx-zS1HcUNRrBRDtv1uxZqxbzq4h8pm6wg,7659
3
- airflow/providers/elasticsearch/hooks/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
4
- airflow/providers/elasticsearch/hooks/elasticsearch.py,sha256=r5JKHB20SBQS6bGy0o1t4_G2DIxe2HANU0YTLWP41JM,6481
5
- airflow/providers/elasticsearch/log/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
6
- airflow/providers/elasticsearch/log/es_json_formatter.py,sha256=IBCC6U8XUIfZ1vZKeDAQWCwNCXhP5yG2oOjSJesuGV0,1640
7
- airflow/providers/elasticsearch/log/es_response.py,sha256=3ZSIdVcI--7_Ouw32HicIijS0D15NoRxlNaN-FvnBC8,5374
8
- airflow/providers/elasticsearch/log/es_task_handler.py,sha256=rD659Y86XC5iEGG488opPLJpmLcyUPcau3uMJTUsUCE,22986
9
- apache_airflow_providers_elasticsearch-5.0.1rc1.dist-info/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
10
- apache_airflow_providers_elasticsearch-5.0.1rc1.dist-info/METADATA,sha256=pdBp6tF2B1V471wkSseDpGVLKLlRA4LWqH3JZI7d2QY,5951
11
- apache_airflow_providers_elasticsearch-5.0.1rc1.dist-info/NOTICE,sha256=m-6s2XynUxVSUIxO4rVablAZCvFq-wmLrqV91DotRBw,240
12
- apache_airflow_providers_elasticsearch-5.0.1rc1.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
13
- apache_airflow_providers_elasticsearch-5.0.1rc1.dist-info/entry_points.txt,sha256=dAJ1Ib0gGGXb1p2Gd9pMCFzyIXRCqHax_eno9jpWDWk,110
14
- apache_airflow_providers_elasticsearch-5.0.1rc1.dist-info/top_level.txt,sha256=OeMVH5md7fr2QQWpnZoOWWxWO-0WH1IP70lpTVwopPg,8
15
- apache_airflow_providers_elasticsearch-5.0.1rc1.dist-info/RECORD,,