apache-airflow-providers-elasticsearch 5.5.3rc1__py3-none-any.whl → 6.0.0rc1__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.
@@ -29,11 +29,11 @@ from airflow import __version__ as airflow_version
29
29
 
30
30
  __all__ = ["__version__"]
31
31
 
32
- __version__ = "5.5.3"
32
+ __version__ = "6.0.0"
33
33
 
34
34
  if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
35
- "2.8.0"
35
+ "2.9.0"
36
36
  ):
37
37
  raise RuntimeError(
38
- f"The package `apache-airflow-providers-elasticsearch:{__version__}` needs Apache Airflow 2.8.0+"
38
+ f"The package `apache-airflow-providers-elasticsearch:{__version__}` needs Apache Airflow 2.9.0+"
39
39
  )
@@ -28,8 +28,9 @@ def get_provider_info():
28
28
  "name": "Elasticsearch",
29
29
  "description": "`Elasticsearch <https://www.elastic.co/elasticsearch>`__\n",
30
30
  "state": "ready",
31
- "source-date-epoch": 1731570065,
31
+ "source-date-epoch": 1734533734,
32
32
  "versions": [
33
+ "6.0.0",
33
34
  "5.5.3",
34
35
  "5.5.2",
35
36
  "5.5.1",
@@ -75,7 +76,7 @@ def get_provider_info():
75
76
  "1.0.0",
76
77
  ],
77
78
  "dependencies": [
78
- "apache-airflow>=2.8.0",
79
+ "apache-airflow>=2.9.0",
79
80
  "apache-airflow-providers-common-sql>=1.20.0",
80
81
  "elasticsearch>=8.10,<9",
81
82
  ],
@@ -95,7 +96,7 @@ def get_provider_info():
95
96
  ],
96
97
  "connection-types": [
97
98
  {
98
- "hook-class-name": "airflow.providers.elasticsearch.hooks.elasticsearch.ElasticsearchHook",
99
+ "hook-class-name": "airflow.providers.elasticsearch.hooks.elasticsearch.ElasticsearchSQLHook",
99
100
  "connection-type": "elasticsearch",
100
101
  }
101
102
  ],
@@ -21,10 +21,8 @@ from functools import cached_property
21
21
  from typing import TYPE_CHECKING, Any
22
22
  from urllib import parse
23
23
 
24
- from deprecated import deprecated
25
24
  from elasticsearch import Elasticsearch
26
25
 
27
- from airflow.exceptions import AirflowProviderDeprecationWarning
28
26
  from airflow.hooks.base import BaseHook
29
27
  from airflow.providers.common.sql.hooks.sql import DbApiHook
30
28
 
@@ -142,21 +140,6 @@ class ElasticsearchSQLHook(DbApiHook):
142
140
  return uri
143
141
 
144
142
 
145
- @deprecated(
146
- reason="Please use `airflow.providers.elasticsearch.hooks.elasticsearch.ElasticsearchSQLHook`.",
147
- category=AirflowProviderDeprecationWarning,
148
- )
149
- class ElasticsearchHook(ElasticsearchSQLHook):
150
- """
151
- This class is deprecated and was renamed to ElasticsearchSQLHook.
152
-
153
- Please use :class:`airflow.providers.elasticsearch.hooks.elasticsearch.ElasticsearchSQLHook`.
154
- """
155
-
156
- def __init__(self, *args, **kwargs):
157
- super().__init__(*args, **kwargs)
158
-
159
-
160
143
  class ElasticsearchPythonHook(BaseHook):
