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


##########
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

Review Comment:
   > check all these attribute in __init__ all at once? (e.g., all([...]))`
   @Lee-W , I'm sorry. I need help understanding this. Do you want to check if 
the `environment` and `region` are passed directly in the arguments?  I am 
unsure how we can use `all`  in `__init__` here as these properties can be part 
of the connection or the object and might be missing.
   
   For instance, a user might not even pass `region` when using a pod-based 
index and 
   



-- 
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