pankajkoti commented on code in PR #36014:
URL: https://github.com/apache/airflow/pull/36014#discussion_r1413018967
##########
tests/providers/openai/hooks/test_openai.py:
##########
@@ -16,48 +16,58 @@
# under the License.
from __future__ import annotations
-from unittest.mock import Mock, patch
+from unittest.mock import MagicMock, Mock, patch
import pytest
+from openai import OpenAI
+from openai.types import CreateEmbeddingResponse, Embedding
from airflow.providers.openai.hooks.openai import OpenAIHook
@pytest.fixture
def openai_hook():
- with
patch("airflow.providers.openai.hooks.openai.OpenAIHook._get_api_key"), patch(
- "airflow.providers.openai.hooks.openai.OpenAIHook._get_api_base"
- ) as _:
+ with patch("airflow.providers.openai.hooks.openai.OpenAI") as _:
Review Comment:
yes, it may not be needed, removed it. thank you!
##########
airflow/providers/openai/hooks/openai.py:
##########
@@ -41,13 +42,9 @@ class OpenAIHook(BaseHook):
def __init__(self, conn_id: str = default_conn_name, *args: Any, **kwargs:
Any) -> None:
super().__init__(*args, **kwargs)
self.conn_id = conn_id
- openai.api_key = self._get_api_key()
- api_base = self._get_api_base()
- if api_base:
- openai.api_base = api_base
- @staticmethod
- def get_ui_field_behaviour() -> dict[str, Any]:
+ @classmethod
Review Comment:
yes, the method is a classmethod in the parent BaseHook and with
staticmethod it complains that it does not match the parent class, hence making
it consistent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]