161
144
  """
162
145
  Interacts with Elasticsearch. This hook uses the official Elasticsearch Python Client.
@@ -16,7 +16,7 @@
16
16
  # under the License.
17
17
  from __future__ import annotations
18
18
 
19
- from typing import Iterator
19
+ from collections.abc import Iterator
20
20
 
21
21
 
22
22
  def _wrap(val):
@@ -22,10 +22,9 @@ import inspect
22
22
  import logging
23
23
  import sys
24
24
  import time
25
- import warnings
26
25
  from collections import defaultdict
27
26
  from operator import attrgetter
28
- from typing import TYPE_CHECKING, Any, Callable, List, Literal, Tuple
27
+ from typing import TYPE_CHECKING, Any, Callable, Literal
29
28
  from urllib.parse import quote, urlparse
30
29
 
31
30
  # Using `from elasticsearch import *` would break elasticsearch mocking used in unit test.
@@ -34,10 +33,11 @@ import pendulum
34
33
  from elasticsearch.exceptions import NotFoundError
35
34
 
36
35
  from airflow.configuration import conf
37
- from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
36
+ from airflow.exceptions import AirflowException
38
37
  from airflow.models.dagrun import DagRun
39
38
  from airflow.providers.elasticsearch.log.es_json_formatter import ElasticsearchJSONFormatter
40
39
  from airflow.providers.elasticsearch.log.es_response import ElasticSearchResponse, Hit
40
+ from airflow.providers.elasticsearch.version_compat import AIRFLOW_V_3_0_PLUS
41
41
  from airflow.utils import timezone
42
42
  from airflow.utils.log.file_task_handler import FileTaskHandler
43
43
  from airflow.utils.log.logging_mixin import ExternalLoggingMixin, LoggingMixin
@@ -52,7 +52,7 @@ if TYPE_CHECKING:
52
52
 
53
53
  LOG_LINE_DEFAULTS = {"exc_text": "", "stack_info": ""}
54
54
  # Elasticsearch hosted log type
55
- EsLogMsgType = List[Tuple[str, str]]
55
+ EsLogMsgType = list[tuple[str, str]]
56
56
 
57
57
  # Compatibility: Airflow 2.3.3 and up uses this method, which accesses the
58
58
  # LogTemplate model to record the log ID template used. If this function does
@@ -72,20 +72,6 @@ def get_es_kwargs_from_config() -> dict[str, Any]:
72
72
  if elastic_search_config
73
73
  else {}
74
74
  )
75
- # TODO: Remove in next major release (drop support for elasticsearch<8 parameters)
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
- warnings.warn(
82
- "retry_timeout is not supported with elasticsearch>=8. Please use `retry_on_timeout`.",
83
- AirflowProviderDeprecationWarning,
84
- stacklevel=2,
85
- )
86
- retry_timeout = elastic_search_config.get("retry_timeout")
87
- if retry_timeout is not None:
88
- kwargs_dict["retry_on_timeout"] = retry_timeout
89
75
  return kwargs_dict
90
76
 
91
77
 
@@ -126,7 +112,7 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
126
112
 
127
113
  To efficiently query and sort Elasticsearch results, this handler assumes each
128
114
  log message has a field `log_id` consists of ti primary keys:
129
- `log_id = {dag_id}-{task_id}-{execution_date}-{try_number}`
115
+ `log_id = {dag_id}-{task_id}-{logical_date}-{try_number}`
130
116
  Log messages with specific log_id are sorted based on `offset`,
131
117
  which is a unique integer indicates log message's order.
132
118
  Timestamps here are unreliable because multiple log messages
@@ -157,8 +143,6 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
157
143
  index_patterns: str = conf.get("elasticsearch", "index_patterns"),
158
144
  index_patterns_callable: str = conf.get("elasticsearch", "index_patterns_callable", fallback=""),
159
145
  es_kwargs: dict | None | Literal["default_es_kwargs"] = "default_es_kwargs",
160
- *,
161
- log_id_template: str | None = None,
162
146
  **kwargs,
163
147
  ):
164
148
  es_kwargs = es_kwargs or {}
@@ -170,14 +154,7 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
170
154
 
171
155
  self.client = elasticsearch.Elasticsearch(host, **es_kwargs)
172
156
  # in airflow.cfg, host of elasticsearch has to be http://dockerhostXxxx:9200
173
- if USE_PER_RUN_LOG_ID and log_id_template is not None:
174
- warnings.warn(
175
- "Passing log_id_template to ElasticsearchTaskHandler is deprecated and has no effect",
176
- AirflowProviderDeprecationWarning,
177
- stacklevel=2,
178
- )
179
157
 
180
- self.log_id_template = log_id_template # Only used on Airflow < 2.3.2.
181
158
  self.frontend = frontend
182
159
  self.mark_end_on_close = True
183
160
  self.end_of_log_mark = end_of_log_mark.strip()
@@ -239,8 +216,6 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
239
216
  dag_run = ti.get_dagrun(session=session)
240
217
  if USE_PER_RUN_LOG_ID:
241
218
  log_id_template = dag_run.get_log_template(session=session).elasticsearch_id
242
- else:
243
- log_id_template = self.log_id_template
244
219
 
245
220
  if TYPE_CHECKING:
246
221
  assert ti.task
@@ -256,7 +231,7 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
256
231
  if self.json_format:
257
232
  data_interval_start = self._clean_date(data_interval[0])
258
233
  data_interval_end = self._clean_date(data_interval[1])
259
- execution_date = self._clean_date(dag_run.execution_date)
234
+ logical_date = self._clean_date(dag_run.logical_date)
260
235
  else:
261
236
  if data_interval[0]:
262
237
  data_interval_start = data_interval[0].isoformat()
@@ -266,7 +241,7 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
266
241
  data_interval_end = data_interval[1].isoformat()
267
242
  else:
268
243
  data_interval_end = ""
269
- execution_date = dag_run.execution_date.isoformat()
244
+ logical_date = dag_run.logical_date.isoformat()
270
245
 
271
246
  return log_id_template.format(
272
247
  dag_id=ti.dag_id,
@@ -274,7 +249,8 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
274
249
  run_id=getattr(ti, "run_id", ""),
275
250
  data_interval_start=data_interval_start,
276
251
  data_interval_end=data_interval_end,
277
- execution_date=execution_date,
252
+ logical_date=logical_date,
253
+ execution_date=logical_date,
278
254
  try_number=try_number,
279
255
  map_index=getattr(ti, "map_index", ""),
280
256
  )
@@ -444,7 +420,7 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
444
420
  is_trigger_log_context = getattr(ti, "is_trigger_log_context", None)
445
421
  is_ti_raw = getattr(ti, "raw", None)
446
422
  self.mark_end_on_close = not is_ti_raw and not is_trigger_log_context
447
-
423
+ date_key = "logical_date" if AIRFLOW_V_3_0_PLUS else "execution_date"
448
424
  if self.json_format:
449
425
  self.formatter = ElasticsearchJSONFormatter(
450
426
  fmt=self.formatter._fmt,
@@ -452,7 +428,9 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
452
428
  extras={
453
429
  "dag_id": str(ti.dag_id),
454
430
  "task_id": str(ti.task_id),
455
- "execution_date": self._clean_date(ti.execution_date),
431
+ date_key: self._clean_date(ti.logical_date)
432
+ if AIRFLOW_V_3_0_PLUS
433
+ else self._clean_date(ti.execution_date),
456
434
  "try_number": str(ti.try_number),
457
435
  "log_id": self._render_log_id(ti, ti.try_number),
458
436
  },
@@ -580,7 +558,7 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
580
558
  'container': {'id': 'airflow'},
581
559
  'dag_id': 'example_bash_operator',
582
560
  'ecs': {'version': '8.0.0'},
583
- 'execution_date': '2023_07_09T07_47_32_000000',
561
+ 'logical_date': '2023_07_09T07_47_32_000000',
584
562
  'filename': 'taskinstance.py',
585
563
  'input': {'type': 'log'},
586
564
  'levelname': 'INFO',
@@ -0,0 +1,36 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ #
18
+ # NOTE! THIS FILE IS COPIED MANUALLY IN OTHER PROVIDERS DELIBERATELY TO AVOID ADDING UNNECESSARY
19
+ # DEPENDENCIES BETWEEN PROVIDERS. IF YOU WANT TO ADD CONDITIONAL CODE IN YOUR PROVIDER THAT DEPENDS
20
+ # ON AIRFLOW VERSION, PLEASE COPY THIS FILE TO THE ROOT PACKAGE OF YOUR PROVIDER AND IMPORT
21
+ # THOSE CONSTANTS FROM IT RATHER THAN IMPORTING THEM FROM ANOTHER PROVIDER OR TEST CODE
22
+ #
23
+ from __future__ import annotations
24
+
25
+
26
+ def get_base_airflow_version_tuple() -> tuple[int, int, int]:
27
+ from packaging.version import Version
28
+
29
+ from airflow import __version__
30
+
31
+ airflow_version = Version(__version__)
32
+ return airflow_version.major, airflow_version.minor, airflow_version.micro
33
+
34
+
35
+ AIRFLOW_V_2_10_PLUS = get_base_airflow_version_tuple() >= (2, 10, 0)
36
+ AIRFLOW_V_3_0_PLUS = get_base_airflow_version_tuple() >= (3, 0, 0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: apache-airflow-providers-elasticsearch
3
- Version: 5.5.3rc1
3
+ Version: 6.0.0rc1
4
4
  Summary: Provider package apache-airflow-providers-elasticsearch for Apache Airflow
5
5
  Keywords: airflow-provider,elasticsearch,airflow,integration
6
6
  Author-email: Apache Software Foundation <dev@airflow.apache.org>
@@ -21,17 +21,15 @@ Classifier: Programming Language :: Python :: 3.11
21
21
  Classifier: Programming Language :: Python :: 3.12
22
22
  Classifier: Topic :: System :: Monitoring
23
23
  Requires-Dist: apache-airflow-providers-common-sql>=1.20.0rc0
24
- Requires-Dist: apache-airflow>=2.8.0rc0
24
+ Requires-Dist: apache-airflow>=2.9.0rc0
25
25
  Requires-Dist: elasticsearch>=8.10,<9
26
- Requires-Dist: apache-airflow-providers-common-sql ; extra == "common-sql"
27
26
  Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
28
- Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.5.3/changelog.html
29
- Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.5.3
27
+ Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/6.0.0/changelog.html
28
+ Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/6.0.0
30
29
  Project-URL: Slack Chat, https://s.apache.org/airflow-slack
31
30
  Project-URL: Source Code, https://github.com/apache/airflow
32
- Project-URL: Twitter, https://twitter.com/ApacheAirflow
31
+ Project-URL: Twitter, https://x.com/ApacheAirflow
33
32
  Project-URL: YouTube, https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/
34
- Provides-Extra: common-sql
35
33
 
36
34
 
37
35
  .. Licensed to the Apache Software Foundation (ASF) under one
@@ -77,7 +75,7 @@ Provides-Extra: common-sql
77
75
 
78
76
  Package ``apache-airflow-providers-elasticsearch``
79
77
 
80
- Release: ``5.5.3.rc1``
78
+ Release: ``6.0.0.rc1``
81
79
 
82
80
 
83
81
  `Elasticsearch <https://www.elastic.co/elasticsearch>`__
@@ -90,7 +88,7 @@ This is a provider package for ``elasticsearch`` provider. All classes for this
90
88
  are in ``airflow.providers.elasticsearch`` python package.
91
89
 
92
90
  You can find package information and changelog for the provider
93
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.5.3/>`_.
91
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/6.0.0/>`_.
94
92
 
95
93
  Installation
96
94
  ------------
@@ -107,7 +105,7 @@ Requirements
107
105
  ======================================= ==================
108
106
  PIP package Version required
109
107
  ======================================= ==================
110
- ``apache-airflow`` ``>=2.8.0``
108
+ ``apache-airflow`` ``>=2.9.0``
111
109
  ``apache-airflow-providers-common-sql`` ``>=1.20.0``
112
110
  ``elasticsearch`` ``>=8.10,<9``
113
111
  ======================================= ==================
@@ -132,4 +130,4 @@ Dependent package
132
130
  ============================================================================================================ ==============
133
131
 
134
132
  The changelog for the provider package can be found in the
135
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.5.3/changelog.html>`_.
133
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/6.0.0/changelog.html>`_.
@@ -0,0 +1,14 @@
1
+ airflow/providers/elasticsearch/LICENSE,sha256=FFb4jd2AXnOOf7XLP04pQW6jbdhG49TxlGY6fFpCV1Y,13609
2
+ airflow/providers/elasticsearch/__init__.py,sha256=fmylEM7BkJquAI8XVb8elGOtTIkzza6oQ9LEMpxCM6U,1500
3
+ airflow/providers/elasticsearch/get_provider_info.py,sha256=SY9_0oTY1ciySePMvByw4d7wiacaJgjIeMd8mOoflic,8637
4
+ airflow/providers/elasticsearch/version_compat.py,sha256=aHg90_DtgoSnQvILFICexMyNlHlALBdaeWqkX3dFDug,1605
5
+ airflow/providers/elasticsearch/hooks/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
6
+ airflow/providers/elasticsearch/hooks/elasticsearch.py,sha256=-J3X2BHHncI1iV8nZ959057-kPR9ecgEw9B-QqNUupY,5812
7
+ airflow/providers/elasticsearch/log/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
8
+ airflow/providers/elasticsearch/log/es_json_formatter.py,sha256=DwWPDJtZLr_6Mdae1-XVEgmE1XErFIanSzxWovs50ig,1796
9
+ airflow/providers/elasticsearch/log/es_response.py,sha256=LdMBuVBTydaC42HooYSttAjTK-CpPA4r_KHl38msMnk,6046
10
+ airflow/providers/elasticsearch/log/es_task_handler.py,sha256=kLXTrkwcDN3sOFaBLDxLGcyKegnSNG5wvA9H9RQDsd4,25054
11
+ apache_airflow_providers_elasticsearch-6.0.0rc1.dist-info/entry_points.txt,sha256=jpgAUVmTsdtWQ4nru2FJQKP9JBN4OPHK-ybfYc3_BOs,109
12
+ apache_airflow_providers_elasticsearch-6.0.0rc1.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
13
+ apache_airflow_providers_elasticsearch-6.0.0rc1.dist-info/METADATA,sha256=WzuJs5KZMuo4vbke3DZnWLzidGrFAPdXyU0i0QGsbYQ,6070
14
+ apache_airflow_providers_elasticsearch-6.0.0rc1.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- airflow/providers/elasticsearch/LICENSE,sha256=FFb4jd2AXnOOf7XLP04pQW6jbdhG49TxlGY6fFpCV1Y,13609
2
- airflow/providers/elasticsearch/__init__.py,sha256=Htu_SzTsWLOVul8QKPjq-x_desW2SH_sWq-Q_LEOmog,1500
3
- airflow/providers/elasticsearch/get_provider_info.py,sha256=Q8-klQQR7Vo7QnURf8KD9NBUHSsLhmtg2471JobHMoI,8613
4
- airflow/providers/elasticsearch/hooks/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
5
- airflow/providers/elasticsearch/hooks/elasticsearch.py,sha256=TPIRIqS0lu7apfofxKKfg9kO7-8Qo2ippdL1uEk7B3g,6393
6
- airflow/providers/elasticsearch/log/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
7
- airflow/providers/elasticsearch/log/es_json_formatter.py,sha256=DwWPDJtZLr_6Mdae1-XVEgmE1XErFIanSzxWovs50ig,1796
8
- airflow/providers/elasticsearch/log/es_response.py,sha256=tEFz1pAUzIg6Zw43ZjiHFTOB72kNP-czbEwMbymUZ88,6037
9
- airflow/providers/elasticsearch/log/es_task_handler.py,sha256=6E_oQ8RQFbYf5rR_vjLHq1r_sZEP4wKe0ToCcHC7H4M,25950
10
- apache_airflow_providers_elasticsearch-5.5.3rc1.dist-info/entry_points.txt,sha256=jpgAUVmTsdtWQ4nru2FJQKP9JBN4OPHK-ybfYc3_BOs,109
11
- apache_airflow_providers_elasticsearch-5.5.3rc1.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
12
- apache_airflow_providers_elasticsearch-5.5.3rc1.dist-info/METADATA,sha256=jYPAjc7c0oM2xXjMJKmj3lUobcmHxYIzFk__EtmvocQ,6178
13
- apache_airflow_providers_elasticsearch-5.5.3rc1.dist-info/RECORD,,