Skip to content

Commit

Permalink
Remove unused argument metadata from es_read and make clearly private (
Browse files Browse the repository at this point in the history
…#34790)

* Remove unused argument metadata from es_read

* renaem underscore; add notes

* Update airflow/providers/elasticsearch/CHANGELOG.rst

Co-authored-by: Elad Kalif <45845474+eladkal@users.noreply.github.com>

---------

Co-authored-by: Elad Kalif <45845474+eladkal@users.noreply.github.com>
  • Loading branch information
dstandish and eladkal committed Oct 13, 2023
1 parent 128f6b9 commit 0e5890b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions airflow/providers/elasticsearch/CHANGELOG.rst
Expand Up @@ -27,6 +27,12 @@
Changelog
---------


.. note::
In PR #34790 we removed the unused argument ``metadata`` from method ``es_read``. We determined that ``es_read``
is an internal method and therefore not subject to backcompat, so we did not bump major version for this provider.
In order to make clearer that this is an internal method we renamed it with an underscore prefix ``_es_read``.

.. note::
Upgrade to Elasticsearch 8. The ElasticsearchTaskHandler & ElasticsearchSQLHook will now use Elasticsearch 8 package.
As explained https://elasticsearch-py.readthedocs.io/en/stable , Elasticsearch language clients are only backwards
Expand Down
7 changes: 4 additions & 3 deletions airflow/providers/elasticsearch/log/es_task_handler.py
Expand Up @@ -269,7 +269,7 @@ def _read(

offset = metadata["offset"]
log_id = self._render_log_id(ti, try_number)
logs = self.es_read(log_id, offset, metadata)
logs = self._es_read(log_id, offset)
logs_by_host = self._group_logs_by_host(logs)
next_offset = offset if not logs else attrgetter(self.offset_field)(logs[-1])
# Ensure a string here. Large offset numbers will get JSON.parsed incorrectly
Expand Down Expand Up @@ -330,13 +330,14 @@ def _format_msg(self, log_line):
# Just a safe-guard to preserve backwards-compatibility
return log_line.message

def es_read(self, log_id: str, offset: int | str, metadata: dict) -> list | ElasticSearchResponse:
def _es_read(self, log_id: str, offset: int | str) -> list | ElasticSearchResponse:
"""
Return the logs matching log_id in Elasticsearch and next offset or ''.
:param log_id: the log_id of the log to read.
:param offset: the offset start to read log from.
:param metadata: log metadata, used for steaming log download.
:meta private:
"""
query: dict[Any, Any] = {
"query": {
Expand Down

0 comments on commit 0e5890b

Please sign in to comment.