sunank200 commented on code in PR #37307:
URL: https://github.com/apache/airflow/pull/37307#discussion_r1579126340


##########
airflow/providers/pinecone/hooks/pinecone.py:
##########
@@ -64,43 +69,73 @@ def get_ui_field_behaviour(cls) -> dict[str, Any]:
         """Return custom field behaviour."""
         return {
             "hidden_fields": ["port", "schema"],
-            "relabeling": {"login": "Pinecone Environment", "password": 
"Pinecone API key"},
+            "relabeling": {
+                "login": "Pinecone Environment",
+                "host": "Pinecone Host",
+                "password": "Pinecone API key",
+            },
         }
 
-    def __init__(self, conn_id: str = default_conn_name) -> None:
+    def __init__(
+        self, conn_id: str = default_conn_name, environment: str | None = 
None, region: str | None = None
+    ) -> None:
         self.conn_id = conn_id
-        self.get_conn()
-
-    def get_conn(self) -> None:
-        pinecone_connection = self.get_connection(self.conn_id)
-        api_key = pinecone_connection.password
-        pinecone_environment = pinecone_connection.login
-        pinecone_host = pinecone_connection.host
-        extras = pinecone_connection.extra_dejson
+        self._environment = environment
+        self._region = region
+        self.conn = self.get_conn()
+
+    @property
+    def api_key(self) -> str:
+        key = self.conn.password
+        if not key:
+            raise LookupError("Pinecone API Key not found in connection")
+        return key
+
+    @cached_property
+    def environment(self) -> str:
+        if self._environment:
+            return self._environment
+        env = self.conn.login
+        if not env:
+            raise LookupError("Pinecone environment not found in connection")
+        return env
+
+    @cached_property
+    def region(self) -> str:
+        if self._region:
+            return self._region
+        region = self.conn.extra_dejson.get("region")
+        if not region:
+            raise LookupError("Pinecone region not found in connection")
+        return region
+
+    @cached_property
+    def pc(self) -> Pinecone:
+        """Pinecone object to interact with Pinecone."""

Review Comment:
   Can you change this name if its not a standard term used, p



##########
airflow/providers/pinecone/hooks/pinecone.py:
##########
@@ -64,43 +69,73 @@ def get_ui_field_behaviour(cls) -> dict[str, Any]:
         """Return custom field behaviour."""
         return {
             "hidden_fields": ["port", "schema"],
-            "relabeling": {"login": "Pinecone Environment", "password": 
"Pinecone API key"},
+            "relabeling": {
+                "login": "Pinecone Environment",
+                "host": "Pinecone Host",
+                "password": "Pinecone API key",
+            },
         }
 
-    def __init__(self, conn_id: str = default_conn_name) -> None:
+    def __init__(
+        self, conn_id: str = default_conn_name, environment: str | None = 
None, region: str | None = None
+    ) -> None:
         self.conn_id = conn_id
-        self.get_conn()
-
-    def get_conn(self) -> None:
-        pinecone_connection = self.get_connection(self.conn_id)
-        api_key = pinecone_connection.password
-        pinecone_environment = pinecone_connection.login
-        pinecone_host = pinecone_connection.host
-        extras = pinecone_connection.extra_dejson
+        self._environment = environment
+        self._region = region
+        self.conn = self.get_conn()
+
+    @property
+    def api_key(self) -> str:
+        key = self.conn.password
+        if not key:
+            raise LookupError("Pinecone API Key not found in connection")
+        return key
+
+    @cached_property
+    def environment(self) -> str:
+        if self._environment:
+            return self._environment
+        env = self.conn.login
+        if not env:
+            raise LookupError("Pinecone environment not found in connection")
+        return env
+
+    @cached_property
+    def region(self) -> str:
+        if self._region:
+            return self._region
+        region = self.conn.extra_dejson.get("region")
+        if not region:
+            raise LookupError("Pinecone region not found in connection")
+        return region
+
+    @cached_property
+    def pc(self) -> Pinecone:
+        """Pinecone object to interact with Pinecone."""

Review Comment:
   Can you change this name if its not a standard term used, please



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to