From 981c3613498aeafed47c55cc6ed90a8f70e0369e Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 20 Oct 2023 15:44:53 +0800 Subject: [PATCH 1/5] improve project struct --- hugegraph-llm/README.md | 2 +- hugegraph-llm/examples/build_kg_test.py | 4 ++-- .../src/{ => hugegraph_llm/llms}/__init__.py | 0 .../llm => hugegraph_llm/llms}/base.py | 0 .../llm => hugegraph_llm/llms}/openai_llm.py | 2 +- .../operators/build_kg_operator.py | 8 +++---- .../operators/hugegraph_op}/__init__.py | 0 .../hugegraph_op}/commit_data_to_kg.py | 4 ++-- .../operators/llm_op}/__init__.py | 0 .../operators/llm_op}/disambiguate_data.py | 4 ++-- .../operators/llm_op}/parse_text_to_data.py | 4 ++-- .../llm_op}/unstructured_data_utils.py | 0 hugegraph-llm/src/operators/llm/__init__.py | 16 ------------- hugegraph-python/README.md | 2 +- hugegraph-python/example/hugegraph_test.py | 2 +- hugegraph-python/example/test.py | 2 +- .../src/{ => pyhugegraph/api}/__init__.py | 0 .../src/{ => pyhugegraph}/api/common.py | 2 +- .../src/{ => pyhugegraph}/api/graph.py | 12 +++++----- .../src/{ => pyhugegraph}/api/graphs.py | 10 ++++---- .../src/{ => pyhugegraph}/api/gremlin.py | 10 ++++---- .../src/{ => pyhugegraph}/api/schema.py | 24 +++++++++---------- .../api/schema_manage}/__init__.py | 0 .../api/schema_manage/edge_label.py | 8 +++---- .../api/schema_manage/index_label.py | 8 +++---- .../api/schema_manage/property_key.py | 8 +++---- .../api/schema_manage/vertex_label.py | 8 +++---- .../src/{ => pyhugegraph}/client.py | 12 +++++----- .../structure}/__init__.py | 0 .../{ => pyhugegraph}/structure/edge_data.py | 0 .../structure/edge_label_data.py | 0 .../structure/graph_instance.py | 0 .../structure/index_label_data.py | 0 .../structure/property_key_data.py | 0 .../structure/respon_data.py | 0 .../structure/vertex_data.py | 0 .../structure/vertex_label_data.py | 0 .../utils}/__init__.py | 0 .../src/{ => pyhugegraph}/utils/constants.py | 0 .../src/{ => pyhugegraph}/utils/exceptions.py | 0 .../{ => pyhugegraph}/utils/huge_decorator.py | 2 +- .../{ => pyhugegraph}/utils/huge_requests.py | 0 .../src/{ => pyhugegraph}/utils/util.py | 2 +- hugegraph-python/src/utils/__init__.py | 16 ------------- 44 files changed, 70 insertions(+), 102 deletions(-) rename hugegraph-llm/src/{ => hugegraph_llm/llms}/__init__.py (100%) rename hugegraph-llm/src/{operators/llm => hugegraph_llm/llms}/base.py (100%) rename hugegraph-llm/src/{operators/llm => hugegraph_llm/llms}/openai_llm.py (98%) rename hugegraph-llm/src/{ => hugegraph_llm}/operators/build_kg_operator.py (88%) rename hugegraph-llm/src/{operators => hugegraph_llm/operators/hugegraph_op}/__init__.py (100%) rename hugegraph-llm/src/{operators/build_kg => hugegraph_llm/operators/hugegraph_op}/commit_data_to_kg.py (98%) rename hugegraph-llm/src/{operators/build_kg => hugegraph_llm/operators/llm_op}/__init__.py (100%) rename hugegraph-llm/src/{operators/build_kg => hugegraph_llm/operators/llm_op}/disambiguate_data.py (98%) rename hugegraph-llm/src/{operators/build_kg => hugegraph_llm/operators/llm_op}/parse_text_to_data.py (98%) rename hugegraph-llm/src/{operators/build_kg => hugegraph_llm/operators/llm_op}/unstructured_data_utils.py (100%) delete mode 100644 hugegraph-llm/src/operators/llm/__init__.py rename hugegraph-python/src/{ => pyhugegraph/api}/__init__.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/api/common.py (94%) rename hugegraph-python/src/{ => pyhugegraph}/api/graph.py (94%) rename hugegraph-python/src/{ => pyhugegraph}/api/graphs.py (88%) rename hugegraph-python/src/{ => pyhugegraph}/api/gremlin.py (83%) rename hugegraph-python/src/{ => pyhugegraph}/api/schema.py (87%) rename hugegraph-python/src/{api => pyhugegraph/api/schema_manage}/__init__.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/api/schema_manage/edge_label.py (93%) rename hugegraph-python/src/{ => pyhugegraph}/api/schema_manage/index_label.py (91%) rename hugegraph-python/src/{ => pyhugegraph}/api/schema_manage/property_key.py (93%) rename hugegraph-python/src/{ => pyhugegraph}/api/schema_manage/vertex_label.py (93%) rename hugegraph-python/src/{ => pyhugegraph}/client.py (83%) rename hugegraph-python/src/{api/schema_manage => pyhugegraph/structure}/__init__.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/structure/edge_data.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/structure/edge_label_data.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/structure/graph_instance.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/structure/index_label_data.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/structure/property_key_data.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/structure/respon_data.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/structure/vertex_data.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/structure/vertex_label_data.py (100%) rename hugegraph-python/src/{structure => pyhugegraph/utils}/__init__.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/utils/constants.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/utils/exceptions.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/utils/huge_decorator.py (94%) rename hugegraph-python/src/{ => pyhugegraph}/utils/huge_requests.py (100%) rename hugegraph-python/src/{ => pyhugegraph}/utils/util.py (91%) delete mode 100644 hugegraph-python/src/utils/__init__.py diff --git a/hugegraph-llm/README.md b/hugegraph-llm/README.md index 3fb644102..acfc8d60d 100644 --- a/hugegraph-llm/README.md +++ b/hugegraph-llm/README.md @@ -16,7 +16,7 @@ With this project, we aim to reduce the cost of using graph systems, and decreas ## Examples(knowledge graph construction by llm) 1. Start the HugeGraph database, you can do it via Docker. Refer to this [link](https://hub.docker.com/r/hugegraph/hugegraph) for guidance -2. Run example like python hugegraph-llm/examples/build_kg_test.py +2. Run example like `python hugegraph-llm/examples/build_kg_test.py` Note: If you need a proxy to access OpenAI's API, please set your HTTP proxy in `build_kg_test.py`. diff --git a/hugegraph-llm/examples/build_kg_test.py b/hugegraph-llm/examples/build_kg_test.py index ef6dad511..e1bdfb30b 100644 --- a/hugegraph-llm/examples/build_kg_test.py +++ b/hugegraph-llm/examples/build_kg_test.py @@ -15,8 +15,8 @@ # specific language governing permissions and limitations # under the License. import os -from src.operators.build_kg_operator import KgBuilder -from src.operators.llm.openai_llm import OpenAIChat +from hugegraph_llm.operators.build_kg_operator import KgBuilder +from hugegraph_llm.llms.openai_llm import OpenAIChat if __name__ == "__main__": # If you need a proxy to access OpenAI's API, please set your HTTP proxy here diff --git a/hugegraph-llm/src/__init__.py b/hugegraph-llm/src/hugegraph_llm/llms/__init__.py similarity index 100% rename from hugegraph-llm/src/__init__.py rename to hugegraph-llm/src/hugegraph_llm/llms/__init__.py diff --git a/hugegraph-llm/src/operators/llm/base.py b/hugegraph-llm/src/hugegraph_llm/llms/base.py similarity index 100% rename from hugegraph-llm/src/operators/llm/base.py rename to hugegraph-llm/src/hugegraph_llm/llms/base.py diff --git a/hugegraph-llm/src/operators/llm/openai_llm.py b/hugegraph-llm/src/hugegraph_llm/llms/openai_llm.py similarity index 98% rename from hugegraph-llm/src/operators/llm/openai_llm.py rename to hugegraph-llm/src/hugegraph_llm/llms/openai_llm.py index b8da93055..ded7f3487 100644 --- a/hugegraph-llm/src/operators/llm/openai_llm.py +++ b/hugegraph-llm/src/hugegraph_llm/llms/openai_llm.py @@ -19,7 +19,7 @@ import tiktoken from retry import retry -from src.operators.llm.base import BaseLLM +from hugegraph_llm.llms.base import BaseLLM class OpenAIChat(BaseLLM): diff --git a/hugegraph-llm/src/operators/build_kg_operator.py b/hugegraph-llm/src/hugegraph_llm/operators/build_kg_operator.py similarity index 88% rename from hugegraph-llm/src/operators/build_kg_operator.py rename to hugegraph-llm/src/hugegraph_llm/operators/build_kg_operator.py index 0b6753f21..ee0d15452 100644 --- a/hugegraph-llm/src/operators/build_kg_operator.py +++ b/hugegraph-llm/src/hugegraph_llm/operators/build_kg_operator.py @@ -14,13 +14,13 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from src.operators.build_kg.commit_data_to_kg import CommitDataToKg -from src.operators.build_kg.disambiguate_data import DisambiguateData -from src.operators.build_kg.parse_text_to_data import ( +from hugegraph_llm.operators.hugegraph_op.commit_data_to_kg import CommitDataToKg +from hugegraph_llm.operators.llm_op.disambiguate_data import DisambiguateData +from hugegraph_llm.operators.llm_op.parse_text_to_data import ( ParseTextToData, ParseTextToDataWithSchemas, ) -from src.operators.llm.base import BaseLLM +from hugegraph_llm.llms.base import BaseLLM class KgBuilder: diff --git a/hugegraph-llm/src/operators/__init__.py b/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/__init__.py similarity index 100% rename from hugegraph-llm/src/operators/__init__.py rename to hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/__init__.py diff --git a/hugegraph-llm/src/operators/build_kg/commit_data_to_kg.py b/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/commit_data_to_kg.py similarity index 98% rename from hugegraph-llm/src/operators/build_kg/commit_data_to_kg.py rename to hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/commit_data_to_kg.py index 79aec7963..7d1c92977 100644 --- a/hugegraph-llm/src/operators/build_kg/commit_data_to_kg.py +++ b/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/commit_data_to_kg.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. import os -from hugegraph.connection import PyHugeGraph +from pyhugegraph.client import PyHugeClient def generate_new_relationships(nodes_schemas_data, relationships_data): @@ -140,7 +140,7 @@ def generate_relationships(data): class CommitDataToKg: def __init__(self): - self.client = PyHugeGraph( + self.client = PyHugeClient( "127.0.0.1", "8080", user="admin", pwd="admin", graph="hugegraph" ) self.schema = self.client.schema() diff --git a/hugegraph-llm/src/operators/build_kg/__init__.py b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/__init__.py similarity index 100% rename from hugegraph-llm/src/operators/build_kg/__init__.py rename to hugegraph-llm/src/hugegraph_llm/operators/llm_op/__init__.py diff --git a/hugegraph-llm/src/operators/build_kg/disambiguate_data.py b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/disambiguate_data.py similarity index 98% rename from hugegraph-llm/src/operators/build_kg/disambiguate_data.py rename to hugegraph-llm/src/hugegraph_llm/operators/llm_op/disambiguate_data.py index cd7f3fe70..e982d99fc 100644 --- a/hugegraph-llm/src/operators/build_kg/disambiguate_data.py +++ b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/disambiguate_data.py @@ -18,13 +18,13 @@ import re from itertools import groupby -from src.operators.build_kg.unstructured_data_utils import ( +from hugegraph_llm.operators.llm_op.unstructured_data_utils import ( nodes_text_to_list_of_dict, relationships_text_to_list_of_dict, relationships_schemas_text_to_list_of_dict, nodes_schemas_text_to_list_of_dict, ) -from src.operators.llm.base import BaseLLM +from hugegraph_llm.llms.base import BaseLLM def disambiguate_nodes() -> str: diff --git a/hugegraph-llm/src/operators/build_kg/parse_text_to_data.py b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/parse_text_to_data.py similarity index 98% rename from hugegraph-llm/src/operators/build_kg/parse_text_to_data.py rename to hugegraph-llm/src/hugegraph_llm/operators/llm_op/parse_text_to_data.py index 8e1a3fb4e..1b67f76ed 100644 --- a/hugegraph-llm/src/operators/build_kg/parse_text_to_data.py +++ b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/parse_text_to_data.py @@ -17,13 +17,13 @@ import re from typing import List -from src.operators.build_kg.unstructured_data_utils import ( +from hugegraph_llm.operators.llm_op.unstructured_data_utils import ( nodes_text_to_list_of_dict, nodes_schemas_text_to_list_of_dict, relationships_schemas_text_to_list_of_dict, relationships_text_to_list_of_dict, ) -from src.operators.llm.base import BaseLLM +from hugegraph_llm.llms.base import BaseLLM def generate_system_message() -> str: diff --git a/hugegraph-llm/src/operators/build_kg/unstructured_data_utils.py b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/unstructured_data_utils.py similarity index 100% rename from hugegraph-llm/src/operators/build_kg/unstructured_data_utils.py rename to hugegraph-llm/src/hugegraph_llm/operators/llm_op/unstructured_data_utils.py diff --git a/hugegraph-llm/src/operators/llm/__init__.py b/hugegraph-llm/src/operators/llm/__init__.py deleted file mode 100644 index 13a83393a..000000000 --- a/hugegraph-llm/src/operators/llm/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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. diff --git a/hugegraph-python/README.md b/hugegraph-python/README.md index 42106473f..6dfba1760 100644 --- a/hugegraph-python/README.md +++ b/hugegraph-python/README.md @@ -13,7 +13,7 @@ release soon # Examples ```python -from src.client import PyHugeClient +from pyhugegraph.client import PyHugeClient client = PyHugeClient("127.0.0.1", "8080", user="admin", pwd="admin", graph="hugegraph") diff --git a/hugegraph-python/example/hugegraph_test.py b/hugegraph-python/example/hugegraph_test.py index e41908aaf..23b8de619 100644 --- a/hugegraph-python/example/hugegraph_test.py +++ b/hugegraph-python/example/hugegraph_test.py @@ -28,7 +28,7 @@ def __init__( ) -> None: """Create a new HugeGraph wrapper instance.""" try: - from src.client import PyHugeClient + from pyhugegraph.client import PyHugeClient except ImportError: raise ValueError( "Please install HugeGraph Python client first: " diff --git a/hugegraph-python/example/test.py b/hugegraph-python/example/test.py index 056ccae8a..05ce0a89b 100644 --- a/hugegraph-python/example/test.py +++ b/hugegraph-python/example/test.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from src.client import PyHugeClient +from pyhugegraph.client import PyHugeClient if __name__ == '__main__': client = PyHugeClient("127.0.0.1", "8080", user="admin", pwd="admin", graph="test") diff --git a/hugegraph-python/src/__init__.py b/hugegraph-python/src/pyhugegraph/api/__init__.py similarity index 100% rename from hugegraph-python/src/__init__.py rename to hugegraph-python/src/pyhugegraph/api/__init__.py diff --git a/hugegraph-python/src/api/common.py b/hugegraph-python/src/pyhugegraph/api/common.py similarity index 94% rename from hugegraph-python/src/api/common.py rename to hugegraph-python/src/pyhugegraph/api/common.py index 42b6c0aea..8daefec06 100644 --- a/hugegraph-python/src/api/common.py +++ b/hugegraph-python/src/pyhugegraph/api/common.py @@ -14,7 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from src.utils.constants import Constants +from pyhugegraph.utils.constants import Constants class ParameterHolder: diff --git a/hugegraph-python/src/api/graph.py b/hugegraph-python/src/pyhugegraph/api/graph.py similarity index 94% rename from hugegraph-python/src/api/graph.py rename to hugegraph-python/src/pyhugegraph/api/graph.py index 2deaa8994..0d0c278c4 100644 --- a/hugegraph-python/src/api/graph.py +++ b/hugegraph-python/src/pyhugegraph/api/graph.py @@ -17,12 +17,12 @@ import json -from src.utils.huge_requests import HugeSession -from src.api.common import HugeParamsBase -from src.structure.vertex_data import VertexData -from src.structure.edge_data import EdgeData -from src.utils.exceptions import NotFoundError, CreateError, RemoveError, UpdateError -from src.utils.util import create_exception, check_if_authorized, check_if_success +from pyhugegraph.utils.huge_requests import HugeSession +from pyhugegraph.api.common import HugeParamsBase +from pyhugegraph.structure.vertex_data import VertexData +from pyhugegraph.structure.edge_data import EdgeData +from pyhugegraph.utils.exceptions import NotFoundError, CreateError, RemoveError, UpdateError +from pyhugegraph.utils.util import create_exception, check_if_authorized, check_if_success class GraphManager(HugeParamsBase): diff --git a/hugegraph-python/src/api/graphs.py b/hugegraph-python/src/pyhugegraph/api/graphs.py similarity index 88% rename from hugegraph-python/src/api/graphs.py rename to hugegraph-python/src/pyhugegraph/api/graphs.py index b22ec3a95..b44aa6d83 100644 --- a/hugegraph-python/src/api/graphs.py +++ b/hugegraph-python/src/pyhugegraph/api/graphs.py @@ -19,12 +19,12 @@ import requests -from src.api.common import HugeParamsBase +from pyhugegraph.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 +from pyhugegraph.utils.constants import Constants +from pyhugegraph.utils.exceptions import NotFoundError +from pyhugegraph.utils.huge_requests import HugeSession +from pyhugegraph.utils.util import check_if_success class GraphsManager(HugeParamsBase): diff --git a/hugegraph-python/src/api/gremlin.py b/hugegraph-python/src/pyhugegraph/api/gremlin.py similarity index 83% rename from hugegraph-python/src/api/gremlin.py rename to hugegraph-python/src/pyhugegraph/api/gremlin.py index 38a7c3056..562a5bd79 100644 --- a/hugegraph-python/src/api/gremlin.py +++ b/hugegraph-python/src/pyhugegraph/api/gremlin.py @@ -19,11 +19,11 @@ import requests -from src.api.common import HugeParamsBase -from src.structure.respon_data import ResponseData -from src.utils.exceptions import NotFoundError -from src.utils.huge_requests import HugeSession -from src.utils.util import check_if_success +from pyhugegraph.api.common import HugeParamsBase +from pyhugegraph.structure.respon_data import ResponseData +from pyhugegraph.utils.exceptions import NotFoundError +from pyhugegraph.utils.huge_requests import HugeSession +from pyhugegraph.utils.util import check_if_success class GremlinManager(HugeParamsBase): diff --git a/hugegraph-python/src/api/schema.py b/hugegraph-python/src/pyhugegraph/api/schema.py similarity index 87% rename from hugegraph-python/src/api/schema.py rename to hugegraph-python/src/pyhugegraph/api/schema.py index 9001028f3..c0f6c83fc 100644 --- a/hugegraph-python/src/api/schema.py +++ b/hugegraph-python/src/pyhugegraph/api/schema.py @@ -18,18 +18,18 @@ 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 +from pyhugegraph.api.common import HugeParamsBase +from pyhugegraph.api.schema_manage.edge_label import EdgeLabel +from pyhugegraph.api.schema_manage.index_label import IndexLabel +from pyhugegraph.api.schema_manage.property_key import PropertyKey +from pyhugegraph.api.schema_manage.vertex_label import VertexLabel +from pyhugegraph.structure.edge_label_data import EdgeLabelData +from pyhugegraph.structure.index_label_data import IndexLabelData +from pyhugegraph.structure.property_key_data import PropertyKeyData +from pyhugegraph.structure.vertex_label_data import VertexLabelData +from pyhugegraph.utils.exceptions import NotFoundError +from pyhugegraph.utils.huge_requests import HugeSession +from pyhugegraph.utils.util import check_if_success class SchemaManager(HugeParamsBase): diff --git a/hugegraph-python/src/api/__init__.py b/hugegraph-python/src/pyhugegraph/api/schema_manage/__init__.py similarity index 100% rename from hugegraph-python/src/api/__init__.py rename to hugegraph-python/src/pyhugegraph/api/schema_manage/__init__.py diff --git a/hugegraph-python/src/api/schema_manage/edge_label.py b/hugegraph-python/src/pyhugegraph/api/schema_manage/edge_label.py similarity index 93% rename from hugegraph-python/src/api/schema_manage/edge_label.py rename to hugegraph-python/src/pyhugegraph/api/schema_manage/edge_label.py index 31d81d968..502d08464 100644 --- a/hugegraph-python/src/api/schema_manage/edge_label.py +++ b/hugegraph-python/src/pyhugegraph/api/schema_manage/edge_label.py @@ -17,10 +17,10 @@ import json -from src.api.common import HugeParamsBase -from src.utils.exceptions import CreateError, UpdateError, RemoveError -from src.utils.huge_decorator import decorator_params, decorator_create -from src.utils.util import check_if_success, check_if_authorized +from pyhugegraph.api.common import HugeParamsBase +from pyhugegraph.utils.exceptions import CreateError, UpdateError, RemoveError +from pyhugegraph.utils.huge_decorator import decorator_params, decorator_create +from pyhugegraph.utils.util import check_if_success, check_if_authorized class EdgeLabel(HugeParamsBase): diff --git a/hugegraph-python/src/api/schema_manage/index_label.py b/hugegraph-python/src/pyhugegraph/api/schema_manage/index_label.py similarity index 91% rename from hugegraph-python/src/api/schema_manage/index_label.py rename to hugegraph-python/src/pyhugegraph/api/schema_manage/index_label.py index cc93a9103..e29c8c775 100644 --- a/hugegraph-python/src/api/schema_manage/index_label.py +++ b/hugegraph-python/src/pyhugegraph/api/schema_manage/index_label.py @@ -19,10 +19,10 @@ import requests -from src.api.common import HugeParamsBase -from src.utils.huge_decorator import decorator_params, decorator_create -from src.utils.exceptions import CreateError, RemoveError -from src.utils.util import check_if_authorized, check_if_success +from pyhugegraph.api.common import HugeParamsBase +from pyhugegraph.utils.huge_decorator import decorator_params, decorator_create +from pyhugegraph.utils.exceptions import CreateError, RemoveError +from pyhugegraph.utils.util import check_if_authorized, check_if_success class IndexLabel(HugeParamsBase): diff --git a/hugegraph-python/src/api/schema_manage/property_key.py b/hugegraph-python/src/pyhugegraph/api/schema_manage/property_key.py similarity index 93% rename from hugegraph-python/src/api/schema_manage/property_key.py rename to hugegraph-python/src/pyhugegraph/api/schema_manage/property_key.py index 6f9cce4ac..7a7f0e79e 100644 --- a/hugegraph-python/src/api/schema_manage/property_key.py +++ b/hugegraph-python/src/pyhugegraph/api/schema_manage/property_key.py @@ -19,10 +19,10 @@ import requests -from src.api.common import HugeParamsBase -from src.utils.exceptions import CreateError, UpdateError, RemoveError -from src.utils.huge_decorator import decorator_params, decorator_create -from src.utils.util import check_if_success, check_if_authorized +from pyhugegraph.api.common import HugeParamsBase +from pyhugegraph.utils.exceptions import CreateError, UpdateError, RemoveError +from pyhugegraph.utils.huge_decorator import decorator_params, decorator_create +from pyhugegraph.utils.util import check_if_success, check_if_authorized class PropertyKey(HugeParamsBase): diff --git a/hugegraph-python/src/api/schema_manage/vertex_label.py b/hugegraph-python/src/pyhugegraph/api/schema_manage/vertex_label.py similarity index 93% rename from hugegraph-python/src/api/schema_manage/vertex_label.py rename to hugegraph-python/src/pyhugegraph/api/schema_manage/vertex_label.py index 462fe138c..e031fd327 100644 --- a/hugegraph-python/src/api/schema_manage/vertex_label.py +++ b/hugegraph-python/src/pyhugegraph/api/schema_manage/vertex_label.py @@ -19,10 +19,10 @@ import requests -from src.api.common import HugeParamsBase -from src.utils.exceptions import CreateError, UpdateError, RemoveError -from src.utils.huge_decorator import decorator_params, decorator_create -from src.utils.util import check_if_success, check_if_authorized +from pyhugegraph.api.common import HugeParamsBase +from pyhugegraph.utils.exceptions import CreateError, UpdateError, RemoveError +from pyhugegraph.utils.huge_decorator import decorator_params, decorator_create +from pyhugegraph.utils.util import check_if_success, check_if_authorized class VertexLabel(HugeParamsBase): diff --git a/hugegraph-python/src/client.py b/hugegraph-python/src/pyhugegraph/client.py similarity index 83% rename from hugegraph-python/src/client.py rename to hugegraph-python/src/pyhugegraph/client.py index b039725b8..e12b73d56 100644 --- a/hugegraph-python/src/client.py +++ b/hugegraph-python/src/pyhugegraph/client.py @@ -15,12 +15,12 @@ # specific language governing permissions and limitations # under the License. -from src.api.common import HugeParamsBase -from src.api.graph import GraphManager -from src.api.graphs import GraphsManager -from src.api.gremlin import GremlinManager -from src.api.schema import SchemaManager -from src.structure.graph_instance import GraphInstance +from pyhugegraph.api.common import HugeParamsBase +from pyhugegraph.api.graph import GraphManager +from pyhugegraph.api.graphs import GraphsManager +from pyhugegraph.api.gremlin import GremlinManager +from pyhugegraph.api.schema import SchemaManager +from pyhugegraph.structure.graph_instance import GraphInstance class PyHugeClient(HugeParamsBase): diff --git a/hugegraph-python/src/api/schema_manage/__init__.py b/hugegraph-python/src/pyhugegraph/structure/__init__.py similarity index 100% rename from hugegraph-python/src/api/schema_manage/__init__.py rename to hugegraph-python/src/pyhugegraph/structure/__init__.py diff --git a/hugegraph-python/src/structure/edge_data.py b/hugegraph-python/src/pyhugegraph/structure/edge_data.py similarity index 100% rename from hugegraph-python/src/structure/edge_data.py rename to hugegraph-python/src/pyhugegraph/structure/edge_data.py diff --git a/hugegraph-python/src/structure/edge_label_data.py b/hugegraph-python/src/pyhugegraph/structure/edge_label_data.py similarity index 100% rename from hugegraph-python/src/structure/edge_label_data.py rename to hugegraph-python/src/pyhugegraph/structure/edge_label_data.py diff --git a/hugegraph-python/src/structure/graph_instance.py b/hugegraph-python/src/pyhugegraph/structure/graph_instance.py similarity index 100% rename from hugegraph-python/src/structure/graph_instance.py rename to hugegraph-python/src/pyhugegraph/structure/graph_instance.py diff --git a/hugegraph-python/src/structure/index_label_data.py b/hugegraph-python/src/pyhugegraph/structure/index_label_data.py similarity index 100% rename from hugegraph-python/src/structure/index_label_data.py rename to hugegraph-python/src/pyhugegraph/structure/index_label_data.py diff --git a/hugegraph-python/src/structure/property_key_data.py b/hugegraph-python/src/pyhugegraph/structure/property_key_data.py similarity index 100% rename from hugegraph-python/src/structure/property_key_data.py rename to hugegraph-python/src/pyhugegraph/structure/property_key_data.py diff --git a/hugegraph-python/src/structure/respon_data.py b/hugegraph-python/src/pyhugegraph/structure/respon_data.py similarity index 100% rename from hugegraph-python/src/structure/respon_data.py rename to hugegraph-python/src/pyhugegraph/structure/respon_data.py diff --git a/hugegraph-python/src/structure/vertex_data.py b/hugegraph-python/src/pyhugegraph/structure/vertex_data.py similarity index 100% rename from hugegraph-python/src/structure/vertex_data.py rename to hugegraph-python/src/pyhugegraph/structure/vertex_data.py diff --git a/hugegraph-python/src/structure/vertex_label_data.py b/hugegraph-python/src/pyhugegraph/structure/vertex_label_data.py similarity index 100% rename from hugegraph-python/src/structure/vertex_label_data.py rename to hugegraph-python/src/pyhugegraph/structure/vertex_label_data.py diff --git a/hugegraph-python/src/structure/__init__.py b/hugegraph-python/src/pyhugegraph/utils/__init__.py similarity index 100% rename from hugegraph-python/src/structure/__init__.py rename to hugegraph-python/src/pyhugegraph/utils/__init__.py diff --git a/hugegraph-python/src/utils/constants.py b/hugegraph-python/src/pyhugegraph/utils/constants.py similarity index 100% rename from hugegraph-python/src/utils/constants.py rename to hugegraph-python/src/pyhugegraph/utils/constants.py diff --git a/hugegraph-python/src/utils/exceptions.py b/hugegraph-python/src/pyhugegraph/utils/exceptions.py similarity index 100% rename from hugegraph-python/src/utils/exceptions.py rename to hugegraph-python/src/pyhugegraph/utils/exceptions.py diff --git a/hugegraph-python/src/utils/huge_decorator.py b/hugegraph-python/src/pyhugegraph/utils/huge_decorator.py similarity index 94% rename from hugegraph-python/src/utils/huge_decorator.py rename to hugegraph-python/src/pyhugegraph/utils/huge_decorator.py index 9077bb810..3087778f6 100644 --- a/hugegraph-python/src/utils/huge_decorator.py +++ b/hugegraph-python/src/pyhugegraph/utils/huge_decorator.py @@ -17,7 +17,7 @@ from decorator import decorator -from src.utils.exceptions import NotAuthorizedError +from pyhugegraph.utils.exceptions import NotAuthorizedError @decorator diff --git a/hugegraph-python/src/utils/huge_requests.py b/hugegraph-python/src/pyhugegraph/utils/huge_requests.py similarity index 100% rename from hugegraph-python/src/utils/huge_requests.py rename to hugegraph-python/src/pyhugegraph/utils/huge_requests.py diff --git a/hugegraph-python/src/utils/util.py b/hugegraph-python/src/pyhugegraph/utils/util.py similarity index 91% rename from hugegraph-python/src/utils/util.py rename to hugegraph-python/src/pyhugegraph/utils/util.py index 9b9424bf3..c5368b0c5 100644 --- a/hugegraph-python/src/utils/util.py +++ b/hugegraph-python/src/pyhugegraph/utils/util.py @@ -17,7 +17,7 @@ import json -from src.utils.exceptions import ServiceUnavailableException, NotAuthorizedError, NotFoundError +from pyhugegraph.utils.exceptions import ServiceUnavailableException, NotAuthorizedError, NotFoundError def create_exception(response_content): diff --git a/hugegraph-python/src/utils/__init__.py b/hugegraph-python/src/utils/__init__.py deleted file mode 100644 index e0533d992..000000000 --- a/hugegraph-python/src/utils/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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. From fe810b1d6de94e20ec6f336ad53927332fae9426 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 20 Oct 2023 16:07:45 +0800 Subject: [PATCH 2/5] improve project struct --- {hugegraph-python => hugegraph-python-client}/README.md | 0 {hugegraph-python => hugegraph-python-client}/example/__init__.py | 0 .../example/client_test.py | 0 .../example/hugegraph_test.py | 0 {hugegraph-python => hugegraph-python-client}/example/test.py | 0 {hugegraph-python => hugegraph-python-client}/requirements.txt | 0 .../src/pyhugegraph/api/__init__.py | 0 .../src/pyhugegraph/api/common.py | 0 .../src/pyhugegraph/api/graph.py | 0 .../src/pyhugegraph/api/graphs.py | 0 .../src/pyhugegraph/api/gremlin.py | 0 .../src/pyhugegraph/api/schema.py | 0 .../src/pyhugegraph/api/schema_manage/__init__.py | 0 .../src/pyhugegraph/api/schema_manage/edge_label.py | 0 .../src/pyhugegraph/api/schema_manage/index_label.py | 0 .../src/pyhugegraph/api/schema_manage/property_key.py | 0 .../src/pyhugegraph/api/schema_manage/vertex_label.py | 0 .../src/pyhugegraph/client.py | 0 .../src/pyhugegraph/structure/__init__.py | 0 .../src/pyhugegraph/structure/edge_data.py | 0 .../src/pyhugegraph/structure/edge_label_data.py | 0 .../src/pyhugegraph/structure/graph_instance.py | 0 .../src/pyhugegraph/structure/index_label_data.py | 0 .../src/pyhugegraph/structure/property_key_data.py | 0 .../src/pyhugegraph/structure/respon_data.py | 0 .../src/pyhugegraph/structure/vertex_data.py | 0 .../src/pyhugegraph/structure/vertex_label_data.py | 0 .../src/pyhugegraph/utils/__init__.py | 0 .../src/pyhugegraph/utils/constants.py | 0 .../src/pyhugegraph/utils/exceptions.py | 0 .../src/pyhugegraph/utils/huge_decorator.py | 0 .../src/pyhugegraph/utils/huge_requests.py | 0 .../src/pyhugegraph/utils/util.py | 0 33 files changed, 0 insertions(+), 0 deletions(-) rename {hugegraph-python => hugegraph-python-client}/README.md (100%) rename {hugegraph-python => hugegraph-python-client}/example/__init__.py (100%) rename {hugegraph-python => hugegraph-python-client}/example/client_test.py (100%) rename {hugegraph-python => hugegraph-python-client}/example/hugegraph_test.py (100%) rename {hugegraph-python => hugegraph-python-client}/example/test.py (100%) rename {hugegraph-python => hugegraph-python-client}/requirements.txt (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/api/__init__.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/api/common.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/api/graph.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/api/graphs.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/api/gremlin.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/api/schema.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/api/schema_manage/__init__.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/api/schema_manage/edge_label.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/api/schema_manage/index_label.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/api/schema_manage/property_key.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/api/schema_manage/vertex_label.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/client.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/structure/__init__.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/structure/edge_data.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/structure/edge_label_data.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/structure/graph_instance.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/structure/index_label_data.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/structure/property_key_data.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/structure/respon_data.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/structure/vertex_data.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/structure/vertex_label_data.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/utils/__init__.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/utils/constants.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/utils/exceptions.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/utils/huge_decorator.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/utils/huge_requests.py (100%) rename {hugegraph-python => hugegraph-python-client}/src/pyhugegraph/utils/util.py (100%) diff --git a/hugegraph-python/README.md b/hugegraph-python-client/README.md similarity index 100% rename from hugegraph-python/README.md rename to hugegraph-python-client/README.md diff --git a/hugegraph-python/example/__init__.py b/hugegraph-python-client/example/__init__.py similarity index 100% rename from hugegraph-python/example/__init__.py rename to hugegraph-python-client/example/__init__.py diff --git a/hugegraph-python/example/client_test.py b/hugegraph-python-client/example/client_test.py similarity index 100% rename from hugegraph-python/example/client_test.py rename to hugegraph-python-client/example/client_test.py diff --git a/hugegraph-python/example/hugegraph_test.py b/hugegraph-python-client/example/hugegraph_test.py similarity index 100% rename from hugegraph-python/example/hugegraph_test.py rename to hugegraph-python-client/example/hugegraph_test.py diff --git a/hugegraph-python/example/test.py b/hugegraph-python-client/example/test.py similarity index 100% rename from hugegraph-python/example/test.py rename to hugegraph-python-client/example/test.py diff --git a/hugegraph-python/requirements.txt b/hugegraph-python-client/requirements.txt similarity index 100% rename from hugegraph-python/requirements.txt rename to hugegraph-python-client/requirements.txt diff --git a/hugegraph-python/src/pyhugegraph/api/__init__.py b/hugegraph-python-client/src/pyhugegraph/api/__init__.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/api/__init__.py rename to hugegraph-python-client/src/pyhugegraph/api/__init__.py diff --git a/hugegraph-python/src/pyhugegraph/api/common.py b/hugegraph-python-client/src/pyhugegraph/api/common.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/api/common.py rename to hugegraph-python-client/src/pyhugegraph/api/common.py diff --git a/hugegraph-python/src/pyhugegraph/api/graph.py b/hugegraph-python-client/src/pyhugegraph/api/graph.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/api/graph.py rename to hugegraph-python-client/src/pyhugegraph/api/graph.py diff --git a/hugegraph-python/src/pyhugegraph/api/graphs.py b/hugegraph-python-client/src/pyhugegraph/api/graphs.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/api/graphs.py rename to hugegraph-python-client/src/pyhugegraph/api/graphs.py diff --git a/hugegraph-python/src/pyhugegraph/api/gremlin.py b/hugegraph-python-client/src/pyhugegraph/api/gremlin.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/api/gremlin.py rename to hugegraph-python-client/src/pyhugegraph/api/gremlin.py diff --git a/hugegraph-python/src/pyhugegraph/api/schema.py b/hugegraph-python-client/src/pyhugegraph/api/schema.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/api/schema.py rename to hugegraph-python-client/src/pyhugegraph/api/schema.py diff --git a/hugegraph-python/src/pyhugegraph/api/schema_manage/__init__.py b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/__init__.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/api/schema_manage/__init__.py rename to hugegraph-python-client/src/pyhugegraph/api/schema_manage/__init__.py diff --git a/hugegraph-python/src/pyhugegraph/api/schema_manage/edge_label.py b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/api/schema_manage/edge_label.py rename to hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py diff --git a/hugegraph-python/src/pyhugegraph/api/schema_manage/index_label.py b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/index_label.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/api/schema_manage/index_label.py rename to hugegraph-python-client/src/pyhugegraph/api/schema_manage/index_label.py diff --git a/hugegraph-python/src/pyhugegraph/api/schema_manage/property_key.py b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/api/schema_manage/property_key.py rename to hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py diff --git a/hugegraph-python/src/pyhugegraph/api/schema_manage/vertex_label.py b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/vertex_label.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/api/schema_manage/vertex_label.py rename to hugegraph-python-client/src/pyhugegraph/api/schema_manage/vertex_label.py diff --git a/hugegraph-python/src/pyhugegraph/client.py b/hugegraph-python-client/src/pyhugegraph/client.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/client.py rename to hugegraph-python-client/src/pyhugegraph/client.py diff --git a/hugegraph-python/src/pyhugegraph/structure/__init__.py b/hugegraph-python-client/src/pyhugegraph/structure/__init__.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/structure/__init__.py rename to hugegraph-python-client/src/pyhugegraph/structure/__init__.py diff --git a/hugegraph-python/src/pyhugegraph/structure/edge_data.py b/hugegraph-python-client/src/pyhugegraph/structure/edge_data.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/structure/edge_data.py rename to hugegraph-python-client/src/pyhugegraph/structure/edge_data.py diff --git a/hugegraph-python/src/pyhugegraph/structure/edge_label_data.py b/hugegraph-python-client/src/pyhugegraph/structure/edge_label_data.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/structure/edge_label_data.py rename to hugegraph-python-client/src/pyhugegraph/structure/edge_label_data.py diff --git a/hugegraph-python/src/pyhugegraph/structure/graph_instance.py b/hugegraph-python-client/src/pyhugegraph/structure/graph_instance.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/structure/graph_instance.py rename to hugegraph-python-client/src/pyhugegraph/structure/graph_instance.py diff --git a/hugegraph-python/src/pyhugegraph/structure/index_label_data.py b/hugegraph-python-client/src/pyhugegraph/structure/index_label_data.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/structure/index_label_data.py rename to hugegraph-python-client/src/pyhugegraph/structure/index_label_data.py diff --git a/hugegraph-python/src/pyhugegraph/structure/property_key_data.py b/hugegraph-python-client/src/pyhugegraph/structure/property_key_data.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/structure/property_key_data.py rename to hugegraph-python-client/src/pyhugegraph/structure/property_key_data.py diff --git a/hugegraph-python/src/pyhugegraph/structure/respon_data.py b/hugegraph-python-client/src/pyhugegraph/structure/respon_data.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/structure/respon_data.py rename to hugegraph-python-client/src/pyhugegraph/structure/respon_data.py diff --git a/hugegraph-python/src/pyhugegraph/structure/vertex_data.py b/hugegraph-python-client/src/pyhugegraph/structure/vertex_data.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/structure/vertex_data.py rename to hugegraph-python-client/src/pyhugegraph/structure/vertex_data.py diff --git a/hugegraph-python/src/pyhugegraph/structure/vertex_label_data.py b/hugegraph-python-client/src/pyhugegraph/structure/vertex_label_data.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/structure/vertex_label_data.py rename to hugegraph-python-client/src/pyhugegraph/structure/vertex_label_data.py diff --git a/hugegraph-python/src/pyhugegraph/utils/__init__.py b/hugegraph-python-client/src/pyhugegraph/utils/__init__.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/utils/__init__.py rename to hugegraph-python-client/src/pyhugegraph/utils/__init__.py diff --git a/hugegraph-python/src/pyhugegraph/utils/constants.py b/hugegraph-python-client/src/pyhugegraph/utils/constants.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/utils/constants.py rename to hugegraph-python-client/src/pyhugegraph/utils/constants.py diff --git a/hugegraph-python/src/pyhugegraph/utils/exceptions.py b/hugegraph-python-client/src/pyhugegraph/utils/exceptions.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/utils/exceptions.py rename to hugegraph-python-client/src/pyhugegraph/utils/exceptions.py diff --git a/hugegraph-python/src/pyhugegraph/utils/huge_decorator.py b/hugegraph-python-client/src/pyhugegraph/utils/huge_decorator.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/utils/huge_decorator.py rename to hugegraph-python-client/src/pyhugegraph/utils/huge_decorator.py diff --git a/hugegraph-python/src/pyhugegraph/utils/huge_requests.py b/hugegraph-python-client/src/pyhugegraph/utils/huge_requests.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/utils/huge_requests.py rename to hugegraph-python-client/src/pyhugegraph/utils/huge_requests.py diff --git a/hugegraph-python/src/pyhugegraph/utils/util.py b/hugegraph-python-client/src/pyhugegraph/utils/util.py similarity index 100% rename from hugegraph-python/src/pyhugegraph/utils/util.py rename to hugegraph-python-client/src/pyhugegraph/utils/util.py From 21924c374a45e37707a5d0a0b30c051011314329 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 23 Oct 2023 16:25:38 +0800 Subject: [PATCH 3/5] introduce pylint --- .github/workflows/pylint.yml | 7 +- hugegraph-llm/examples/build_kg_test.py | 42 +- hugegraph-llm/requirements.txt | 3 + hugegraph-llm/src/hugegraph_llm/llms/base.py | 2 + .../src/hugegraph_llm/llms/openai_llm.py | 10 +- .../operators/build_kg_operator.py | 14 +- .../hugegraph_op/commit_data_to_kg.py | 30 +- .../operators/llm_op/disambiguate_data.py | 20 +- .../operators/llm_op/parse_text_to_data.py | 23 +- .../llm_op/unstructured_data_utils.py | 31 +- .../example/client_test.py | 23 - .../example/hugegraph_test.py | 5 +- hugegraph-python-client/example/test.py | 8 +- .../src/pyhugegraph/api/common.py | 10 +- .../src/pyhugegraph/api/graph.py | 243 ++++--- .../src/pyhugegraph/api/graphs.py | 17 +- .../src/pyhugegraph/api/gremlin.py | 7 +- .../src/pyhugegraph/api/schema.py | 31 +- .../api/schema_manage/edge_label.py | 79 ++- .../api/schema_manage/index_label.py | 24 +- .../api/schema_manage/property_key.py | 74 +- .../api/schema_manage/vertex_label.py | 72 +- .../src/pyhugegraph/structure/edge_data.py | 2 +- .../pyhugegraph/structure/edge_label_data.py | 7 +- .../pyhugegraph/structure/graph_instance.py | 5 +- .../pyhugegraph/structure/index_label_data.py | 7 +- .../structure/property_key_data.py | 4 +- .../src/pyhugegraph/structure/respon_data.py | 2 +- .../src/pyhugegraph/structure/vertex_data.py | 2 +- .../structure/vertex_label_data.py | 6 +- .../src/pyhugegraph/utils/exceptions.py | 18 +- .../src/pyhugegraph/utils/huge_decorator.py | 10 +- .../src/pyhugegraph/utils/huge_requests.py | 4 +- .../src/pyhugegraph/utils/util.py | 17 +- pylint.conf | 647 ++++++++++++++++++ 35 files changed, 1133 insertions(+), 373 deletions(-) create mode 100644 hugegraph-llm/requirements.txt delete mode 100644 hugegraph-python-client/example/client_test.py create mode 100644 pylint.conf diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 756665940..f3caddf28 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -22,6 +22,11 @@ jobs: run: | python -m pip install --upgrade pip pip install pylint + pip install -r ./hugegraph-llm/requirements.txt + pip install -r ./hugegraph-python-client/requirements.txt + export PYTHONPATH=$(pwd)/hugegraph-llm/src:$(pwd)/hugegraph-python-client/src + echo ${PYTHONPATH} - name: Analysing the code with pylint run: | - pylint $(git ls-files '*.py') + pylint --rcfile=./pylint.conf hugegraph-llm + pylint --rcfile=./pylint.conf hugegraph-python-client diff --git a/hugegraph-llm/examples/build_kg_test.py b/hugegraph-llm/examples/build_kg_test.py index e1bdfb30b..ece0048ef 100644 --- a/hugegraph-llm/examples/build_kg_test.py +++ b/hugegraph-llm/examples/build_kg_test.py @@ -14,6 +14,8 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + + import os from hugegraph_llm.operators.build_kg_operator import KgBuilder from hugegraph_llm.llms.openai_llm import OpenAIChat @@ -22,28 +24,35 @@ # If you need a proxy to access OpenAI's API, please set your HTTP proxy here os.environ["http_proxy"] = "" os.environ["https_proxy"] = "" - api_key = "" + API_KEY = "" default_llm = OpenAIChat( - api_key=api_key, model_name="gpt-3.5-turbo-16k", max_tokens=4000 + api_key=API_KEY, + model_name="gpt-3.5-turbo-16k", + max_tokens=4000, ) - text = ( - "Meet Sarah, a 30-year-old attorney, and her roommate, James, whom she's shared a home with since 2010. James, " - "in his professional life, works as a journalist. Additionally, Sarah is the proud owner of the website " - "www.sarahsplace.com, while James manages his own webpage, though the specific URL is not mentioned here. " - "These two individuals, Sarah and James, have not only forged a strong personal bond as roommates but have " - "also carved out their distinctive digital presence through their respective webpages, showcasing their " - "varied interests and experiences." + TEXT = ( + "Meet Sarah, a 30-year-old attorney, and her roommate, James, whom she's shared a home with" + " since 2010. James, in his professional life, works as a journalist. Additionally, Sarah" + " is the proud owner of the website www.sarahsplace.com, while James manages his own" + " webpage, though the specific URL is not mentioned here. These two individuals, Sarah and" + " James, have not only forged a strong personal bond as roommates but have also carved out" + " their distinctive digital presence through their respective webpages, showcasing their" + " varied interests and experiences." ) builder = KgBuilder(default_llm) # build kg with only text - builder.parse_text_to_data(text).disambiguate_data().commit_data_to_kg().run() + builder.parse_text_to_data(TEXT).disambiguate_data().commit_data_to_kg().run() # build kg with text and schemas nodes_schemas = [ { "label": "Person", "primary_key": "name", - "properties": {"age": "int", "name": "text", "occupation": "text"}, + "properties": { + "age": "int", + "name": "text", + "occupation": "text", + }, }, { "label": "Webpage", @@ -58,12 +67,15 @@ "type": "roommate", "properties": {"start": "int"}, }, - {"start": "Person", "end": "Webpage", "type": "owns", "properties": {}}, + { + "start": "Person", + "end": "Webpage", + "type": "owns", + "properties": {}, + }, ] ( - builder.parse_text_to_data_with_schemas( - text, nodes_schemas, relationships_schemas - ) + builder.parse_text_to_data_with_schemas(TEXT, nodes_schemas, relationships_schemas) .disambiguate_data_with_schemas() .commit_data_to_kg() .run() diff --git a/hugegraph-llm/requirements.txt b/hugegraph-llm/requirements.txt new file mode 100644 index 000000000..5341b0bd6 --- /dev/null +++ b/hugegraph-llm/requirements.txt @@ -0,0 +1,3 @@ +openai==0.28.1 +retry==0.9.2 +tiktoken==0.5.1 diff --git a/hugegraph-llm/src/hugegraph_llm/llms/base.py b/hugegraph-llm/src/hugegraph_llm/llms/base.py index 1ff2923f6..a9a1bdb85 100644 --- a/hugegraph-llm/src/hugegraph_llm/llms/base.py +++ b/hugegraph-llm/src/hugegraph_llm/llms/base.py @@ -14,6 +14,8 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + + from abc import ABC, abstractmethod from typing import Any, List, Optional, Callable diff --git a/hugegraph-llm/src/hugegraph_llm/llms/openai_llm.py b/hugegraph-llm/src/hugegraph_llm/llms/openai_llm.py index ded7f3487..7766abf63 100644 --- a/hugegraph-llm/src/hugegraph_llm/llms/openai_llm.py +++ b/hugegraph-llm/src/hugegraph_llm/llms/openai_llm.py @@ -14,6 +14,8 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + + from typing import Callable, List, Optional import openai import tiktoken @@ -56,10 +58,10 @@ def generate( return str(f"Error: {e}") # catch authorization errors / do not retry except openai.error.AuthenticationError as e: - return "Error: The provided OpenAI API key is invalid" + return f"Error: The provided OpenAI API key is invalid, {e}" except Exception as e: print(f"Retrying LLM call {e}") - raise Exception() + raise Exception() from e async def generate_streaming( self, @@ -86,11 +88,11 @@ async def generate_streaming( await on_token_callback(message) return result - def num_tokens_from_string(self, string: str) -> int: + async def num_tokens_from_string(self, string: str) -> int: encoding = tiktoken.encoding_for_model(self.model) num_tokens = len(encoding.encode(string)) return num_tokens - def max_allowed_token_length(self) -> int: + async def max_allowed_token_length(self) -> int: # TODO: list all models and their max tokens from api return 2049 diff --git a/hugegraph-llm/src/hugegraph_llm/operators/build_kg_operator.py b/hugegraph-llm/src/hugegraph_llm/operators/build_kg_operator.py index ee0d15452..deb7a2bdb 100644 --- a/hugegraph-llm/src/hugegraph_llm/operators/build_kg_operator.py +++ b/hugegraph-llm/src/hugegraph_llm/operators/build_kg_operator.py @@ -14,6 +14,8 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + + from hugegraph_llm.operators.hugegraph_op.commit_data_to_kg import CommitDataToKg from hugegraph_llm.operators.llm_op.disambiguate_data import DisambiguateData from hugegraph_llm.operators.llm_op.parse_text_to_data import ( @@ -33,9 +35,7 @@ def parse_text_to_data(self, text: str): self.parse_text_to_kg.append(ParseTextToData(llm=self.llm, text=text)) return self - def parse_text_to_data_with_schemas( - self, text: str, nodes_schemas, relationships_schemas - ): + def parse_text_to_data_with_schemas(self, text: str, nodes_schemas, relationships_schemas): self.parse_text_to_kg.append( ParseTextToDataWithSchemas( llm=self.llm, @@ -47,15 +47,11 @@ def parse_text_to_data_with_schemas( return self def disambiguate_data(self): - self.parse_text_to_kg.append( - DisambiguateData(llm=self.llm, is_user_schema=False) - ) + self.parse_text_to_kg.append(DisambiguateData(llm=self.llm, is_user_schema=False)) return self def disambiguate_data_with_schemas(self): - self.parse_text_to_kg.append( - DisambiguateData(llm=self.llm, is_user_schema=True) - ) + self.parse_text_to_kg.append(DisambiguateData(llm=self.llm, is_user_schema=True)) return self def commit_data_to_kg(self): diff --git a/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/commit_data_to_kg.py b/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/commit_data_to_kg.py index 7d1c92977..6d6764b04 100644 --- a/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/commit_data_to_kg.py +++ b/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/commit_data_to_kg.py @@ -14,22 +14,23 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + + import os from pyhugegraph.client import PyHugeClient def generate_new_relationships(nodes_schemas_data, relationships_data): - label_id = dict() + label_id = {} i = 1 old_label = [] for item in nodes_schemas_data: label = item["label"] if label in old_label: continue - else: - label_id[label] = i - i += 1 - old_label.append(label) + label_id[label] = i + i += 1 + old_label.append(label) new_relationships_data = [] for relationship in relationships_data: start = relationship["start"] @@ -45,7 +46,7 @@ def generate_new_relationships(nodes_schemas_data, relationships_data): for key1, value1 in end.items(): if key1 == key: new_end = f"{value}" + ":" + f"{value1}" - relationships_data = dict() + relationships_data = {} relationships_data["start"] = new_start relationships_data["end"] = new_end relationships_data["type"] = relationships_type @@ -91,7 +92,7 @@ def generate_schema_nodes(data): properties = item["properties"] schema_statement = f"schema.vertexLabel('{label}').properties(" schema_statement += ", ".join(f"'{prop}'" for prop in properties.keys()) - schema_statement += f").nullableKeys(" + schema_statement += ").nullableKeys(" schema_statement += ", ".join( f"'{prop}'" for prop in properties.keys() if prop != primary_key ) @@ -109,11 +110,14 @@ def generate_schema_relationships(data): end = item["end"] schema_relationships_type = item["type"] properties = item["properties"] - schema_statement = f"schema.edgeLabel('{schema_relationships_type}').sourceLabel('{start}').targetLabel('{end}').properties(" + schema_statement = ( + f"schema.edgeLabel('{schema_relationships_type}')" + f".sourceLabel('{start}').targetLabel('{end}').properties(" + ) schema_statement += ", ".join(f"'{prop}'" for prop in properties.keys()) - schema_statement += f").nullableKeys(" + schema_statement += ").nullableKeys(" schema_statement += ", ".join(f"'{prop}'" for prop in properties.keys()) - schema_statement += f").ifNotExist().create()" + schema_statement += ").ifNotExist().create()" schema_relationships_statements.append(schema_statement) return schema_relationships_statements @@ -153,12 +157,9 @@ def run(self, data: dict): relationships = data["relationships"] nodes_schemas = data["nodes_schemas"] relationships_schemas = data["relationships_schemas"] - schema = self.schema # properties schema schema_nodes_properties = generate_schema_properties(nodes_schemas) - schema_relationships_properties = generate_schema_properties( - relationships_schemas - ) + schema_relationships_properties = generate_schema_properties(relationships_schemas) for schema_nodes_property in schema_nodes_properties: exec(schema_nodes_property) @@ -175,7 +176,6 @@ def run(self, data: dict): for schema_relationship in schema_relationships: exec(schema_relationship) - g = self.client.graph() # nodes nodes = generate_nodes(nodes) for node in nodes: diff --git a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/disambiguate_data.py b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/disambiguate_data.py index e982d99fc..f540673a8 100644 --- a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/disambiguate_data.py +++ b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/disambiguate_data.py @@ -14,6 +14,8 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + + import json import re from itertools import groupby @@ -102,7 +104,7 @@ def generate_prompt(data) -> str: """ -internalRegex = r"\[(.*?)\]" +INTERNAL_REGEX = r"\[(.*?)\]" class DisambiguateData: @@ -144,7 +146,7 @@ def run(self, data: dict) -> dict[str, list[any]]: {"role": "user", "content": generate_prompt(dis_string)}, ] raw_nodes = self.llm.generate(messages) - n = re.findall(internalRegex, raw_nodes) + n = re.findall(INTERNAL_REGEX, raw_nodes) new_nodes.extend(nodes_text_to_list_of_dict(n)) relationship_data = "" @@ -172,7 +174,7 @@ def run(self, data: dict) -> dict[str, list[any]]: {"role": "user", "content": generate_prompt(relationship_data)}, ] raw_relationships = self.llm.generate(messages) - rels = re.findall(internalRegex, raw_relationships) + rels = re.findall(INTERNAL_REGEX, raw_relationships) new_relationships.extend(relationships_text_to_list_of_dict(rels)) if not self.is_user_schema: @@ -193,7 +195,7 @@ def run(self, data: dict) -> dict[str, list[any]]: {"role": "user", "content": generate_prompt(nodes_schemas_data)}, ] raw_nodes_schemas = self.llm.generate(messages) - n = re.findall(internalRegex, raw_nodes_schemas) + n = re.findall(INTERNAL_REGEX, raw_nodes_schemas) new_nodes_schemas.extend(nodes_schemas_text_to_list_of_dict(n)) relationships_schemas_data = "" @@ -210,12 +212,8 @@ def run(self, data: dict) -> dict[str, list[any]]: + "]\n" ) - node_schemas_labels = [ - nodes_schemas["label"] for nodes_schemas in new_nodes_schemas - ] - relationships_schemas_data += "Valid Labels:\n" + "\n".join( - node_schemas_labels - ) + node_schemas_labels = [nodes_schemas["label"] for nodes_schemas in new_nodes_schemas] + relationships_schemas_data += "Valid Labels:\n" + "\n".join(node_schemas_labels) messages = [ { @@ -228,7 +226,7 @@ def run(self, data: dict) -> dict[str, list[any]]: }, ] raw_relationships_schemas = self.llm.generate(messages) - schemas_rels = re.findall(internalRegex, raw_relationships_schemas) + schemas_rels = re.findall(INTERNAL_REGEX, raw_relationships_schemas) new_relationships_schemas.extend( relationships_schemas_text_to_list_of_dict(schemas_rels) ) diff --git a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/parse_text_to_data.py b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/parse_text_to_data.py index 1b67f76ed..42d36ac29 100644 --- a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/parse_text_to_data.py +++ b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/parse_text_to_data.py @@ -14,6 +14,8 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + + import re from typing import List @@ -89,8 +91,7 @@ def split_string_to_fit_token_space( current_chunk = "" for chunk in chunked_data: if ( - llm.num_tokens_from_string(current_chunk) - + llm.num_tokens_from_string(chunk) + llm.num_tokens_from_string(current_chunk) + llm.num_tokens_from_string(chunk) < allowed_tokens ): current_chunk += chunk @@ -123,10 +124,8 @@ def get_nodes_and_relationships_from_result(result): nodes.extend(re.findall(internal_regex, raw_nodes)) relationships.extend(re.findall(internal_regex, raw_relationships)) nodes_schemas.extend(re.findall(internal_regex, raw_nodes_schemas)) - relationships_schemas.extend( - re.findall(internal_regex, raw_relationships_schemas) - ) - result = dict() + relationships_schemas.extend(re.findall(internal_regex, raw_relationships_schemas)) + result = {} result["nodes"] = [] result["relationships"] = [] result["nodes_schemas"] = [] @@ -159,9 +158,7 @@ def process(self, chunk): def run(self, data: dict) -> dict[str, list[any]]: system_message = generate_system_message() prompt_string = generate_prompt("") - token_usage_per_prompt = self.llm.num_tokens_from_string( - system_message + prompt_string - ) + token_usage_per_prompt = self.llm.num_tokens_from_string(system_message + prompt_string) chunked_data = split_string_to_fit_token_space( llm=self.llm, string=self.text, token_use_per_string=token_usage_per_prompt ) @@ -178,9 +175,7 @@ def run(self, data: dict) -> dict[str, list[any]]: class ParseTextToDataWithSchemas: llm: BaseLLM - def __init__( - self, llm: BaseLLM, text: str, nodes_schema, relationships_schemas - ) -> None: + def __init__(self, llm: BaseLLM, text: str, nodes_schema, relationships_schemas) -> None: self.llm = llm self.text = text self.data = {} @@ -204,9 +199,7 @@ def process_with_schemas(self, chunk): def run(self) -> dict[str, list[any]]: system_message = generate_system_message_with_schemas() prompt_string = generate_prompt_with_schemas("", "", "") - token_usage_per_prompt = self.llm.num_tokens_from_string( - system_message + prompt_string - ) + token_usage_per_prompt = self.llm.num_tokens_from_string(system_message + prompt_string) chunked_data = split_string_to_fit_token_space( llm=self.llm, string=self.text, token_use_per_string=token_usage_per_prompt ) diff --git a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/unstructured_data_utils.py b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/unstructured_data_utils.py index 9451b6533..f02b9cfc4 100644 --- a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/unstructured_data_utils.py +++ b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/unstructured_data_utils.py @@ -14,13 +14,20 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + + import json import re -regex = r"Nodes:\s+(.*?)\s?\s?Relationships:\s?\s?NodesSchemas:\s+(.*?)\s?\s?RelationshipsSchemas:\s?\s?(.*)" -internalRegex = r"\[(.*?)\]" -jsonRegex = r"\{.*\}" -jsonRegex_relationships = r"\{.*?\}" +REGEX = ( + r"Nodes:\s+(.*?)\s?\s?" + r"Relationships:\s?\s?" + r"NodesSchemas:\s+(.*?)\s?\s?" + r"RelationshipsSchemas:\s?\s?(.*)" +) +INTERNAL_REGEX = r"\[(.*?)\]" +JSON_REGEX = r"\{.*\}" +JSON_REGEX_RELATIONSHIPS = r"\{.*?\}" def nodes_text_to_list_of_dict(nodes): @@ -32,7 +39,7 @@ def nodes_text_to_list_of_dict(nodes): name = node_list[0].strip().replace('"', "") label = node_list[1].strip().replace('"', "") - properties = re.search(jsonRegex, node) + properties = re.search(JSON_REGEX, node) if properties is None: properties = "{}" else: @@ -56,7 +63,7 @@ def relationships_text_to_list_of_dict(relationships): end = {} properties = {} relationship_type = relationship_list[1].strip().replace('"', "") - matches = re.findall(jsonRegex_relationships, relationship) + matches = re.findall(JSON_REGEX_RELATIONSHIPS, relationship) i = 1 for match in matches: if i == 1: @@ -89,7 +96,7 @@ def nodes_schemas_text_to_list_of_dict(nodes_schemas): label = nodes_schema_list[0].strip().replace('"', "") primary_key = nodes_schema_list[1].strip().replace('"', "") - properties = re.search(jsonRegex, nodes_schema) + properties = re.search(JSON_REGEX, nodes_schema) if properties is None: properties = "{}" else: @@ -99,9 +106,7 @@ def nodes_schemas_text_to_list_of_dict(nodes_schemas): properties = json.loads(properties) except json.decoder.JSONDecodeError: properties = {} - result.append( - {"label": label, "primary_key": primary_key, "properties": properties} - ) + result.append({"label": label, "primary_key": primary_key, "properties": properties}) return result @@ -113,11 +118,9 @@ def relationships_schemas_text_to_list_of_dict(relationships_schemas): continue start = relationships_schema_list[0].strip().replace('"', "") end = relationships_schema_list[2].strip().replace('"', "") - relationships_schema_type = ( - relationships_schema_list[1].strip().replace('"', "") - ) + relationships_schema_type = relationships_schema_list[1].strip().replace('"', "") - properties = re.search(jsonRegex, relationships_schema) + properties = re.search(JSON_REGEX, relationships_schema) if properties is None: properties = "{}" else: diff --git a/hugegraph-python-client/example/client_test.py b/hugegraph-python-client/example/client_test.py deleted file mode 100644 index 323780bab..000000000 --- a/hugegraph-python-client/example/client_test.py +++ /dev/null @@ -1,23 +0,0 @@ -import unittest -from typing import Any -from unittest.mock import MagicMock, patch - -from example.hugegraph_test 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, mock_graph: Any) -> None: - mock_graph.return_value = MagicMock() - client = HugeGraph(self.username, self.password, self.address, self.port, self.graph) - - result = client.exec("g.V().limit(10)") - self.assertIsInstance(result, MagicMock) diff --git a/hugegraph-python-client/example/hugegraph_test.py b/hugegraph-python-client/example/hugegraph_test.py index 23b8de619..8b47f5121 100644 --- a/hugegraph-python-client/example/hugegraph_test.py +++ b/hugegraph-python-client/example/hugegraph_test.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. + class HugeGraph: """HugeGraph wrapper for graph operations""" @@ -24,7 +25,7 @@ def __init__( password: str = "default", address: str = "127.0.0.1", port: int = 8081, - graph: str = "hugegraph" + graph: str = "hugegraph", ) -> None: """Create a new HugeGraph wrapper instance.""" try: @@ -33,7 +34,7 @@ def __init__( raise ValueError( "Please install HugeGraph Python client first: " "`pip3 install hugegraph-python-client`" - ) + ) from ImportError self.username = username self.password = password diff --git a/hugegraph-python-client/example/test.py b/hugegraph-python-client/example/test.py index adf3c2e5a..516244408 100644 --- a/hugegraph-python-client/example/test.py +++ b/hugegraph-python-client/example/test.py @@ -17,7 +17,7 @@ from pyhugegraph.client import PyHugeClient -if __name__ == '__main__': +if __name__ == "__main__": client = PyHugeClient("127.0.0.1", "8080", user="admin", pwd="admin", graph="test") """schema""" @@ -25,9 +25,11 @@ schema.propertyKey("name").asText().ifNotExist().create() schema.propertyKey("birthDate").asText().ifNotExist().create() schema.vertexLabel("Person").properties("name", "birthDate").usePrimaryKeyId().primaryKeys( - "name").ifNotExist().create() + "name" + ).ifNotExist().create() schema.vertexLabel("Movie").properties("name").usePrimaryKeyId().primaryKeys( - "name").ifNotExist().create() + "name" + ).ifNotExist().create() schema.edgeLabel("ActedIn").sourceLabel("Person").targetLabel("Movie").ifNotExist().create() print(schema.getVertexLabels()) diff --git a/hugegraph-python-client/src/pyhugegraph/api/common.py b/hugegraph-python-client/src/pyhugegraph/api/common.py index 8daefec06..a1dd7d820 100644 --- a/hugegraph-python-client/src/pyhugegraph/api/common.py +++ b/hugegraph-python-client/src/pyhugegraph/api/common.py @@ -27,8 +27,7 @@ def set(self, key, value): def get_value(self, key): if key not in self._dic: return None - else: - return self._dic[key] + return self._dic[key] def get_dic(self): return self._dic @@ -44,18 +43,15 @@ def __init__(self, graph_instance): self._port = graph_instance.port self._user = graph_instance.user_name self._pwd = graph_instance.passwd - self._host = "http://{}:{}".format(graph_instance.ip, graph_instance.port) + self._host = f"http://{graph_instance.ip}:{graph_instance.port}" self._auth = (graph_instance.user_name, graph_instance.passwd) self._graph_name = graph_instance.graph_name self._parameter_holder = None - self._headers = { - 'Content-Type': Constants.HEADER_CONTENT_TYPE - } + self._headers = {"Content-Type": Constants.HEADER_CONTENT_TYPE} self._timeout = graph_instance.timeout def add_parameter(self, key, value): self._parameter_holder.set(key, value) - return def get_parameter_holder(self): return self._parameter_holder diff --git a/hugegraph-python-client/src/pyhugegraph/api/graph.py b/hugegraph-python-client/src/pyhugegraph/api/graph.py index 0d0c278c4..393f0e434 100644 --- a/hugegraph-python-client/src/pyhugegraph/api/graph.py +++ b/hugegraph-python-client/src/pyhugegraph/api/graph.py @@ -39,27 +39,37 @@ def close(self): self.session.close() def addVertex(self, label, properties, id=None): - data = dict() + data = {} if id is not None: - data['id'] = id - data['label'] = label + data["id"] = id + data["label"] = label data["properties"] = properties - url = f'{self._host}/graphs/{self._graph_name}/graph/vertices' - response = self.session.post(url, data=json.dumps(data), auth=self._auth, - headers=self._headers, timeout=self._timeout) - if check_if_success(response, CreateError("create vertex failed: {}".format(response.content))): + url = f"{self._host}/graphs/{self._graph_name}/graph/vertices" + response = self.session.post( + url, + data=json.dumps(data), + auth=self._auth, + headers=self._headers, + timeout=self._timeout, + ) + if check_if_success(response, CreateError(f"create vertex failed: {response.content}")): res = VertexData(json.loads(response.content)) return res def addVertices(self, input_data): - url = f'{self._host}/graphs/{self._graph_name}/graph/vertices/batch' + url = f"{self._host}/graphs/{self._graph_name}/graph/vertices/batch" data = [] for item in input_data: - data.append({'label': item[0], 'properties': item[1]}) - response = self.session.post(url, data=json.dumps(data), auth=self._auth, - headers=self._headers, timeout=self._timeout) - if check_if_success(response, CreateError("create vertexes failed: {}".format(response.content))): + data.append({"label": item[0], "properties": item[1]}) + response = self.session.post( + url, + data=json.dumps(data), + auth=self._auth, + headers=self._headers, + timeout=self._timeout, + ) + if check_if_success(response, CreateError(f"create vertexes failed: {response.content}")): res = [] for item in json.loads(response.content): res.append(VertexData({"id": item})) @@ -68,58 +78,70 @@ def addVertices(self, input_data): def appendVertex(self, vertex_id, properties): url = f'{self._host}/graphs/{self._graph_name}/graph/vertices/"{vertex_id}"?action=append' - data = { - "properties": properties - } - response = self.session.put(url, data=json.dumps(data), auth=self._auth, - headers=self._headers, timeout=self._timeout) - if check_if_success(response, UpdateError("append vertex failed: {}".format(response.content))): + data = {"properties": properties} + response = self.session.put( + url, + data=json.dumps(data), + auth=self._auth, + headers=self._headers, + timeout=self._timeout, + ) + if check_if_success(response, UpdateError(f"append vertex failed: {response.content}")): res = VertexData(json.loads(response.content)) return res def eliminateVertex(self, vertex_id, properties): - url = f'{self._host}/graphs/{self._graph_name}/graph/vertices/"{vertex_id}"?action=eliminate' - - data = { - "properties": properties - } - response = self.session.put(url, data=json.dumps(data), auth=self._auth, headers=self._headers, - timeout=self._timeout) - if check_if_success(response, UpdateError("eliminate vertex failed: {}".format(response.content))): + url = ( + f'{self._host}/graphs/{self._graph_name}/graph/vertices/"{vertex_id}"?action=eliminate' + ) + + data = {"properties": properties} + response = self.session.put( + url, + data=json.dumps(data), + auth=self._auth, + headers=self._headers, + timeout=self._timeout, + ) + if check_if_success(response, UpdateError(f"eliminate vertex failed: {response.content}")): res = VertexData(json.loads(response.content)) return res def getVertexById(self, vertex_id): url = f'{self._host}/graphs/{self._graph_name}/graph/vertices/"{vertex_id}"' - response = self.session.get(url, auth=self._auth, headers=self._headers, timeout=self._timeout) - if check_if_success(response, NotFoundError("Vertex not found: {}".format(response.content))): + response = self.session.get( + url, auth=self._auth, headers=self._headers, timeout=self._timeout + ) + if check_if_success(response, NotFoundError(f"Vertex not found: {response.content}")): res = VertexData(json.loads(response.content)) return res def getVertexByPage(self, label, limit, page, properties=None): - url = f'{self._host}/graphs/{self._graph_name}/graph/vertices?' + url = f"{self._host}/graphs/{self._graph_name}/graph/vertices?" para = "" para = para + "&label=" + label if properties: para = para + "&properties=" + json.dumps(properties) if page: - para += '&page={}'.format(page) + para += f"&page={page}" else: - para += '&page' + para += "&page" para = para + "&limit=" + str(limit) url = url + para[1:] - response = self.session.get(url, auth=self._auth, headers=self._headers, timeout=self._timeout) - if check_if_success(response, NotFoundError("Vertex not found: {}".format(response.content))): + response = self.session.get( + url, auth=self._auth, headers=self._headers, timeout=self._timeout + ) + if check_if_success(response, NotFoundError(f"Vertex not found: {response.content}")): res = [] for item in json.loads(response.content)["vertices"]: res.append(VertexData(item)) next_page = json.loads(response.content)["page"] return res, next_page - def getVertexByCondition(self, label="", limit=0, page='', properties=None): - url = f'{self._host}/graphs/{self._graph_name}/graph/vertices?' + def getVertexByCondition(self, label="", limit=0, page="", properties=None): + url = f"{self._host}/graphs/{self._graph_name}/graph/vertices?" para = "" if label: @@ -129,12 +151,14 @@ def getVertexByCondition(self, label="", limit=0, page='', properties=None): if limit > 0: para = para + "&limit=" + str(limit) if page: - para += '&page={}'.format(page) + para += f"&page={page}" else: - para += '&page' + para += "&page" url = url + para[1:] - response = self.session.get(url, auth=self._auth, headers=self._headers, timeout=self._timeout) - if check_if_success(response, NotFoundError("Vertex not found: {}".format(response.content))): + response = self.session.get( + url, auth=self._auth, headers=self._headers, timeout=self._timeout + ) + if check_if_success(response, NotFoundError(f"Vertex not found: {response.content}")): res = [] for item in json.loads(response.content)["vertices"]: res.append(VertexData(item)) @@ -142,79 +166,104 @@ def getVertexByCondition(self, label="", limit=0, page='', properties=None): def removeVertexById(self, vertex_id): url = f'{self._host}/graphs/{self._graph_name}/graph/vertices/"{vertex_id}"' - response = self.session.delete(url, auth=self._auth, headers=self._headers, timeout=self._timeout) - if check_if_success(response, RemoveError("remove vertex failed: {}".format(response.content))): + response = self.session.delete( + url, auth=self._auth, headers=self._headers, timeout=self._timeout + ) + if check_if_success(response, RemoveError(f"remove vertex failed: {response.content}")): return response.content def addEdge(self, edge_label, out_id, in_id, properties): - url = f'{self._host}/graphs/{self._graph_name}/graph/edges' - - data = { - "label": edge_label, - "outV": out_id, - "inV": in_id, - "properties": properties - } - response = self.session.post(url, data=json.dumps(data), auth=self._auth, - headers=self._headers, timeout=self._timeout) - if check_if_success(response, CreateError("created edge failed: {}".format(response.content))): + url = f"{self._host}/graphs/{self._graph_name}/graph/edges" + + data = {"label": edge_label, "outV": out_id, "inV": in_id, "properties": properties} + response = self.session.post( + url, + data=json.dumps(data), + auth=self._auth, + headers=self._headers, + timeout=self._timeout, + ) + if check_if_success(response, CreateError(f"created edge failed: {response.content}")): res = EdgeData(json.loads(response.content)) return res def addEdges(self, input_data): - url = f'{self._host}/graphs/{self._graph_name}/graph/edges/batch' + url = f"{self._host}/graphs/{self._graph_name}/graph/edges/batch" data = [] for item in input_data: - data.append({'label': item[0], 'outV': item[1], 'inV': item[2], 'outVLabel': item[3], - 'inVLabel': item[4], 'properties': item[5]}) - response = self.session.post(url, data=json.dumps(data), auth=self._auth, - headers=self._headers, timeout=self._timeout) - if check_if_success(response, CreateError("created edges failed: {}".format(response.content))): + data.append( + { + "label": item[0], + "outV": item[1], + "inV": item[2], + "outVLabel": item[3], + "inVLabel": item[4], + "properties": item[5], + } + ) + response = self.session.post( + url, + data=json.dumps(data), + auth=self._auth, + headers=self._headers, + timeout=self._timeout, + ) + if check_if_success(response, CreateError(f"created edges failed: {response.content}")): res = [] for item in json.loads(response.content): res.append(EdgeData({"id": item})) return res def appendEdge(self, edge_id, properties): - url = f'{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}?action=append' - - data = { - "properties": properties - } - response = self.session.put(url, data=json.dumps(data), auth=self._auth, - headers=self._headers, timeout=self._timeout) - if check_if_success(response, UpdateError("append edge failed: {}".format(response.content))): + url = f"{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}?action=append" + + data = {"properties": properties} + response = self.session.put( + url, + data=json.dumps(data), + auth=self._auth, + headers=self._headers, + timeout=self._timeout, + ) + if check_if_success(response, UpdateError(f"append edge failed: {response.content}")): res = EdgeData(json.loads(response.content)) return res def eliminateEdge(self, edge_id, properties): - url = f'{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}?action=eliminate' - - data = { - "properties": properties - } - response = self.session.put(url, data=json.dumps(data), auth=self._auth, - headers=self._headers, timeout=self._timeout) - if check_if_success(response, UpdateError("eliminate edge failed: {}".format(response.content))): + url = f"{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}?action=eliminate" + + data = {"properties": properties} + response = self.session.put( + url, + data=json.dumps(data), + auth=self._auth, + headers=self._headers, + timeout=self._timeout, + ) + if check_if_success(response, UpdateError(f"eliminate edge failed: {response.content}")): res = EdgeData(json.loads(response.content)) return res def getEdgeById(self, edge_id): - url = f'{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}' + url = f"{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}" - response = self.session.get(url, auth=self._auth, headers=self._headers, timeout=self._timeout) - if check_if_success(response, NotFoundError("not found edge: {}".format(response.content))): + response = self.session.get( + url, auth=self._auth, headers=self._headers, timeout=self._timeout + ) + if check_if_success(response, NotFoundError(f"not found edge: {response.content}")): res = EdgeData(json.loads(response.content)) return res - def getEdgeByPage(self, label=None, vertex_id=None, direction=None, limit=0, page=None, properties=None): - url = f'{self._host}/graphs/{self._graph_name}/graph/edges?' + def getEdgeByPage( + self, label=None, vertex_id=None, direction=None, limit=0, page=None, properties=None + ): + url = f"{self._host}/graphs/{self._graph_name}/graph/edges?" para = "" if vertex_id: if direction: - para = para + "&vertex_id=\"" + vertex_id + "\"&direction=" + direction + para = para + '&vertex_id="' + vertex_id + '"&direction=' + direction else: raise NotFoundError("Direction can not be empty.") if label: @@ -222,34 +271,40 @@ def getEdgeByPage(self, label=None, vertex_id=None, direction=None, limit=0, pag if properties: para = para + "&properties=" + json.dumps(properties) if page: - para += '&page={}'.format(page) + para += f"&page={page}" else: - para += '&page' + para += "&page" if limit > 0: para = para + "&limit=" + str(limit) url = url + para[1:] - response = self.session.get(url, auth=self._auth, headers=self._headers, timeout=self._timeout) - if check_if_success(response, NotFoundError("not found edges: {}".format(response.content))): + response = self.session.get( + url, auth=self._auth, headers=self._headers, timeout=self._timeout + ) + if check_if_success(response, NotFoundError(f"not found edges: {response.content}")): res = [] for item in json.loads(response.content)["edges"]: res.append(EdgeData(item)) return res, json.loads(response.content)["page"] def removeEdgeById(self, edge_id): - url = f'{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}' + url = f"{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}" - response = self.session.delete(url, auth=self._auth, headers=self._headers, timeout=self._timeout) - if check_if_success(response, RemoveError("remove edge failed: {}".format(response.content))): + response = self.session.delete( + url, auth=self._auth, headers=self._headers, timeout=self._timeout + ) + if check_if_success(response, RemoveError(f"remove edge failed: {response.content}")): return response.content def getVerticesById(self, vertex_ids): if not vertex_ids: return [] - url = f'{self._host}/graphs/{self._graph_name}/traversers/vertices?' + url = f"{self._host}/graphs/{self._graph_name}/traversers/vertices?" for vertex_id in vertex_ids: - url += 'ids="{}"&'.format(vertex_id) + url += f'ids="{vertex_id}"&' url = url.rstrip("&") - response = self.session.get(url, auth=self._auth, headers=self._headers, timeout=self._timeout) + response = self.session.get( + url, auth=self._auth, headers=self._headers, timeout=self._timeout + ) if response.status_code == 200 and check_if_authorized(response): res = [] for item in json.loads(response.content)["vertices"]: @@ -261,11 +316,13 @@ def getVerticesById(self, vertex_ids): def getEdgesById(self, edge_ids): if not edge_ids: return [] - url = f'{self._host}/graphs/{self._graph_name}/traversers/edges?' + url = f"{self._host}/graphs/{self._graph_name}/traversers/edges?" for vertex_id in edge_ids: - url += 'ids={}&'.format(vertex_id) + url += f"ids={vertex_id}&" url = url.rstrip("&") - response = self.session.get(url, auth=self._auth, headers=self._headers, timeout=self._timeout) + response = self.session.get( + url, auth=self._auth, headers=self._headers, timeout=self._timeout + ) if response.status_code == 200 and check_if_authorized(response): res = [] for item in json.loads(response.content)["edges"]: diff --git a/hugegraph-python-client/src/pyhugegraph/api/graphs.py b/hugegraph-python-client/src/pyhugegraph/api/graphs.py index b44aa6d83..6b4a1339c 100644 --- a/hugegraph-python-client/src/pyhugegraph/api/graphs.py +++ b/hugegraph-python-client/src/pyhugegraph/api/graphs.py @@ -14,10 +14,7 @@ # 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 pyhugegraph.api.common import HugeParamsBase @@ -41,31 +38,37 @@ def close(self): self.session.close() def get_all_graphs(self): - url = f'{self._host}/graphs' + 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) + return "" def get_version(self): - url = f'{self._host}/versions' + 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) + return "" def get_graph_info(self): - url = f'{self._host}/graphs/{self._graph_name}' + 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) + return "" def clear_graph_all_data(self): - url = f'{self._host}/graphs/{self._graph_name}/clear?confirm_message={Constants.CONFORM_MESSAGE}' + url = f"{self._host}/graphs/{self._graph_name}/clear?confirm_message=" \ + f"{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) + return "" 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) + return "" diff --git a/hugegraph-python-client/src/pyhugegraph/api/gremlin.py b/hugegraph-python-client/src/pyhugegraph/api/gremlin.py index 562a5bd79..8126e5aec 100644 --- a/hugegraph-python-client/src/pyhugegraph/api/gremlin.py +++ b/hugegraph-python-client/src/pyhugegraph/api/gremlin.py @@ -17,8 +17,6 @@ import json import re -import requests - from pyhugegraph.api.common import HugeParamsBase from pyhugegraph.structure.respon_data import ResponseData from pyhugegraph.utils.exceptions import NotFoundError @@ -41,8 +39,9 @@ def close(self): def exec(self, gremlin): gremlin = re.sub("^g", self._graph_name + ".traversal()", gremlin) - url = f'{self._host}/gremlin?gremlin={gremlin}' + url = f"{self._host}/gremlin?gremlin={gremlin}" response = self.session.get(url, auth=self._auth, headers=self._headers) - error = NotFoundError("Gremlin can't get results: {}".format(response.content)) + error = NotFoundError(f"Gremlin can't get results: {response.content}") if check_if_success(response, error): return ResponseData(json.loads(response.content)).result + return "" diff --git a/hugegraph-python-client/src/pyhugegraph/api/schema.py b/hugegraph-python-client/src/pyhugegraph/api/schema.py index c0f6c83fc..10da5b313 100644 --- a/hugegraph-python-client/src/pyhugegraph/api/schema.py +++ b/hugegraph-python-client/src/pyhugegraph/api/schema.py @@ -80,8 +80,9 @@ def indexLabel(self, name): """ create schemas """ + def getSchema(self): - url = f'{self._host}/graphs/{self._graph_name}/schema' + url = f"{self._host}/graphs/{self._graph_name}/schema" response = self.session.get(url, auth=self._auth, headers=self._headers) error = NotFoundError(f"schema not found: {response.content}") if check_if_success(response, error): @@ -89,7 +90,7 @@ def getSchema(self): return schema def getPropertyKey(self, property_name): - url = f'{self._host}/graphs/{self._graph_name}/schema/propertykeys/{property_name}' + url = f"{self._host}/graphs/{self._graph_name}/schema/propertykeys/{property_name}" response = self.session.get(url, auth=self._auth, headers=self._headers) error = NotFoundError(f"PropertyKey not found: {response.content}") if check_if_success(response, error): @@ -97,7 +98,7 @@ def getPropertyKey(self, property_name): return property_keys_data def getPropertyKeys(self): - url = f'{self._host}/graphs/{self._graph_name}/schema/propertykeys' + url = f"{self._host}/graphs/{self._graph_name}/schema/propertykeys" response = self.session.get(url, auth=self._auth, headers=self._headers) res = [] if check_if_success(response): @@ -106,15 +107,15 @@ def getPropertyKeys(self): return res def getVertexLabel(self, name): - url = f'{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{name}' + url = f"{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{name}" response = self.session.get(url, auth=self._auth, headers=self._headers) - error = NotFoundError("VertexLabel not found: {}".format(response.content)) + error = NotFoundError(f"VertexLabel not found: {response.content}") if check_if_success(response, error): res = VertexLabelData(json.loads(response.content)) return res def getVertexLabels(self): - url = f'{self._host}/graphs/{self._graph_name}/schema/vertexlabels' + url = f"{self._host}/graphs/{self._graph_name}/schema/vertexlabels" response = self.session.get(url, auth=self._auth, headers=self._headers) res = [] if check_if_success(response): @@ -123,15 +124,15 @@ def getVertexLabels(self): return res def getEdgeLabel(self, label_name): - url = f'{self._host}/graphs/{self._graph_name}/schema/edgelabels/{label_name}' + url = f"{self._host}/graphs/{self._graph_name}/schema/edgelabels/{label_name}" response = self.session.get(url, auth=self._auth, headers=self._headers) - error = NotFoundError("EdgeLabel not found: {}".format(response.content)) + error = NotFoundError(f"EdgeLabel not found: {response.content}") if check_if_success(response, error): res = EdgeLabelData(json.loads(response.content)) return res def getEdgeLabels(self): - url = f'{self._host}/graphs/{self._graph_name}/schema/edgelabels' + url = f"{self._host}/graphs/{self._graph_name}/schema/edgelabels" response = self.session.get(url, auth=self._auth, headers=self._headers) res = [] if check_if_success(response): @@ -140,7 +141,7 @@ def getEdgeLabels(self): return res def getRelations(self): - url = f'{self._host}/graphs/{self._graph_name}/schema/edgelabels' + url = f"{self._host}/graphs/{self._graph_name}/schema/edgelabels" response = self.session.get(url, auth=self._auth, headers=self._headers) res = [] if check_if_success(response): @@ -149,18 +150,18 @@ def getRelations(self): return res def getIndexLabel(self, name): - url = f'{self._host}/graphs/{self._graph_name}/schema/indexlabels/{name}' + url = f"{self._host}/graphs/{self._graph_name}/schema/indexlabels/{name}" response = self.session.get(url, auth=self._auth, headers=self._headers) - error = NotFoundError("EdgeLabel not found: {}".format(response.content)) + error = NotFoundError(f"EdgeLabel not found: {response.content}") if check_if_success(response, error): res = IndexLabelData(json.loads(response.content)) return res def getIndexLabels(self): - url = f'{self._host}/graphs/{self._graph_name}/schema/indexlabels' + url = f"{self._host}/graphs/{self._graph_name}/schema/indexlabels" response = self.session.get(url, auth=self._auth, headers=self._headers) res = [] if check_if_success(response): - for item in json.loads(response.content)['indexlabels']: + for item in json.loads(response.content)["indexlabels"]: res.append(IndexLabelData(item)) - return res + return res diff --git a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py index 502d08464..a26d4710a 100644 --- a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py +++ b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py @@ -47,7 +47,7 @@ def targetLabel(self, target_label): @decorator_params def userdata(self, *args): if not self._parameter_holder.get_value("user_data"): - self._parameter_holder.set('user_data', dict()) + self._parameter_holder.set("user_data", {}) user_data = self._parameter_holder.get_value("user_data") i = 0 while i < len(args): @@ -93,58 +93,81 @@ def ifNotExist(self): @decorator_create def create(self): dic = self._parameter_holder.get_dic() - data = dict() - keys = ['name', 'source_label', 'target_label', 'nullable_keys', 'properties', - 'enable_label_index', 'sort_keys', 'user_data', 'frequency'] + data = {} + keys = [ + "name", + "source_label", + "target_label", + "nullable_keys", + "properties", + "enable_label_index", + "sort_keys", + "user_data", + "frequency", + ] for key in keys: if key in dic: data[key] = dic[key] - url = f'{self._host}/graphs/{self._graph_name}/schema/edgelabels' - response = self.session.post(url, data=json.dumps(data), auth=self._auth, headers=self._headers) + url = f"{self._host}/graphs/{self._graph_name}/schema/edgelabels" + response = self.session.post( + url, data=json.dumps(data), auth=self._auth, headers=self._headers + ) self.clean_parameter_holder() - error = CreateError('CreateError: "create EdgeLabel failed", Detail: "{}"' - .format(str(response.content))) + error = CreateError( + f'CreateError: "create EdgeLabel failed", Detail: "{str(response.content)}"' + ) if check_if_success(response, error): - return 'create EdgeLabel success, Detail: "{}"'.format(str(response.content)) + return f'create EdgeLabel success, Detail: "{str(response.content)}"' @decorator_params def remove(self): url = f'{self._host}/graphs/{self._graph_name}/schema/edgelabels/{self._parameter_holder.get_value("name")}' response = self.session.delete(url, auth=self._auth, headers=self._headers) self.clean_parameter_holder() - error = RemoveError('RemoveError: "remove EdgeLabel failed", Detail: "{}"' - .format(str(response.content))) + error = RemoveError( + f'RemoveError: "remove EdgeLabel failed", Detail: "{str(response.content)}"' + ) if check_if_success(response, error): - return 'remove EdgeLabel success, Detail: "{}"'.format(str(response.content)) + return f'remove EdgeLabel success, Detail: "{str(response.content)}"' @decorator_params def append(self): dic = self._parameter_holder.get_dic() - data = dict() - keys = ['name', 'nullable_keys', 'properties', 'user_data'] + data = {} + keys = ["name", "nullable_keys", "properties", "user_data"] for key in keys: if key in dic: data[key] = dic[key] - url = f'{self._host}/graphs/{self._graph_name}/schema/edgelabels/{data["name"]}?action=append' - response = self.session.put(url, data=json.dumps(data), auth=self._auth, headers=self._headers) + url = ( + f'{self._host}/graphs/{self._graph_name}/schema/edgelabels/{data["name"]}?action=append' + ) + response = self.session.put( + url, data=json.dumps(data), auth=self._auth, headers=self._headers + ) self.clean_parameter_holder() - error = UpdateError('UpdateError: "append EdgeLabel failed", Detail: "{}"'.format(str(response.content))) + error = UpdateError( + f'UpdateError: "append EdgeLabel failed", Detail: "{str(response.content)}"' + ) if check_if_success(response, error): - return 'append EdgeLabel success, Detail: "{}"'.format(str(response.content)) + return f'append EdgeLabel success, Detail: "{str(response.content)}"' @decorator_params def eliminate(self): name = self._parameter_holder.get_value("name") - user_data = self._parameter_holder.get_value("user_data") if \ - self._parameter_holder.get_value("user_data") else {} - url = f'{self._host}/graphs/{self._graph_name}/schema/edgelabels/{name}?action=eliminate' - data = { - "name": name, - "user_data": user_data - } - response = self.session.put(url, data=json.dumps(data), auth=self._auth, headers=self._headers) + user_data = ( + self._parameter_holder.get_value("user_data") + if self._parameter_holder.get_value("user_data") + else {} + ) + url = f"{self._host}/graphs/{self._graph_name}/schema/edgelabels/{name}?action=eliminate" + data = {"name": name, "user_data": user_data} + response = self.session.put( + url, data=json.dumps(data), auth=self._auth, headers=self._headers + ) self.clean_parameter_holder() - error = UpdateError('UpdateError: "eliminate EdgeLabel failed", Detail: "{}"'.format(str(response.content))) + error = UpdateError( + f'UpdateError: "eliminate EdgeLabel failed", Detail: "{str(response.content)}"' + ) if check_if_success(response, error): - return 'eliminate EdgeLabel success, Detail: "{}"'.format(str(response.content)) + return f'eliminate EdgeLabel success, Detail: "{str(response.content)}"' diff --git a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/index_label.py b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/index_label.py index e29c8c775..9ac382960 100644 --- a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/index_label.py +++ b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/index_label.py @@ -77,27 +77,31 @@ def ifNotExist(self): @decorator_create def create(self): dic = self._parameter_holder.get_dic() - data = dict() + data = {} data["name"] = dic["name"] data["base_type"] = dic["base_type"] data["base_value"] = dic["base_value"] data["index_type"] = dic["index_type"] data["fields"] = list(dic["fields"]) - url = f'{self._host}/graphs/{self._graph_name}/schema/indexlabels' - response = self.session.post(url, data=json.dumps(data), auth=self._auth, headers=self._headers) + url = f"{self._host}/graphs/{self._graph_name}/schema/indexlabels" + response = self.session.post( + url, data=json.dumps(data), auth=self._auth, headers=self._headers + ) self.clean_parameter_holder() - error = CreateError('CreateError: "create IndexLabel failed", ' - 'Detail "{}"'.format(str(response.content))) + error = CreateError( + f'CreateError: "create IndexLabel failed", Detail "{str(response.content)}"' + ) if check_if_success(response, error): - return 'create IndexLabel success, Deatil: "{}"'.format(str(response.content)) + return f'create IndexLabel success, Deatil: "{str(response.content)}"' @decorator_params def remove(self): name = self._parameter_holder.get_value("name") - url = f'{self._host}/graphs/{self._graph_name}/schema/indexlabels/{name}' + url = f"{self._host}/graphs/{self._graph_name}/schema/indexlabels/{name}" response = self.session.delete(url, auth=self._auth, headers=self._headers) self.clean_parameter_holder() - error = RemoveError('RemoveError: "remove IndexLabel failed", ' - 'Detail "{}"'.format(str(response.content))) + error = RemoveError( + f'RemoveError: "remove IndexLabel failed", Detail "{str(response.content)}"' + ) if check_if_success(response, error): - return 'remove IndexLabel success, Deatil: "{}"'.format(str(response.content)) + return f'remove IndexLabel success, Deatil: "{str(response.content)}"' diff --git a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py index 7a7f0e79e..903f527d4 100644 --- a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py +++ b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py @@ -89,7 +89,7 @@ def calcOld(self): def userdata(self, *args): user_data = self._parameter_holder.get_value("user_data") if not user_data: - self._parameter_holder.set("user_data", dict()) + self._parameter_holder.set("user_data", {}) user_data = self._parameter_holder.get_value("user_data") i = 0 while i < len(args): @@ -107,55 +107,59 @@ def ifNotExist(self): @decorator_create def create(self): dic = self._parameter_holder.get_dic() - property_keys = { - "name": dic["name"] - } + property_keys = {"name": dic["name"]} if "data_type" in dic: property_keys["data_type"] = dic["data_type"] if "cardinality" in dic: property_keys["cardinality"] = dic["cardinality"] - url = f'{self._host}/graphs/{self._graph_name}/schema/propertykeys' - response = self.session.post(url, data=json.dumps(property_keys), auth=self._auth, headers=self._headers) + url = f"{self._host}/graphs/{self._graph_name}/schema/propertykeys" + response = self.session.post( + url, data=json.dumps(property_keys), auth=self._auth, headers=self._headers + ) self.clean_parameter_holder() - if check_if_success(response, CreateError( - 'CreateError: "create PropertyKey failed", Detail: {}'.format(response.content))): - return 'create PropertyKey success, Detail: {}'.format(response.content) + if check_if_success( + response, + CreateError(f'CreateError: "create PropertyKey failed", Detail: {response.content}'), + ): + return f"create PropertyKey success, Detail: {response.content}" @decorator_params def append(self): property_name = self._parameter_holder.get_value("name") user_data = self._parameter_holder.get_value("user_data") if not user_data: - user_data = dict() - data = { - "name": property_name, - "user_data": user_data - } - - url = f'{self._host}/graphs/{self._graph_name}/schema/propertykeys/{property_name}/?action=append' - response = self.session.put(url, data=json.dumps(data), auth=self._auth, headers=self._headers) + user_data = {} + data = {"name": property_name, "user_data": user_data} + + url = f"{self._host}/graphs/{self._graph_name}/schema/propertykeys/{property_name}/?action=append" + response = self.session.put( + url, data=json.dumps(data), auth=self._auth, headers=self._headers + ) self.clean_parameter_holder() - if check_if_success(response, UpdateError( - 'UpdateError: "append PropertyKey failed", Detail: {}'.format(response.content))): - return 'append PropertyKey success, Detail: {}'.format(response.content) + if check_if_success( + response, + UpdateError(f'UpdateError: "append PropertyKey failed", Detail: {response.content}'), + ): + return f"append PropertyKey success, Detail: {response.content}" @decorator_params def eliminate(self): property_name = self._parameter_holder.get_value("name") user_data = self._parameter_holder.get_value("user_data") if not user_data: - user_data = dict() - data = { - "name": property_name, - "user_data": user_data - } - - url = f'{self._host}/graphs/{self._graph_name}/schema/propertykeys/{property_name}/?action=eliminate' - response = self.session.put(url, data=json.dumps(data), auth=self._auth, headers=self._headers) + user_data = {} + data = {"name": property_name, "user_data": user_data} + + url = f"{self._host}/graphs/{self._graph_name}/schema/propertykeys/{property_name}/?action=eliminate" + response = self.session.put( + url, data=json.dumps(data), auth=self._auth, headers=self._headers + ) self.clean_parameter_holder() - error = UpdateError(f'UpdateError: "eliminate PropertyKey failed", Detail: {str(response.content)}') + error = UpdateError( + f'UpdateError: "eliminate PropertyKey failed", Detail: {str(response.content)}' + ) if check_if_success(response, error): - return 'eliminate PropertyKey success, Detail: {}'.format(str(response.content)) + return f"eliminate PropertyKey success, Detail: {str(response.content)}" @decorator_params def remove(self): @@ -163,6 +167,10 @@ def remove(self): url = f'{self._host}/graphs/{self._graph_name}/schema/propertykeys/{dic["name"]}' response = self.session.delete(url) self.clean_parameter_holder() - if check_if_success(response, RemoveError( - 'RemoveError: "delete PropertyKey failed", Detail: {}'.format(str(response.content)))): - return 'delete PropertyKey success, Detail: {}'.format(dic["name"]) + if check_if_success( + response, + RemoveError( + f'RemoveError: "delete PropertyKey failed", Detail: {str(response.content)}' + ), + ): + return f'delete PropertyKey success, Detail: {dic["name"]}' diff --git a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/vertex_label.py b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/vertex_label.py index e031fd327..3a45cffc4 100644 --- a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/vertex_label.py +++ b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/vertex_label.py @@ -73,8 +73,8 @@ def enableLabelIndex(self, flag): @decorator_params def userdata(self, *args): if "user_data" not in self._parameter_holder.get_keys(): - self._parameter_holder.set('user_data', dict()) - user_data = self._parameter_holder.get_value('user_data') + self._parameter_holder.set("user_data", {}) + user_data = self._parameter_holder.get_value("user_data") i = 0 while i < len(args): user_data[args[i]] = args[i + 1] @@ -92,65 +92,83 @@ def ifNotExist(self): @decorator_create def create(self): dic = self._parameter_holder.get_dic() - key_list = ["name", "id_strategy", "primary_keys", "nullable_keys", "index_labels", - "properties", "enable_label_index", "user_data"] + key_list = [ + "name", + "id_strategy", + "primary_keys", + "nullable_keys", + "index_labels", + "properties", + "enable_label_index", + "user_data", + ] data = {} for key in key_list: if key in dic: data[key] = dic[key] - url = f'{self._host}/graphs/{self._graph_name}/schema/vertexlabels' - response = self.session.post(url, data=json.dumps(data), auth=self._auth, headers=self._headers) + url = f"{self._host}/graphs/{self._graph_name}/schema/vertexlabels" + response = self.session.post( + url, data=json.dumps(data), auth=self._auth, headers=self._headers + ) self.clean_parameter_holder() - error = CreateError('CreateError: "create VertexLabel failed", Detail: "{}"' - .format(str(response.content))) + error = CreateError( + f'CreateError: "create VertexLabel failed", Detail: "{str(response.content)}"' + ) if check_if_success(response, error): - return 'create VertexLabel success, Detail: "{}"'.format(str(response.content)) + return f'create VertexLabel success, Detail: "{str(response.content)}"' @decorator_params def append(self): dic = self._parameter_holder.get_dic() - properties = dic['properties'] if "properties" in dic else [] - nullable_keys = dic['nullable_keys'] if "nullable_keys" in dic else [] - user_data = dic['user_data'] if 'user_data' in dic else {} + properties = dic["properties"] if "properties" in dic else [] + nullable_keys = dic["nullable_keys"] if "nullable_keys" in dic else [] + user_data = dic["user_data"] if "user_data" in dic else {} url = f'{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{dic["name"]}?action=append' data = { "name": dic["name"], "properties": properties, "nullable_keys": nullable_keys, - "user_data": user_data + "user_data": user_data, } - response = self.session.put(url, data=json.dumps(data), auth=self._auth, headers=self._headers) + response = self.session.put( + url, data=json.dumps(data), auth=self._auth, headers=self._headers + ) self.clean_parameter_holder() - error = UpdateError('UpdateError: "append VertexLabel failed", Detail: "{}"'. - format(str(response.content))) + error = UpdateError( + f'UpdateError: "append VertexLabel failed", Detail: "{str(response.content)}"' + ) if check_if_success(response, error): - return 'append VertexLabel success, Detail: "{}"'.format(str(response.content)) + return f'append VertexLabel success, Detail: "{str(response.content)}"' @decorator_params def remove(self): name = self._parameter_holder.get_value("name") - url = f'{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{name}' + url = f"{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{name}" response = self.session.delete(url, auth=self._auth, headers=self._headers) self.clean_parameter_holder() - error = RemoveError('RemoveError: "remove VertexLabel failed", Detail: "{}"'. - format(str(response.content))) + error = RemoveError( + f'RemoveError: "remove VertexLabel failed", Detail: "{str(response.content)}"' + ) if check_if_success(response, error): - return 'remove VertexLabel success, Detail: "{}"'.format(str(response.content)) + return f'remove VertexLabel success, Detail: "{str(response.content)}"' @decorator_params def eliminate(self): name = self._parameter_holder.get_value("name") - url = f'{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{name}/?action=eliminate' + url = f"{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{name}/?action=eliminate" dic = self._parameter_holder.get_dic() - user_data = dic['user_data'] if 'user_data' in dic else {} + user_data = dic["user_data"] if "user_data" in dic else {} data = { "name": self._parameter_holder.get_value("name"), "user_data": user_data, } - response = self.session.put(url, data=json.dumps(data), auth=self._auth, headers=self._headers) - error = UpdateError('UpdateError: "eliminate VertexLabel failed", Detail: "{}"'. - format(str(response.content))) + response = self.session.put( + url, data=json.dumps(data), auth=self._auth, headers=self._headers + ) + error = UpdateError( + f'UpdateError: "eliminate VertexLabel failed", Detail: "{str(response.content)}"' + ) if check_if_success(response, error): - return 'eliminate VertexLabel success, Detail: "{}"'.format(str(response.content)) + return f'eliminate VertexLabel success, Detail: "{str(response.content)}"' diff --git a/hugegraph-python-client/src/pyhugegraph/structure/edge_data.py b/hugegraph-python-client/src/pyhugegraph/structure/edge_data.py index 1269e0a07..e0732c956 100644 --- a/hugegraph-python-client/src/pyhugegraph/structure/edge_data.py +++ b/hugegraph-python-client/src/pyhugegraph/structure/edge_data.py @@ -60,5 +60,5 @@ def properties(self): return self.__properties def __repr__(self): - res = "{}--{}-->{}".format(self.__outV, self.__label, self.__inV) + res = f"{self.__outV}--{self.__label}-->{self.__inV}" return res diff --git a/hugegraph-python-client/src/pyhugegraph/structure/edge_label_data.py b/hugegraph-python-client/src/pyhugegraph/structure/edge_label_data.py index 57cfc582d..48eb9e40a 100644 --- a/hugegraph-python-client/src/pyhugegraph/structure/edge_label_data.py +++ b/hugegraph-python-client/src/pyhugegraph/structure/edge_label_data.py @@ -67,12 +67,9 @@ def userdata(self): return self.__user_data def relations(self): - res = "{}--{}-->{}".format( - self.__source_label, self.__name, self.__target_label) + res = f"{self.__source_label}--{self.__name}-->{self.__target_label}" return res def __repr__(self): - res = "name: {}, properties: {}".format( - self.__name - , self.__properties) + res = f"name: {self.__name}, properties: {self.__properties}" return res diff --git a/hugegraph-python-client/src/pyhugegraph/structure/graph_instance.py b/hugegraph-python-client/src/pyhugegraph/structure/graph_instance.py index 34bed439d..5defa08a2 100644 --- a/hugegraph-python-client/src/pyhugegraph/structure/graph_instance.py +++ b/hugegraph-python-client/src/pyhugegraph/structure/graph_instance.py @@ -50,5 +50,8 @@ def timeout(self): return self.__timeout def __repr__(self): - res = f"ip:{self.ip}, port:{self.port}, graph_name:{self.graph_name}, user_name:{self.user_name}, passwd:{self.passwd}, timeout:{self.timeout}" + res = ( + f"ip:{self.ip}, port:{self.port}, graph_name:{self.graph_name}," + f" user_name:{self.user_name}, passwd:{self.passwd}, timeout:{self.timeout}" + ) return res diff --git a/hugegraph-python-client/src/pyhugegraph/structure/index_label_data.py b/hugegraph-python-client/src/pyhugegraph/structure/index_label_data.py index 4f602330a..65aedfc5e 100644 --- a/hugegraph-python-client/src/pyhugegraph/structure/index_label_data.py +++ b/hugegraph-python-client/src/pyhugegraph/structure/index_label_data.py @@ -50,7 +50,8 @@ def indexType(self): return self.__index_type def __repr__(self): - res = "index_name: {}, base_value: {}, base_type: {}, fields: [], index_type: {}"\ - .format(self.__name, self.__base_value, self.__base_type, self.__fields, - self.__index_type) + res = ( + f"index_name: {self.__name}, base_value: {self.__base_value}, base_type:" + f" {self.__base_type}, fields: {self.__fields}, index_type: {self.__index_type}" + ) return res diff --git a/hugegraph-python-client/src/pyhugegraph/structure/property_key_data.py b/hugegraph-python-client/src/pyhugegraph/structure/property_key_data.py index 665d6325b..9b7b50c3f 100644 --- a/hugegraph-python-client/src/pyhugegraph/structure/property_key_data.py +++ b/hugegraph-python-client/src/pyhugegraph/structure/property_key_data.py @@ -45,7 +45,7 @@ def userdata(self): return self.__user_data def __repr__(self): - res = "name: {}, cardinality: {}, data_type: {}".format( - self.__name, self.__cardinality, self.__data_type + res = ( + f"name: {self.__name}, cardinality: {self.__cardinality}, data_type: {self.__data_type}" ) return res diff --git a/hugegraph-python-client/src/pyhugegraph/structure/respon_data.py b/hugegraph-python-client/src/pyhugegraph/structure/respon_data.py index cbbbc8180..0f4f1b146 100644 --- a/hugegraph-python-client/src/pyhugegraph/structure/respon_data.py +++ b/hugegraph-python-client/src/pyhugegraph/structure/respon_data.py @@ -35,5 +35,5 @@ def result(self): return self.__result def __repr__(self): - res = "id: {}, status: {}, result: {}".format(self.__id, self.__status, self.__result) + res = f"id: {self.__id}, status: {self.__status}, result: {self.__result}" return res diff --git a/hugegraph-python-client/src/pyhugegraph/structure/vertex_data.py b/hugegraph-python-client/src/pyhugegraph/structure/vertex_data.py index eb358bc98..bccee3762 100644 --- a/hugegraph-python-client/src/pyhugegraph/structure/vertex_data.py +++ b/hugegraph-python-client/src/pyhugegraph/structure/vertex_data.py @@ -40,5 +40,5 @@ def properties(self): return self.__properties def __repr__(self): - res = "id: {}, label: {}, type: {}".format(self.__id, self.__label, self.__type) + res = f"id: {self.__id}, label: {self.__label}, type: {self.__type}" return res diff --git a/hugegraph-python-client/src/pyhugegraph/structure/vertex_label_data.py b/hugegraph-python-client/src/pyhugegraph/structure/vertex_label_data.py index fe2a8b560..2a8e443d3 100644 --- a/hugegraph-python-client/src/pyhugegraph/structure/vertex_label_data.py +++ b/hugegraph-python-client/src/pyhugegraph/structure/vertex_label_data.py @@ -57,6 +57,8 @@ def userdata(self): return self.__user_data def __repr__(self): - res = "name: {}, primary_keys: {}, properties: {}".format( - self.__name, self.__primary_keys, self.__properties) + res = ( + f"name: {self.__name}, primary_keys: {self.__primary_keys}, " + f"properties: {self.__properties}" + ) return res diff --git a/hugegraph-python-client/src/pyhugegraph/utils/exceptions.py b/hugegraph-python-client/src/pyhugegraph/utils/exceptions.py index 7cfb4aaac..78fee8c19 100644 --- a/hugegraph-python-client/src/pyhugegraph/utils/exceptions.py +++ b/hugegraph-python-client/src/pyhugegraph/utils/exceptions.py @@ -18,45 +18,47 @@ class NotAuthorizedError(Exception): """ - Not Authorized + Not Authorized """ + class InvalidParameter(Exception): """ - Parameter setting error + Parameter setting error """ + class NotFoundError(Exception): """ - no content found + no content found """ class CreateError(Exception): """ - Failed to create vertex or edge + Failed to create vertex or edge """ class RemoveError(Exception): """ - Failed to delete vertex or edge + Failed to delete vertex or edge """ class UpdateError(Exception): """ - Failed to modify node + Failed to modify node """ class DataFormatError(Exception): """ - Input data format error + Input data format error """ class ServiceUnavailableException(Exception): """ - The server is too busy to be available + The server is too busy to be available """ diff --git a/hugegraph-python-client/src/pyhugegraph/utils/huge_decorator.py b/hugegraph-python-client/src/pyhugegraph/utils/huge_decorator.py index 3087778f6..47906ad90 100644 --- a/hugegraph-python-client/src/pyhugegraph/utils/huge_decorator.py +++ b/hugegraph-python-client/src/pyhugegraph/utils/huge_decorator.py @@ -24,16 +24,16 @@ def decorator_params(func, *args, **kwargs): parameter_holder = args[0].get_parameter_holder() if parameter_holder is None or "name" not in parameter_holder.get_keys(): - print('Parameters required, please set necessary parameters.') - raise + print("Parameters required, please set necessary parameters.") + raise Exception("Parameters required, please set necessary parameters.") return func(*args, **kwargs) @decorator def decorator_create(func, *args, **kwargs): parameter_holder = args[0].get_parameter_holder() - if parameter_holder.get_value('not_exist') is False: - return 'Create failed, "{}" already exists.'.format(parameter_holder.get_value('name')) + if parameter_holder.get_value("not_exist") is False: + return f'Create failed, "{parameter_holder.get_value("name")}" already exists.' return func(*args, **kwargs) @@ -41,5 +41,5 @@ def decorator_create(func, *args, **kwargs): def decorator_auth(func, *args, **kwargs): response = args[0] if response.status_code == 401: - raise NotAuthorizedError("NotAuthorized: {}".format(response.content)) + raise NotAuthorizedError(f"NotAuthorized: {response.content}") return func(*args, **kwargs) diff --git a/hugegraph-python-client/src/pyhugegraph/utils/huge_requests.py b/hugegraph-python-client/src/pyhugegraph/utils/huge_requests.py index 744e8b5a3..57ac233d7 100644 --- a/hugegraph-python-client/src/pyhugegraph/utils/huge_requests.py +++ b/hugegraph-python-client/src/pyhugegraph/utils/huge_requests.py @@ -26,7 +26,7 @@ def new_session(): session = requests.Session() retry = Retry(connect=5, backoff_factor=1) adapter = HTTPAdapter(max_retries=retry) - session.mount('http://', adapter) - session.mount('https://', adapter) + session.mount("http://", adapter) + session.mount("https://", adapter) session.keep_alive = False return session diff --git a/hugegraph-python-client/src/pyhugegraph/utils/util.py b/hugegraph-python-client/src/pyhugegraph/utils/util.py index c5368b0c5..56d6533e2 100644 --- a/hugegraph-python-client/src/pyhugegraph/utils/util.py +++ b/hugegraph-python-client/src/pyhugegraph/utils/util.py @@ -17,21 +17,26 @@ import json -from pyhugegraph.utils.exceptions import ServiceUnavailableException, NotAuthorizedError, NotFoundError +from pyhugegraph.utils.exceptions import ( + ServiceUnavailableException, + NotAuthorizedError, + NotFoundError, +) def create_exception(response_content): data = json.loads(response_content) if "ServiceUnavailableException" in data["exception"]: - raise ServiceUnavailableException('ServiceUnavailableException, "message": "{}", "cause": "{}"'. - format(data["message"], data["cause"])) - else: - raise Exception(response_content) + raise ServiceUnavailableException( + f'ServiceUnavailableException, "message": "{data["message"]}",' + f' "cause": "{data["cause"]}"' + ) + raise Exception(response_content) def check_if_authorized(response): if response.status_code == 401: - raise NotAuthorizedError("Please check your username and password. {}".format(response.content)) + raise NotAuthorizedError(f"Please check your username and password. {response.content}") return True diff --git a/pylint.conf b/pylint.conf new file mode 100644 index 000000000..a3638df55 --- /dev/null +++ b/pylint.conf @@ -0,0 +1,647 @@ +[MAIN] + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Clear in-memory caches upon conclusion of linting. Useful if running pylint +# in a server-like mode. +clear-cache-post-run=no + +# Load and enable all available extensions. Use --list-extensions to see a list +# all available extensions. +#enable-all-extensions= + +# In error mode, messages with a category besides ERROR or FATAL are +# suppressed, and no reports are done by default. Error mode is compatible with +# disabling specific errors. +#errors-only= + +# Always return a 0 (non-error) status code, even if lint errors are found. +# This is primarily useful in continuous integration scripts. +#exit-zero= + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. +extension-pkg-allow-list= + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. (This is an alternative name to extension-pkg-allow-list +# for backward compatibility.) +extension-pkg-whitelist= + +# Return non-zero exit code if any of these messages/categories are detected, +# even if score is above --fail-under value. Syntax same as enable. Messages +# specified are enabled, while categories only check already-enabled messages. +fail-on= + +# Specify a score threshold under which the program will exit with error. +fail-under=10 + +# Interpret the stdin as a python script, whose filename needs to be passed as +# the module_or_package argument. +#from-stdin= + +# Files or directories to be skipped. They should be base names, not paths. +ignore=CVS + +# Add files or directories matching the regular expressions patterns to the +# ignore-list. The regex matches against paths and can be in Posix or Windows +# format. Because '\\' represents the directory delimiter on Windows systems, +# it can't be used as an escape character. +ignore-paths=./hugegraph-python-client/src/pyhugegraph/structure,./hugegraph-python-client/src/pyhugegraph/api/schema_manage,./hugegraph-python-client/src/pyhugegraph/api/graph.py,./hugegraph-python-client/src/pyhugegraph/api/schema.py + +# Files or directories matching the regular expression patterns are skipped. +# The regex matches against base names, not paths. The default value ignores +# Emacs file locks +ignore-patterns=^\.# + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis). It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the +# number of processors available to use, and will cap the count on Windows to +# avoid hangs. +jobs=1 + +# Control the amount of potential inferred values when inferring a single +# object. This can help the performance when dealing with large functions or +# complex, nested conditions. +limit-inference-results=100 + +# List of plugins (as comma separated values of python module names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# Minimum Python version to use for version dependent checks. Will default to +# the version used to run pylint. +py-version=3.11 + +# Discover python modules and packages in the file system subtree. +recursive=no + +# Add paths to the list of the source roots. Supports globbing patterns. The +# source root is an absolute path or a path relative to the current working +# directory used to determine a package namespace for modules located under the +# source root. +source-roots= + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages. +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + +# In verbose mode, extra non-checker-related info will be displayed. +#verbose= + + +[BASIC] + +# Naming style matching correct argument names. +argument-naming-style=snake_case + +# Regular expression matching correct argument names. Overrides argument- +# naming-style. If left empty, argument names will be checked with the set +# naming style. +#argument-rgx= + +# Naming style matching correct attribute names. +attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style. If left empty, attribute names will be checked with the set naming +# style. +#attr-rgx= + +# Bad variable names which should always be refused, separated by a comma. +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Bad variable names regexes, separated by a comma. If names match any regex, +# they will always be refused +bad-names-rgxs= + +# Naming style matching correct class attribute names. +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style. If left empty, class attribute names will be checked +# with the set naming style. +#class-attribute-rgx= + +# Naming style matching correct class constant names. +class-const-naming-style=UPPER_CASE + +# Regular expression matching correct class constant names. Overrides class- +# const-naming-style. If left empty, class constant names will be checked with +# the set naming style. +#class-const-rgx= + +# Naming style matching correct class names. +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming- +# style. If left empty, class names will be checked with the set naming style. +#class-rgx= + +# Naming style matching correct constant names. +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style. If left empty, constant names will be checked with the set naming +# style. +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names. +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style. If left empty, function names will be checked with the set +# naming style. +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma. +good-names=i, + j, + k, + ex, + Run, + _ + +# Good variable names regexes, separated by a comma. If names match any regex, +# they will always be accepted +good-names-rgxs= + +# Include a hint for the correct naming format with invalid-name. +include-naming-hint=no + +# Naming style matching correct inline iteration names. +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style. If left empty, inline iteration names will be checked +# with the set naming style. +#inlinevar-rgx= + +# Naming style matching correct method names. +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style. If left empty, method names will be checked with the set naming style. +#method-rgx= + +# Naming style matching correct module names. +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style. If left empty, module names will be checked with the set naming style. +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +# These decorators are taken in consideration only for invalid-name. +property-classes=abc.abstractproperty + +# Regular expression matching correct type alias names. If left empty, type +# alias names will be checked with the set naming style. +#typealias-rgx= + +# Regular expression matching correct type variable names. If left empty, type +# variable names will be checked with the set naming style. +#typevar-rgx= + +# Naming style matching correct variable names. +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style. If left empty, variable names will be checked with the set +# naming style. +#variable-rgx= + + +[CLASSES] + +# Warn about protected attribute access inside special methods +check-protected-access-in-special-methods=no + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp, + asyncSetUp, + __post_init__ + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict,_fields,_replace,_source,_make,os._exit + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + + +[DESIGN] + +# List of regular expressions of class ancestor names to ignore when counting +# public methods (see R0903) +exclude-too-few-public-methods= + +# List of qualified class names to ignore when counting class parents (see +# R0901) +ignored-parents= + +# Maximum number of arguments for function / method. +max-args=5 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Maximum number of boolean expressions in an if statement (see R0916). +max-bool-expr=5 + +# Maximum number of branch for function / method body. +max-branches=12 + +# Maximum number of locals for function / method body. +max-locals=15 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + +# Maximum number of return / yield for function / method body. +max-returns=6 + +# Maximum number of statements in function / method body. +max-statements=50 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when caught. +overgeneral-exceptions=builtins.BaseException,builtins.Exception + + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=100 + +# Maximum number of lines in a module. +max-module-lines=1000 + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[IMPORTS] + +# List of modules that can be imported at any level, not just the top level +# one. +allow-any-import-level= + +# Allow explicit reexports by alias from a package __init__. +allow-reexport-from-package=no + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Deprecated modules which should not be used, separated by a comma. +deprecated-modules= + +# Output a graph (.gv or any supported image format) of external dependencies +# to the given file (report RP0402 must not be disabled). +ext-import-graph= + +# Output a graph (.gv or any supported image format) of all (i.e. internal and +# external) dependencies to the given file (report RP0402 must not be +# disabled). +import-graph= + +# Output a graph (.gv or any supported image format) of internal dependencies +# to the given file (report RP0402 must not be disabled). +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + +# Couples of modules and preferred modules, separated by a comma. +preferred-modules= + + +[LOGGING] + +# The type of string formatting that logging methods do. `old` means using % +# formatting, `new` is for `{}` formatting. +logging-format-style=old + +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, +# UNDEFINED. +confidence=HIGH, + CONTROL_FLOW, + INFERENCE, + INFERENCE_FAILURE, + UNDEFINED + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then re-enable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable=raw-checker-failed, + bad-inline-option, + locally-disabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + use-symbolic-message-instead, + use-implicit-booleaness-not-comparison-to-string, + use-implicit-booleaness-not-comparison-to-zero, + missing-module-docstring, + missing-class-docstring, + missing-function-docstring, + W0122, # Use of exec (exec-used) + R0914, # Too many local variables (19/15) (too-many-locals) + R0903, # Too few public methods (1/2) + W0613, # Unused argument + W0511, # TODO + W0719, # Raising too general exception: Exception + R0801, # Similar lines + W0105, # String statement has no effect (pointless-string-statement) + R0913, # Too many arguments (6/5) (too-many-arguments) + C0415, # Import outside toplevel + R0902 # Too many instance attributes (11/7) +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable= + + +[METHOD_ARGS] + +# List of qualified names (i.e., library.method) which require a timeout +# parameter e.g. 'requests.api.get,requests.api.post' +timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.api.options,requests.api.patch,requests.api.post,requests.api.put,requests.api.request + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + +# Regular expression of note tags to take in consideration. +notes-rgx= + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=sys.exit,argparse.parse_error + + +[REPORTS] + +# Python expression which should return a score less than or equal to 10. You +# have access to the variables 'fatal', 'error', 'warning', 'refactor', +# 'convention', and 'info' which contain the number of messages in each +# category, as well as 'statement' which is the total number of statements +# analyzed. This score is used by the global evaluation report (RP0004). +evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details. +msg-template= + +# Set the output format. Available formats are: text, parseable, colorized, +# json2 (improved json format), json (old json format) and msvs (visual +# studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +#output-format= + +# Tells whether to display a full report or only the messages. +reports=no + +# Activate the evaluation score. +score=yes + + +[SIMILARITIES] + +# Comments are removed from the similarity computation +ignore-comments=yes + +# Docstrings are removed from the similarity computation +ignore-docstrings=yes + +# Imports are removed from the similarity computation +ignore-imports=yes + +# Signatures are removed from the similarity computation +ignore-signatures=yes + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes. +max-spelling-suggestions=4 + +# Spelling dictionary name. No available dictionaries : You need to install +# both the python package and the system dependency for enchant to work. +spelling-dict= + +# List of comma separated words that should be considered directives if they +# appear at the beginning of a comment and should not be checked. +spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy: + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains the private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to the private dictionary (see the +# --spelling-private-dict-file option) instead of raising a message. +spelling-store-unknown-words=no + + +[STRING] + +# This flag controls whether inconsistent-quotes generates a warning when the +# character used as a quote delimiter is used inconsistently within a module. +check-quote-consistency=no + +# This flag controls whether the implicit-str-concat should generate a warning +# on implicit string concatenation in sequences defined over several lines. +check-str-concat-over-line-jumps=no + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether to warn about missing members when the owner of the attribute +# is inferred to be None. +ignore-none=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of symbolic message names to ignore for Mixin members. +ignored-checks-for-mixins=no-member, + not-async-context-manager, + not-context-manager, + attribute-defined-outside-init + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + +# Regex pattern to define which classes are considered mixins. +mixin-class-rgx=.*[Mm]ixin + +# List of decorators that change the signature of a decorated function. +signature-mutators= + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid defining new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of names allowed to shadow builtins +allowed-redefined-builtins= + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expected to +# not be used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io From 7aab3e3699b529206e65a2439134a5b0428fd982 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 23 Oct 2023 16:34:42 +0800 Subject: [PATCH 4/5] introduce pylint --- .github/workflows/pylint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index f3caddf28..ccb4613d3 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -24,9 +24,9 @@ jobs: pip install pylint pip install -r ./hugegraph-llm/requirements.txt pip install -r ./hugegraph-python-client/requirements.txt - export PYTHONPATH=$(pwd)/hugegraph-llm/src:$(pwd)/hugegraph-python-client/src - echo ${PYTHONPATH} - name: Analysing the code with pylint run: | + export PYTHONPATH=$(pwd)/hugegraph-llm/src:$(pwd)/hugegraph-python-client/src + echo ${PYTHONPATH} pylint --rcfile=./pylint.conf hugegraph-llm pylint --rcfile=./pylint.conf hugegraph-python-client From 98c012f49b02cdaf0df0d871a2408f1c787cc301 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 23 Oct 2023 16:37:40 +0800 Subject: [PATCH 5/5] introduce pylint --- hugegraph-python-client/src/pyhugegraph/api/graphs.py | 2 +- .../src/pyhugegraph/api/schema_manage/edge_label.py | 2 +- .../src/pyhugegraph/api/schema_manage/property_key.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hugegraph-python-client/src/pyhugegraph/api/graphs.py b/hugegraph-python-client/src/pyhugegraph/api/graphs.py index 6b4a1339c..9db1b5679 100644 --- a/hugegraph-python-client/src/pyhugegraph/api/graphs.py +++ b/hugegraph-python-client/src/pyhugegraph/api/graphs.py @@ -11,7 +11,7 @@ # 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 +# KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. diff --git a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py index a26d4710a..78cbcb5e4 100644 --- a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py +++ b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py @@ -11,7 +11,7 @@ # 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 +# KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. diff --git a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py index 903f527d4..d0ce9a1ba 100644 --- a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py +++ b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py @@ -11,7 +11,7 @@ # 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 +# KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License.