imbajin commented on code in PR #83: URL: https://github.com/apache/incubator-hugegraph-ai/pull/83#discussion_r1769937937
########## hugegraph-ml/README.md: ########## @@ -1 +1,123 @@ - \ No newline at end of file + # hugegraph-ml + +## Summary + +`hugegraph-ml` is a tool that integrates HugeGraph with popular graph learning libraries. +It implements most graph learning algorithms, enabling users to perform end-to-end graph learning workflows directly from HugeGraph using `hugegraph-ml`. +Graph data can be read directly from `HugeGraph` and used for tasks such as node embedding, node classification, and graph classification. +The implemented algorithm models can be found in the [models](./src/hugegraph_ml/models) folder. + + +## Environment Requirements + +- python 3.9+ +- hugegraph-server 1.0+ + +## Preparation + +1. Start the HugeGraph database, you can do it via Docker/[Binary packages](https://hugegraph.apache.org/docs/download/download/). +Refer to [docker-link](https://hub.docker.com/r/hugegraph/hugegraph) & [deploy-doc](https://hugegraph.apache.org/docs/quickstart/hugegraph-server/#31-use-docker-container-convenient-for-testdev) for guidance +2. Clone this project + ```bash + git clone https://github.com/apache/incubator-hugegraph-ai.git + ``` +3. Install [hugegraph-python-client](../hugegraph-python-client) and [hugegraph_ml](../hugegraph-ml) + ```bash + cd ./incubator-hugegraph-ai # better to use virtualenv (source venv/bin/activate) + pip install ./hugegraph-python-client + cd .\hugegraph-ml\ + pip install -e . + ``` +4. Enter the project directory + ```bash + cd ./hugegraph-ml/src + ``` + +## Examples + +### Perform node embedding on the `Cora` dataset using the `DGI` model + +Make sure that the Cora dataset is already in your HugeGraph database. +If not, you can run the `import_graph_from_dgl` function to import the `Cora` dataset from `DGL` into +the `HugeGraph` database. + +```python +from hugegraph_ml.utils.dgl2hugegraph_utils import import_graph_from_dgl + +import_graph_from_dgl("cora") +``` + +Run [dgi_example.py](./src/hugegraph_ml/examples/dgi_example.py) to view the example. +```bash +python .\hugegraph_ml\examples\dgi_example.py Review Comment: same ########## hugegraph-ml/src/tests/test_tasks/test_node_embed.py: ########## @@ -0,0 +1,62 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +import unittest Review Comment: ```suggestion # under the License. import unittest ``` ########## hugegraph-ml/README.md: ########## @@ -1 +1,123 @@ - \ No newline at end of file + # hugegraph-ml + +## Summary + +`hugegraph-ml` is a tool that integrates HugeGraph with popular graph learning libraries. +It implements most graph learning algorithms, enabling users to perform end-to-end graph learning workflows directly from HugeGraph using `hugegraph-ml`. +Graph data can be read directly from `HugeGraph` and used for tasks such as node embedding, node classification, and graph classification. +The implemented algorithm models can be found in the [models](./src/hugegraph_ml/models) folder. + + +## Environment Requirements + +- python 3.9+ +- hugegraph-server 1.0+ + +## Preparation + +1. Start the HugeGraph database, you can do it via Docker/[Binary packages](https://hugegraph.apache.org/docs/download/download/). +Refer to [docker-link](https://hub.docker.com/r/hugegraph/hugegraph) & [deploy-doc](https://hugegraph.apache.org/docs/quickstart/hugegraph-server/#31-use-docker-container-convenient-for-testdev) for guidance +2. Clone this project + ```bash + git clone https://github.com/apache/incubator-hugegraph-ai.git + ``` +3. Install [hugegraph-python-client](../hugegraph-python-client) and [hugegraph_ml](../hugegraph-ml) + ```bash + cd ./incubator-hugegraph-ai # better to use virtualenv (source venv/bin/activate) + pip install ./hugegraph-python-client + cd .\hugegraph-ml\ Review Comment: maybe keep the unix-style `/` in cmd path? ########## hugegraph-ml/src/hugegraph_ml/data/hugegraph2dgl.py: ########## @@ -0,0 +1,84 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import dgl +import torch +from pyhugegraph.api.gremlin import GremlinManager +from pyhugegraph.client import PyHugeClient + + +class HugeGraph2DGL: + def __init__( + self, + ip='127.0.0.1', + port="8080", + graph='hugegraph', + user='admin', + pwd='xxx', Review Comment: better to use `""` or `admin`? ########## hugegraph-ml/src/hugegraph_ml/utils/dgl2hugegraph_utils.py: ########## @@ -0,0 +1,133 @@ +# 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 dgl.data import CoraGraphDataset, CiteseerGraphDataset, PubmedGraphDataset +from pyhugegraph.api.graph import GraphManager +from pyhugegraph.api.schema import SchemaManager +from pyhugegraph.client import PyHugeClient + + +def clear_all_data( + ip='127.0.0.1', + port="8080", + graph_name='hugegraph', + user='admin', + pwd='xxx', Review Comment: same -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
