Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finally found the Tasks API warning bug #8

Merged
merged 1 commit into from
Jan 27, 2025
Merged

Finally found the Tasks API warning bug #8

merged 1 commit into from
Jan 27, 2025

Conversation

untergeek
Copy link
Owner

See the 8.16.0 Python client release notes for the workaround.

This exact fix is included now in src/es_wait/task.py

I had initially raised an issue at elastic/elasticsearch-py#2765 to learn what transpired.

--- a/src/es_wait/task.py
+++ b/src/es_wait/task.py
@@ -2,8 +2,10 @@

 import typing as t
 import logging
+import warnings
 from time import localtime, strftime
 from dotmap import DotMap  # type: ignore
+from elasticsearch8.exceptions import GeneralAvailabilityWarning
 from ._base import Waiter

 if t.TYPE_CHECKING:
@@ -72,6 +74,10 @@ class Task(Waiter):

         response = {}
         try:
+            # The Tasks API is not yet GA. We need to suppress the warning for now.
+            # This is required after elasticsearch8>=8.16.0 as the warning is raised
+            # from that release onward.
+            warnings.filterwarnings("ignore", category=GeneralAvailabilityWarning)
             response = dict(self.client.tasks.get(task_id=self.task_id))
         except Exception as err:
             msg = (

See [the 8.16.0 Python client release notes](https://github.com/elastic/elasticsearch-py/releases/tag/v8.16.0) for the workaround.

This exact fix is included now in src/es_wait/task.py

I had initially raised an issue at elastic/elasticsearch-py#2765 to learn what transpired.

```diff
--- a/src/es_wait/task.py
+++ b/src/es_wait/task.py
@@ -2,8 +2,10 @@

 import typing as t
 import logging
+import warnings
 from time import localtime, strftime
 from dotmap import DotMap  # type: ignore
+from elasticsearch8.exceptions import GeneralAvailabilityWarning
 from ._base import Waiter

 if t.TYPE_CHECKING:
@@ -72,6 +74,10 @@ class Task(Waiter):

         response = {}
         try:
+            # The Tasks API is not yet GA. We need to suppress the warning for now.
+            # This is required after elasticsearch8>=8.16.0 as the warning is raised
+            # from that release onward.
+            warnings.filterwarnings("ignore", category=GeneralAvailabilityWarning)
             response = dict(self.client.tasks.get(task_id=self.task_id))
         except Exception as err:
             msg = (
```
@untergeek untergeek merged commit 02e8d31 into main Jan 27, 2025
@untergeek untergeek deleted the release/0.9.3 branch January 27, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant