javeme commented on code in PR #5:
URL:
https://github.com/apache/incubator-hugegraph-ai/pull/5#discussion_r1356643838
##########
hugegraph-python/example/test_connection.py:
##########
@@ -0,0 +1,23 @@
+import unittest
+from typing import Any
+from unittest.mock import MagicMock, patch
+
+from example.test_hugegraph import HugeGraph
+
+class HugeGraphTest(unittest.TestCase):
Review Comment:
also rename the file name?
##########
hugegraph-python/example/test_connection.py:
##########
@@ -0,0 +1,23 @@
+import unittest
Review Comment:
missing license header?
##########
hugegraph-python/example/test_connection.py:
##########
@@ -0,0 +1,23 @@
+import unittest
+from typing import Any
+from unittest.mock import MagicMock, patch
+
+from example.test_hugegraph import HugeGraph
+
+class HugeGraphTest(unittest.TestCase):
+ def setUp(self) -> None:
+ self.username = "test_user"
+ self.password = "test_password"
+ self.address = "test_address"
+ self.graph = "test_hugegraph"
+ self.port = 1234
+ self.session_pool_size = 10
+
+ @patch("src.client.PyHugeGraph")
+ def test_init(self, a: Any) -> None:
+ a.return_value = MagicMock()
+ client = HugeGraph(self.username, self.password,self.address,
self.port, self.graph)
Review Comment:
expect a space "self.password,"
##########
hugegraph-python/src/api/graphs.py:
##########
@@ -0,0 +1,71 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either expresponses or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import json
+import re
+
+import requests
+
+from src.api.common import HugeParamsBase
+
+from src.utils.constants import Constants
+from src.utils.exceptions import NotFoundError
+from src.utils.huge_requests import HugeSession
+from src.utils.util import check_if_success
+
+
+class GraphsManager(HugeParamsBase):
+ def __init__(self, graph_instance):
+ super().__init__(graph_instance)
+ self.session = self.set_session(HugeSession.new_session())
+
+ def set_session(self, session):
+ self.session = session
+ return session
+
+ def close(self):
+ if self.session:
+ self.session.close()
+
+ def get_all_graphs(self):
+ url = f'{self._host}/graphs'
+ response = self.session.get(url, auth=self._auth,
headers=self._headers)
+ if check_if_success(response, NotFoundError(response.content)):
+ return str(response.content)
+
+ def get_version(self):
+ url = f'{self._host}/versions'
+ response = self.session.get(url, auth=self._auth,
headers=self._headers)
+ if check_if_success(response, NotFoundError(response.content)):
+ return str(response.content)
+
+ def get_graph_info(self):
+ url = f'{self._host}/graphs/{self._graph_name}'
+ response = self.session.get(url, auth=self._auth,
headers=self._headers)
+ if check_if_success(response, NotFoundError(response.content)):
+ return str(response.content)
+
+ def clear_graph_all_data(self):
+ url =
f'{self._host}/graphs/{self._graph_name}/clear?confirm_message={Constants.CONFORM_MESSAGE}'
+ response = self.session.delete(url, auth=self._auth,
headers=self._headers)
+ if check_if_success(response, NotFoundError(response.content)):
+ return str(response.content)
+
+ def get_graph_config(self):
+ url = self._host + "/graphs" + "/" + self._graph_name + "/conf"
+ response = self.session.get(url, auth=self._auth,
headers=self._headers)
+ if check_if_success(response, NotFoundError(response.content)):
+ return str(response.content)
Review Comment:
expect a blank line
##########
hugegraph-python/example/test.py:
##########
@@ -0,0 +1,51 @@
+from src.client import PyHugeClient
Review Comment:
missing license header?
##########
hugegraph-python/example/test_connection.py:
##########
@@ -0,0 +1,23 @@
+import unittest
+from typing import Any
+from unittest.mock import MagicMock, patch
+
+from example.test_hugegraph import HugeGraph
+
+class HugeGraphTest(unittest.TestCase):
+ def setUp(self) -> None:
+ self.username = "test_user"
+ self.password = "test_password"
+ self.address = "test_address"
+ self.graph = "test_hugegraph"
+ self.port = 1234
+ self.session_pool_size = 10
+
+ @patch("src.client.PyHugeGraph")
+ def test_init(self, a: Any) -> None:
Review Comment:
rename `a` to `mock_graph`?
##########
hugegraph-python/src/api/schema.py:
##########
@@ -0,0 +1,166 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+import json
+
+from src.api.common import HugeParamsBase
+from src.api.schema_manage.edge_label import EdgeLabel
+from src.api.schema_manage.index_label import IndexLabel
+from src.api.schema_manage.property_key import PropertyKey
+from src.api.schema_manage.vertex_label import VertexLabel
+from src.structure.edge_label_data import EdgeLabelData
+from src.structure.index_label_data import IndexLabelData
+from src.structure.property_key_data import PropertyKeyData
+from src.structure.vertex_label_data import VertexLabelData
+from src.utils.exceptions import NotFoundError
+from src.utils.huge_requests import HugeSession
+from src.utils.util import check_if_success
+
+
+class SchemaManager(HugeParamsBase):
+ def __init__(self, graph_instance):
+ super().__init__(graph_instance)
+ self.session = self.set_session(HugeSession.new_session())
+
+ def set_session(self, session):
+ self.session = session
+ return session
+
+ def close(self):
+ if self.session:
+ self.session.close()
+
+ """
+ create schemas, including propertyKey/vertexLabel/edgeLabel/indexLabel
+ """
+
+ def propertyKey(self, property_name):
+ property_key = PropertyKey(self._graph_instance, self.session)
+ property_key.create_parameter_holder()
+ property_key.add_parameter("name", property_name)
+ property_key.add_parameter("not_exist", True)
+ return property_key
+
+ def vertexLabel(self, vertex_name):
+ vertex_label = VertexLabel(self._graph_instance, self.session)
+ vertex_label.create_parameter_holder()
+ vertex_label.add_parameter("name", vertex_name)
+ # vertex_label.add_parameter("id_strategy", "AUTOMATIC")
+ vertex_label.add_parameter("not_exist", True)
+ return vertex_label
+
+ def edgeLabel(self, name):
+ edge_label = EdgeLabel(self._graph_instance, self.session)
+ edge_label.create_parameter_holder()
+ edge_label.add_parameter("name", name)
+ edge_label.add_parameter("not_exist", True)
+ return edge_label
+
+ def indexLabel(self, name):
+ index_label = IndexLabel(self._graph_instance, self.session)
+ index_label.create_parameter_holder()
+ index_label.add_parameter("name", name)
+ return index_label
+
+ """
+ get schemas info.
+ """
Review Comment:
can we keep the same style with "create schemas"
--
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]