Copilot commented on code in PR #205:
URL: 
https://github.com/apache/incubator-hugegraph-ai/pull/205#discussion_r2030710156


##########
hugegraph-llm/src/hugegraph_llm/utils/hugegraph_utils.py:
##########
@@ -168,3 +170,29 @@ def manage_backup_retention():
     except Exception as e:  # pylint: disable=W0718
         log.error("Failed to manage backup retention: %s", e, exc_info=True)
         raise Exception("Failed to manage backup retention") from e
+
+def check_graph_db_connection(
+    ip: str,
+    port: str,
+    name: str,
+    user: str,
+    pwd: str,
+    graph_space: str
+) -> bool:
+    try:
+        if graph_space and graph_space.strip():
+            test_url = 
f"http://{ip}:{port}/graphspaces/{graph_space}/graphs/{name}/schema";
+        else:
+            test_url = f"http://{ip}:{port}/graphs/{name}/schema";
+        auth = HTTPBasicAuth(user, pwd)
+        response = requests.get(test_url, timeout=(1.0, 5.0), auth=auth)
+        return response.status_code == 200
+    except (requests.exceptions.RequestException, requests.exceptions.Timeout) 
as e:
+        log.warning("GraphDB connection error: %s", str(e))
+        return False
+    except ConnectionError as e:
+        log.warning("network connection error: %s", str(e))
+        return False

Review Comment:
   Catching ConnectionError separately may be redundant since 
requests.exceptions.RequestException already covers connection-related errors. 
Consider consolidating these exception handlers.
   ```suggestion
   
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to