### Install git Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/install_en.rst Installs git using apt-get, required for building from source. ```bash sudo apt-get install git-all ``` -------------------------------- ### Customize GIE instance configuration Source: https://github.com/alibaba/graphscope/blob/main/docs/interactive_engine/getting_started.md Pass additional key-value pairs to customize the startup configuration of GIE. This example sets the total execution time for a query to 3000 seconds. ```python # set total execution time for a query to 3000s g = gs.interactive(graph, params={'query.execution.timeout.ms': 3000000}) ``` -------------------------------- ### Sample output from interactive queries Source: https://github.com/alibaba/graphscope/blob/main/docs/interactive_engine/getting_started.md Example output from running the interactive queries. Shows the log line for building the interactive frontend and the printed results. ```shell ... ... [INFO][coordinator:453]: Built interactive frontend xxx.xxx.xxx.xxx:pppp for graph xxx [6] ... [v[2], v[3], v[0], v[1]] ... ``` -------------------------------- ### Install via Setuptools Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/interactive/development/python/python_sdk.md Build and install the package using Setuptools. Optionally use sudo to install for all users. ```sh python3 setup.py build_proto python3 setup.py install --user ``` -------------------------------- ### Install GraphScope with Aliyun mirror Source: https://github.com/alibaba/graphscope/blob/main/docs/analytical_engine/getting_started.md Install GraphScope using a mirror site to improve download speed. This command uses the Aliyun PyPI mirror. ```bash python3 -m pip install graphscope --upgrade \ -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com ``` -------------------------------- ### Create and use a Python virtual environment for GraphScope Source: https://github.com/alibaba/graphscope/blob/main/docs/interactive_engine/getting_started.md Step-by-step instructions to create a clean Python 3.9 virtual environment, activate it, install GraphScope, and start a Python session. Recommended to avoid package conflicts. ```bash # Create a new virtual environment python3.9 -m venv tutorial-env # Activate the virtual environment source tutorial-env/bin/activate # Install GraphScope python3.9 -m pip install graphscope # Use GraphScope python3.9 >>> import graphscope as gs >>> ...... ``` -------------------------------- ### Install dependencies and run server Source: https://github.com/alibaba/graphscope/blob/main/flex/interactive/sdk/master/README.md Install required packages and start the server from the root directory. ```bash pip3 install -r requirements.txt python3 -m gs_interactive_admin ``` -------------------------------- ### Install TensorFlow 1.12 Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/install_en.rst Installs TensorFlow 1.12.0, required to run the example models provided by GL. ```bash sudo pip install tensorflow==1.12.0 ``` -------------------------------- ### Install Learning Engine with make learning-install Source: https://github.com/alibaba/graphscope/blob/main/docs/learning_engine/dev_and_test.md Install the built learning engine to a specified location using `INSTALL_PREFIX`. The example installs to `/opt/graphscope`. ```bash make learning-install INSTALL_PREFIX=/opt/graphscope ``` -------------------------------- ### Install built wheel Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/install_en.rst Installs the wheel package generated in the dist directory after compilation. ```bash sudo pip install dist/your_wheel_name.whl ``` -------------------------------- ### Compile from source Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/install_en.rst Clones the repository, initializes submodules, and runs make test and make python to build. ```bash git clone https://github.com/alibaba/graph-learn.git cd graph-learn git submodule update --init make test make python ``` -------------------------------- ### Run tests Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/install_en.rst Sources the environment and runs C++ and Python unit tests. ```bash source env.sh ./test_cpp_ut.sh ./test_python_ut.sh ``` -------------------------------- ### Run prebuilt dev Docker image Source: https://github.com/alibaba/graphscope/blob/main/docs/analytical_engine/dev_and_test.md Starts an interactive container named 'dev' with 4096 MB shared memory using the GraphScope dev image. Use this to get a ready-to-use development environment. ```bash docker run --name dev -it --shm-size=4096m registry.cn-hongkong.aliyuncs.com/graphscope/graphscope-dev:latest ``` -------------------------------- ### Install ogb and PyG dependencies Source: https://github.com/alibaba/graphscope/blob/main/python/graphscope/learning/gl_torch_examples/README.md Install ogb and PyG according to the PyTorch version. The command includes installing torch_geometric and related PyG libraries from the PyG wheel index, with a placeholder for the PyTorch version in the URL. ```shell pip3 install ogb pip3 install torch_geometric pip3 install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-x.x.x+cpu.html ``` -------------------------------- ### Install all built artifacts Source: https://github.com/alibaba/graphscope/blob/main/docs/development/dev_guide.md Installs all built artifacts to /opt/graphscope by default. Override the location by setting INSTALL_PREFIX. ```bash make install [INSTALL_PREFIX=/opt/graphscope] ``` -------------------------------- ### Instantiate Estimator and start training Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/quick_start_en.rst Creates a TensorFlow Estimator with the defined model_fn and parameters, then starts training using sample_input_fn. ```python params = {"learning_rate": 1e-4, 'feature_columns': feature_columns} model = tf.estimator.Estimator(model_fn=model_fn, params=params) model.train(input_fn=sample_input_fn) ``` -------------------------------- ### Install wheel package with pip Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/install_en.rst Installs the downloaded wheel package using pip with sudo privileges. ```bash sudo pip install graphlearn-0.1-cp27-cp27mu-linux_x86_64.whl ``` -------------------------------- ### Install analytical engine with make analytical-install Source: https://github.com/alibaba/graphscope/blob/main/docs/analytical_engine/dev_and_test.md Installs the built analytical engine to a specified location using the INSTALL_PREFIX variable. The default installation prefix is /usr/local. ```bash make analytical-install INSTALL_PREFIX=/usr/local ``` -------------------------------- ### Deploy Interactive instance in local mode Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/coordinator/getting_started.md Install gsctl and deploy the Interactive instance in local mode. Use `gsctl instance deploy --help` for more information. If a port binding problem occurs, destroy the instance first and then redeploy. ```bash pip3 install gsctl # Deploy the Interactive instance in local mode gsctl instance deploy --type interactive ``` -------------------------------- ### Import gs_interactive package Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/interactive/development/python/python_sdk.md Import the gs_interactive package after installation. ```python import gs_interactive ``` -------------------------------- ### Connect to Cypher service with cypher-shell Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/interactive/getting_started.md Starts cypher-shell to connect to the Interactive Cypher service. Use -a neo4j://localhost: to connect to a customized port. ```bash ./cypher-shell # or -a neo4j://localhost: to connect to the customized port ``` -------------------------------- ### Install pyYAML Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/interactive/development/python/python_sdk.md Installs the pyYAML package via pip, required for converting YAML graph schema definitions to Python dicts. ```bash pip3 install pyYAML ``` -------------------------------- ### Startup engine with Configuration::parse Source: https://github.com/alibaba/graphscope/blob/main/interactive_engine/executor/engine/pegasus/README.md Reads the hosts.toml file and starts the Pegasus engine. The file path is provided as a string to std::fs::read_to_string. ```rust let server_conf = Configuration::parse( std::fs::read_to_string("/path/to/hosts.toml").unwrap() ).unwrap(); pegasus::startup(server_conf).ok(); ``` -------------------------------- ### Pull CPU Docker image Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/install_en.rst Downloads the CPU version of the GL Docker image. ```default docker pull registry.cn-zhangjiakou.aliyuncs.com/pai-image/graph-learn:v0.1-cpu ``` -------------------------------- ### Install GIE standalone from local Helm package Source: https://github.com/alibaba/graphscope/blob/main/charts/gie-standalone/README.md Downloads the Helm package and installs it locally for customized configuration. ```bash # download helm package helm pull graphscope/gie-standalone --untar helm install gie-standalone ``` -------------------------------- ### List available resources Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/coordinator/getting_started.md After connecting to the coordinator service, list the available resources. ```bash gsctl ls -l ``` -------------------------------- ### Install with image.tag set via --set Source: https://github.com/alibaba/graphscope/blob/main/charts/graphscope-store/README.md Use --set key=value to specify parameters during helm install. This example sets image.tag to latest. ```bash $ helm install my-release \ --set image.tag=latest graphscope/graphscope-store ``` -------------------------------- ### Pull GPU Docker image Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/install_en.rst Downloads the GPU version of the GL Docker image. ```default docker pull registry.cn-zhangjiakou.aliyuncs.com/pai-image/graph-learn:v0.1-gpu ``` -------------------------------- ### Build word_count_toy example Source: https://github.com/alibaba/graphscope/blob/main/interactive_engine/executor/engine/pegasus/README.md Compiles the word_count_toy example in release mode. The resulting binary is placed under target/release/examples. ```bash cargo build --release --example word_count_toy ``` -------------------------------- ### Install with values file using -f Source: https://github.com/alibaba/graphscope/blob/main/charts/graphscope-store/README.md Provide a YAML file that specifies values for the parameters while installing the chart. The default values.yaml can be used as a starting point. ```bash $ helm install my-release -f values.yaml graphscope/graphscope-store ``` -------------------------------- ### Install GraphScope via pip Source: https://github.com/alibaba/graphscope/blob/main/docs/overview/getting_started.md Install the latest version of GraphScope using pip. It is recommended to use a clean Python 3.9 virtual environment. ```bash python3 -m pip install graphscope -U ``` -------------------------------- ### Run the Java SDK example Source: https://github.com/alibaba/graphscope/blob/main/docs/interactive_engine/graph_planner.md Runs the Java SDK example with the specified configuration, query, schema, and statistics files. ```bash java -cp ".:./libs/*" com.alibaba.graphscope.sdk.examples.TestGraphPlanner ./conf/gs_interactive_hiactor.yaml "Match (n) Return n;" ./conf/graph.yaml ./conf/modern_statistics.json ``` -------------------------------- ### Install GraphScope with pip Source: https://github.com/alibaba/graphscope/blob/main/docs/analytical_engine/getting_started.md Install the GraphScope package using pip. Use this command to install the latest version. ```bash python3 -m pip install graphscope --upgrade ``` -------------------------------- ### Install graphscope-client package Source: https://github.com/alibaba/graphscope/blob/main/README.md Install a subset of the GraphScope package with client functions only, if the full package was not installed earlier. ```bash pip3 install graphscope-client ``` -------------------------------- ### Install TensorFlow 2.11.0 for aarch64 Source: https://github.com/alibaba/graphscope/blob/main/docs/learning_engine/getting_started.md Installs the fixed TensorFlow v2.11.0 version under the Linux aarch64 platform, as only this version is supported there. ```bash # Install the fixed 'v2.11.0' version of tensorflow under the linux aarch64 platform python3 -m pip install tensorflow==2.11.0 ``` -------------------------------- ### Define and run supervised GraphSAGE training Source: https://github.com/alibaba/graphscope/blob/main/docs/overview/getting_started.md Defines a train_sage function that builds an EgoGraphSAGE model, prepares train and test datasets with EgoSAGESupervisedDataLoader, computes loss and accuracy, and runs training and testing with LocalTrainer. Uses TensorFlow compatibility imports and requires graphscope.learning. The example calls train_sage with class_num=349 and features_num=130 (128 + kcore + triangle count). ```python try: # https://www.tensorflow.org/guide/migrate import tensorflow.compat.v1 as tf tf.disable_v2_behavior() except ImportError: import tensorflow as tf import graphscope.learning from graphscope.learning.examples import EgoGraphSAGE from graphscope.learning.examples import EgoSAGESupervisedDataLoader from graphscope.learning.examples.tf.trainer import LocalTrainer # supervised GraphSAGE. def train_sage(graph, node_type, edge_type, class_num, features_num, hops_num=2, nbrs_num=[25, 10], epochs=2, hidden_dim=256, in_drop_rate=0.5, learning_rate=0.01, ): graphscope.learning.reset_default_tf_graph() dimensions = [features_num] + [hidden_dim] * (hops_num - 1) + [class_num] model = EgoGraphSAGE(dimensions, act_func=tf.nn.relu, dropout=in_drop_rate) # prepare train dataset train_data = EgoSAGESupervisedDataLoader( graph, graphscope.learning.Mask.TRAIN, node_type=node_type, edge_type=edge_type, nbrs_num=nbrs_num, hops_num=hops_num, ) train_embedding = model.forward(train_data.src_ego) train_labels = train_data.src_ego.src.labels loss = tf.reduce_mean( tf.nn.sparse_softmax_cross_entropy_with_logits( labels=train_labels, logits=train_embedding, ) ) optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate) # prepare test dataset test_data = EgoSAGESupervisedDataLoader( graph, graphscope.learning.Mask.TEST, node_type=node_type, edge_type=edge_type, nbrs_num=nbrs_num, hops_num=hops_num, ) test_embedding = model.forward(test_data.src_ego) test_labels = test_data.src_ego.src.labels test_indices = tf.math.argmax(test_embedding, 1, output_type=tf.int32) test_acc = tf.div( tf.reduce_sum(tf.cast(tf.math.equal(test_indices, test_labels), tf.float32)), tf.cast(tf.shape(test_labels)[0], tf.float32), ) # train and test trainer = LocalTrainer() trainer.train(train_data.iterator, loss, optimizer, epochs=epochs) trainer.test(test_data.iterator, test_acc) train_sage(lg, node_type="paper", edge_type="cites", class_num=349, # output dimension features_num=130, # input dimension, 128 + kcore + triangle count ) ``` -------------------------------- ### Install TensorFlow 2.8.0 for GraphScope Source: https://github.com/alibaba/graphscope/blob/main/docs/learning_engine/getting_started.md Installs TensorFlow v2.8.0 as the NN backend for GraphScope Learning Engine. The comment warns that the latest TensorFlow may cause dependency conflicts, so this fixed version is recommended. ```bash # Installing the latest version of tensorflow may cause dependency # conflicts with GraphScope, we use v2.8.0 here. python3 -m pip install tensorflow==2.8.0 ``` -------------------------------- ### Run the test_graph_planner example binary Source: https://github.com/alibaba/graphscope/blob/main/docs/interactive_engine/graph_planner.md Executes the provided example binary to demonstrate the JNI interface. The command takes a Java class path, JNA lib path, graph schema path, graph statistics path, query, and config path. The output includes an error code, a physical plan in byte format, and a result schema in YAML. ```bash # bin/test_graph_planner bin/test_graph_planner libs native ./conf/graph.yaml ./conf/modern_statistics.json "MATCH (n) RETURN n, COUNT(n);" ./conf/gs_interactive_hiactor.yaml ``` -------------------------------- ### Prepare data and train supervised model Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/quick_start_en.rst Commands to generate the cora dataset and run supervised training for the vertex-classification task. ```shell # Data preparation cd graph-learn/examples/data/ python cora.py # Training and model assessment python train_supervised.py ``` -------------------------------- ### POST /v1/service/start Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/interactive/development/python/python_sdk_ref.md Starts the service. ```APIDOC ## POST /v1/service/start ### Description Starts the service. ### Method POST ### Endpoint /v1/service/start ### Response #### Success Response (200) Indicates the service was started successfully. ``` -------------------------------- ### StartService example in Java Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/interactive/development/java/ServiceManagementApi.md Starts the service on a specified graph. Uses the Session.startService() method with a StartServiceRequest that sets the graphId to "1". Checks the Result for success and prints appropriate messages. ```java // Import classes: import com.alibaba.graphscope.interactive.client.Driver; import com.alibaba.graphscope.interactive.client.Session; import com.alibaba.graphscope.interactive.client.common.Result; import com.alibaba.graphscope.interactive.models.StartServiceRequest; public class Example { public static void main(String[] args) { Driver driver = Driver.connect(); Session session = driver.session(); Result start = session.startService(new StartServiceRequest().graphId("1")); if (!start.isOk()) { System.out.println("Failed to start service: " + start.getStatusMessage()); } else { System.out.println("Service started: " + start.getValue()); } } } ``` -------------------------------- ### Edge data format example Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/quick_start_en.rst Shows the format of the edge data produced by the data preparation script. Each line contains source and destination vertex IDs, with a weight. ```shell src_id:int64 dst_id:int64 35 1033 35 103482 35 103515 ``` -------------------------------- ### Install via Setuptools Source: https://github.com/alibaba/graphscope/blob/main/flex/interactive/sdk/python/README.md Install the package from source using setuptools. Use --user for a local install or sudo for all users. ```sh python setup.py install --user ``` -------------------------------- ### Vertex data format example Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/quick_start_en.rst Shows the format of the vertex data produced by the data preparation script. Each line contains vertex ID, label, and a feature string of 1433 floats. ```default id:int64 label:int32 feature:string 31336 4 0.0:0.0:... 1061127 1 0.0:0.05882353:... 1106406 2 0.0:0.0:... ``` -------------------------------- ### perf-eval examples for gab_cli.py Source: https://github.com/alibaba/graphscope/blob/main/analytical_engine/benchmarks/framework/README.md Example commands to run PageRank on Flash, Grape, and Ligra, and Triangle Counting on GraphX. Note that Flash requires a directory, Grape requires a prefix for .e and .v files, and other platforms require the complete dataset file. ```bash # Run PageRank on Flash python3 gab_cli.py perf-eval --platform flash --algorithm pagerank --path sample_data/flash_sample_graph/ ``` ```bash # Run PageRank on Grape python3 gab_cli.py perf-eval --platform grape --algorithm pagerank --path sample_data/grape_sample_graph ``` ```bash # Run PageRank on Ligra python3 gab_cli.py perf-eval --platform ligra --algorithm pagerank --path sample_data/ligra_sample_graph.txt ``` ```bash # Run Triangle Counting on GraphX python3 gab_cli.py perf-eval --platform graphx --algorithm triangle --path sample_data/graphx_sample_graph.txt --spark-master spark://spark-master:7077 ``` -------------------------------- ### Run interactive queries with Gremlin and Cypher Source: https://github.com/alibaba/graphscope/blob/main/docs/overview/getting_started.md Execute interactive queries on the loaded graph using Gremlin and Cypher to count co-authored papers. The Cypher query requires the lang="cypher" parameter. ```python # get the endpoint for submitting interactive queries on graph g. interactive = graphscope.interactive(g, with_cypher=True) # Gremlin query for counting the number of papers two authors (with id 2 and 4307) have co-authored papers = interactive.execute("g.V().has('author', 'id', 2).out('writes').where(__.in('writes').has('id', 4307)).count()").one() # Cypher query for counting the number of papers two authors (with id 2 and 4307) have co-authored # Note that for Cypher query, the parameter of lang="cypher" is mandatory papers = interactive.execute( \ "MATCH (n1:author)-[:writes]->(p:paper)<-[:writes]-(n2:author) \ WHERE n1.id = 2 AND n2.id = 4307 \ RETURN count(DISTINCT p)", \ lang="cypher") ``` -------------------------------- ### Sample settings.yaml configuration Source: https://github.com/alibaba/graphscope/blob/main/docs/storage_engine/groot.md Example YAML configuration file for Groot Helm chart. Sets the image tag to 'latest' and configures the authentication username and password. ```yaml # cat settings.yaml --- image: tag: latest auth: username: admin password: 123456 ``` -------------------------------- ### Create and Verify vineyard-system Namespace Source: https://github.com/alibaba/graphscope/blob/main/docs/deployment/deploy_with_existing_vineyard_cluster.md Create the namespace 'vineyard-system' and verify it is active. The output shows the namespace was created successfully. ```bash $ kubectl create namespace vineyard-system namespace/vineyard-system created $ kubectl get namespace vineyard-system NAME STATUS AGE vineyard-system Active 33s ``` -------------------------------- ### GRIN vertex reference APIs and cross-partition usage Source: https://github.com/alibaba/graphscope/blob/main/docs/storage_engine/grin.md Shows how to obtain, serialize, deserialize, and cast a vertex reference across partitions. The example includes code for machine 1 (getting and serializing the reference) and machine 2 (deserializing and casting back to a vertex). ```CPP /* grin/partition/partition.h */ GRIN_VERTEX_REF grin_get_vertex_ref_for_vertex(GRIN_GRAPH, GRIN_VERTEX); const char* grin_serialize_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); GRIN_VERTEX_REF grin_deserialize_to_vertex_ref(GRIN_GRAPH, const char*); GRIN_VERTEX grin_get_vertex_from_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); /* run.cc in machine 1 */ { auto vref = grin_get_vertex_ref_for_vertex(g, v); // get v's vertex ref which can be recognized in machine 2 const char* msg = grin_serialize_vertex_ref(g, vref); // serialize into a message // send the message to machine 2... } /* run.cc in machine 2 */ { // receive the message from machine 1... auto vref = grin_deserialize_to_vertex_ref(g, msg); // deserialize back to vertex ref auto v = grin_get_vertex_from_vertex_ref(g, vref); // cast to vertex if g can recognize the vertex ref } ``` -------------------------------- ### Install dependent libraries Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/install_en.rst Installs build dependencies: autoconf, automake, libtool, cmake, and python-numpy. ```bash sudo apt-get install autoconf automake libtool cmake python-numpy ``` -------------------------------- ### Install build-essential for GAE Source: https://github.com/alibaba/graphscope/blob/main/docs/deployment/install_on_local.md Installs cmake and build-essential on Ubuntu to support on-the-fly compilation required by the Analytical Engine (GAE). ```bash apt update -y && apt install cmake build-essential -y ``` -------------------------------- ### Example build config file Source: https://github.com/alibaba/graphscope/blob/main/docs/storage_engine/groot.md Configuration file for the build step, recognized by java.util.Properties. Specifies split size, separator, input/output paths, graph endpoint, column mapping, and skip.header. When load.after.build=true, hadoop.endpoint is not required. ```default split.size=256 separator=\\\|\ninput.path=/tmp/ldbc_sample output.path=/tmp/data_output graph.endpoint=1.2.3.4:55555 column.mapping.config={"person_0_0.csv":{"label":"person","propertiesColMap":{"0":"id","1":"name"}},"person_knows_person_0_0.csv":{"label":"knows","srcLabel":"person","dstLabel":"person","srcPkColMap":{"0":"id"},"dstPkColMap":{"1":"id"},"propertiesColMap":{"2":"date"}}} skip.header=true load.after.build=true # This is not required when load.after.build=true # hadoop.endpoint=127.0.0.1:9000 ``` -------------------------------- ### Push Interactive Image to Own Registry and Deploy Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/interactive/deployment.md Tag and push the Interactive image to your own registry, then deploy an instance using that image. Replace placeholders with your registry and tag. ```bash docker tag graphscope/interactive:latest {YOUR_IMAGE_REGISTRY}/interactive:{TAG} docker push {YOUR_IMAGE_REGISTRY}/interactive:latest python3 gsctl.py instance deploy --type interactive --image-registry {YOUR_IMAGE_REGISTRY} --image-tag {TAG} ``` -------------------------------- ### Start Docker container for GOpt on Neo4j Source: https://github.com/alibaba/graphscope/blob/main/docs/interactive_engine/gopt.md Launches the Docker environment containing the gopt-on-neo4j package and all necessary dependencies. Use this if you lack a complete development environment. ```bash docker run -it registry.cn-hongkong.aliyuncs.com/graphscope/gopt-on-neo4j:latest bash ``` -------------------------------- ### Train EgoGraphSAGE model with GraphScope Source: https://github.com/alibaba/graphscope/blob/main/docs/learning_engine/getting_started.md Complete example that trains an EgoGraphSAGE model to classify nodes (papers) into 349 categories. It imports TensorFlow, loads the ogbn-mag graph, defines the training process, launches a learning engine, and runs training with a local trainer. ```python try: # https://www.tensorflow.org/guide/migrate import tensorflow.compat.v1 as tf tf.disable_v2_behavior() except ImportError: import tensorflow as tf import graphscope as gs from graphscope.dataset import load_ogbn_mag from graphscope.learning.examples import EgoGraphSAGE from graphscope.learning.examples import EgoSAGESupervisedDataLoader from graphscope.learning.examples.tf.trainer import LocalTrainer gs.set_option(show_log=True) # Define the training process of EgoGraphSAGE def train(graph, node_type, edge_type, class_num, features_num, hops_num=2, nbrs_num=[25, 10], epochs=2, hidden_dim=256, in_drop_rate=0.5, learning_rate=0.01 ): gs.learning.reset_default_tf_graph() dimensions = [features_num] + [hidden_dim] * (hops_num - 1) + [class_num] model = EgoGraphSAGE(dimensions, act_func=tf.nn.relu, dropout=in_drop_rate) # prepare training dataset train_data = EgoSAGESupervisedDataLoader( graph, gs.learning.Mask.TRAIN, node_type=node_type, edge_type=edge_type, nbrs_num=nbrs_num, hops_num=hops_num, ) train_embedding = model.forward(train_data.src_ego) train_labels = train_data.src_ego.src.labels loss = tf.reduce_mean( tf.nn.sparse_softmax_cross_entropy_with_logits( labels=train_labels, logits=train_embedding, ) ) optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate) # prepare test dataset test_data = EgoSAGESupervisedDataLoader( graph, gs.learning.Mask.TEST, node_type=node_type, edge_type=edge_type, nbrs_num=nbrs_num, hops_num=hops_num, ) test_embedding = model.forward(test_data.src_ego) test_labels = test_data.src_ego.src.labels test_indices = tf.math.argmax(test_embedding, 1, output_type=tf.int32) test_acc = tf.div( tf.reduce_sum(tf.cast(tf.math.equal(test_indices, test_labels), tf.float32)), tf.cast(tf.shape(test_labels)[0], tf.float32), ) # train and test trainer = LocalTrainer() trainer.train(train_data.iterator, loss, optimizer, epochs=epochs) trainer.test(test_data.iterator, test_acc) # load the obgn-mag graph as example. g = load_ogbn_mag() # define the features for learning. paper_features = [f"feat_{i}" for i in range(128)] # launch a learning engine. lg = gs.graphlearn( g, nodes=[("paper", paper_features)], edges=[("paper", "cites", "paper")], gen_labels=[ ("train", "paper", 100, (0, 75)), ("val", "paper", 100, (75, 85)), ("test", "paper", 100, (85, 100)) ] ) train(lg, node_type="paper", edge_type="cites", class_num=349, # output dimension features_num=128, # input dimension ) ``` -------------------------------- ### Launch learning engine and construct graph with features Source: https://github.com/alibaba/graphscope/blob/main/docs/overview/getting_started.md Defines 128 paper features plus the kcore and tc columns, then launches a learning engine with the sub_graph, specifying node and edge types and generating train/val/test labels with split percentages (0-75, 75-85, 85-100). ```python # define the features for learning paper_features = [f"feat_{i}" for i in range(128)] paper_features.append("kcore") paper_features.append("tc") # launch a learning engine. lg = graphscope.graphlearn(sub_graph, nodes=[("paper", paper_features)], edges=[("paper", "cites", "paper")], gen_labels=[ ("train", "paper", 100, (0, 75)), ("val", "paper", 100, (75, 85)), ("test", "paper", 100, (85, 100)) ]) ``` -------------------------------- ### Build for online BI analysis with flexbuild Source: https://github.com/alibaba/graphscope/blob/main/flex/README.md Builds a database application stack for online BI analysis using the components 'cypher', 'gaia', 'cppsp', and 'mcsr'. The command is run from the flex directory. Note that this case is marked as 'To be supported' and users are advised to try scripts for other cases. ```bash ./flexbuild cypher gaia cppsp mcsr --app db # To be supported. Please try scripts for other cases. ``` -------------------------------- ### Run CBO benchmark in profile and explain modes Source: https://github.com/alibaba/graphscope/blob/main/docs/interactive_engine/gopt.md Runs the CBO query set with profiling to print detailed results, or with explain to return the optimized plan without executing. ```bash ./bin/bench.sh ./queries/CBO --profile ./bin/bench.sh ./queries/CBO --explain ``` -------------------------------- ### Install Groot from a local directory using Helm Source: https://github.com/alibaba/graphscope/blob/main/docs/storage_engine/groot.md Clones the GraphScope repository, navigates to the chart directory, fetches dependency charts, and installs Groot with default configuration. ```bash cd GraphScope/charts/graphscope-store helm dependency update # fetch the dependency charts helm install demo . ``` -------------------------------- ### Example benchmark output for GIE and KuzuDB Source: https://github.com/alibaba/graphscope/blob/main/docs/interactive_engine/benchmark_tool.md Example results from running the JOB Benchmark with the example configuration file example/job_benchmark.properties, comparing GraphScope-GIE and KuzuDB. Shows per-query execution times and a summary line with query count, total execute time, and QPS. ```default Start to benchmark system: GIE QueryName[13a], Parameter[{}], ResultCount[1], ExecuteTimeMS[3638]. QueryName[32a], Parameter[{}], ResultCount[1], ExecuteTimeMS[266]. QueryName[9a], Parameter[{}], ResultCount[1], ExecuteTimeMS[3669]. QueryName[5c], Parameter[{}], ResultCount[1], ExecuteTimeMS[8603]. QueryName[3a], Parameter[{}], ResultCount[1], ExecuteTimeMS[613]. ... System: GIE; query count: 35; execute time(ms): xxx qps: xxx Start to benchmark system: KuzuDb QueryName[13a], Parameter[{}], ResultCount[1], ExecuteTimeMS[7068]. QueryName[32a], Parameter[{}], ResultCount[1], ExecuteTimeMS[253]. QueryName[9a], Parameter[{}], ResultCount[1], ExecuteTimeMS[5122]. QueryName[5c], Parameter[{}], ResultCount[1], ExecuteTimeMS[13623]. QueryName[3a], Parameter[{}], ResultCount[1], ExecuteTimeMS[4676]. ... System: KuzuDB; query count: 35; execute time(ms): xxx qps: xxx ``` -------------------------------- ### Install Python development dependencies Source: https://github.com/alibaba/graphscope/blob/main/docs/development/code_style_guide.md Install the required Python dependencies for style checking in the coordinator directory. ```bash $ pip3 install -r coordinator/requirements-dev.txt ``` -------------------------------- ### Connect and submit a query via Python SDK Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/interactive/development/python/python_sdk.md Create a Driver, open a Neo4j session, and run a Cypher query to count nodes. ```python from gs_interactive.client.driver import Driver from gs_interactive.client.session import Session from gs_interactive.models import * driver = Driver() with driver.getNeo4jSession() as session: result = session.run("MATCH(n) RETURN COUNT(n);") for record in result: print(record) ``` -------------------------------- ### Run iterative algorithm (SSSP) with GraphScope Source: https://github.com/alibaba/graphscope/blob/main/docs/overview/getting_started.md Loads the modern graph and runs label propagation (LPA) and single source shortest path (SSSP) algorithms. Requires the graphscope package and the modern graph dataset. The SSSP algorithm is run on a projected homogeneous graph with source vertex 1. ```python import graphscope as gs from graphscope.dataset.modern_graph import load_modern_graph gs.set_option(show_log=True) # load the modern graph as example. #(modern graph is an example property graph given by Apache at https://tinkerpop.apache.org/docs/current/tutorials/getting-started/) graph = load_modern_graph() # triggers label propagation algorithm(LPA) # on the modern graph(property graph) and print the result. ret = gs.lpa(graph) print(ret.to_dataframe(selector={'id': 'v.id', 'label': 'r'})) # project a modern graph (property graph) to a homogeneous graph # and run single source shortest path(SSSP) algorithm on it, with assigned source=1. pg = graph.project(vertices={'person': None}, edges={'knows': ['weight']}) ret = gs.sssp(pg, src=1) print(ret.to_dataframe(selector={'id': 'v.id', 'distance': 'r'}) ``` -------------------------------- ### Start Neo4j and run verification queries Source: https://github.com/alibaba/graphscope/blob/main/docs/interactive_engine/gopt.md Starts the Neo4j service, opens the Cypher shell, and runs commands to check the graph model and data counts. The commands include 'call apoc.meta.graph();' and two match queries. ```bash ./bin/neo4j start # wait until neo4j service started ... ./bin/cypher-shell # check graph model call apoc.meta.graph(); # check data Match (a) Return count(a); Match (a)-[b]->(c) Return count(b); ``` -------------------------------- ### Install dependencies and build Coordinator with gsctl Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/coordinator/development/dev_and_test.md Installs the gsctl utility, installs the minimal 'dev-learning' dependency set for Coordinator, then builds Coordinator from source. Requires Python and pip. ```bash pip3 install gsctl # install coordinator dependencies # dev-learning is the minimal set of dependencies to build coordinator gsctl install-deps dev-learning # build cd GraphScope && make coordinator ``` -------------------------------- ### Install gs_interactive via pip Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/interactive/development/python/python_sdk.md Install the Interactive Python SDK package using pip. Requires Python >= 3.8. ```bash pip3 install gs_interactive ``` -------------------------------- ### Start the Graph Planner RESTful service Source: https://github.com/alibaba/graphscope/blob/main/docs/interactive_engine/graph_planner.md Starts the RESTful service using the Spring configuration file located at ./conf/application.yaml. ```bash java -cp ".:./libs/*" com.alibaba.graphscope.sdk.restful.GraphPlannerService --spring.config.location=./conf/application.yaml ``` -------------------------------- ### Generate configuration file and start Coordinator Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/coordinator/development/dev_and_test.md Creates a configuration file for the Coordinator with HTTP port 8080 and launches it with the Interactive solution. The configuration sets launcher_type to hosts and session instance_id to demo. ```bash cat > /tmp/config.yaml << EOF coordinator: http_port: 8080 launcher_type: hosts session: instance_id: demo EOF ``` ```bash export SOLUTION=INTERACTIVE python3 -m gscoordinator --config-file /tmp/config.yaml ``` -------------------------------- ### Install GIE standalone from remote Helm repo Source: https://github.com/alibaba/graphscope/blob/main/charts/gie-standalone/README.md Updates the Helm repository and installs the gie-standalone chart with a custom release name. ```bash helm repo update helm install graphscope/gie-standalone ``` -------------------------------- ### StartService: start_service() example Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/interactive/development/python/ServiceManagementApi.md Starts a service on a specified graph using a StartServiceRequest object. The response is a Result[str] object; the example asserts success and prints the value. ```python resp = sess.start_service( start_service_request=StartServiceRequest(graph_id=graph_id) ) assert resp.is_ok() print("restart service result: ", resp.get_value()) ``` -------------------------------- ### Close the connection Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/coordinator/getting_started.md Disconnect from the coordinator service. ```bash gsctl close ``` -------------------------------- ### Graph Construction with graphlearn (gl.Graph, .node(), .edge(), .init()) Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/quick_start_en.rst Loads vertex and edge data into memory using the graphlearn library. Configures parameters for the Cora dataset, defines a graph object, adds node and edge data with decoders, and initializes the graph. This is a local example; for distributed usage, see the Graph Object#Initialization documentation. ```python import graphlearn as gl # Configure the parameters N_CLASS = 7 N_FEATURE = 1433 BATCH_SIZE = 140 HIDDEN_DIM = 128 N_HOP = 2 HOPS = [10, 5] N_EPOCHES = 2 DEPTH = 2 # Define a graph object g = gl.Graph() # Add the vertex data into the graph through `.node()` and define the node type ("item") and data format. # Add the edge data into the graph through `.edge()` and define its type through a triple (source vertex type, destination vertex type, edge type). g.node("examples/data/cora/node_table", node_type="item", decoder=gl.Decoder(labeled=True, attr_types=["float"] * N_FEATURE)) \ .edge("examples/data/cora/edge_table", edge_type=("item", "item", "relation"), decoder=gl.Decoder(weighted=True), directed=False) \ # Construct the graph. This is a local example. For the distributed example, see [Graph Object#Initialization](graph_object_cn.md)。 g.init() ``` -------------------------------- ### Example config file for data building Source: https://github.com/alibaba/graphscope/blob/main/interactive_engine/data-load-tool/README.md Configuration file example for the build command. It specifies split size, separator, input/output paths, graph endpoint, column mappings, and skip.header. The hadoop.endpoint is commented out because it is not required when load.after.build=true. ```properties split.size=256 separator=\\\| input.path=/tmp/ldbc_sample output.path=/tmp/data_output graph.endpoint=1.2.3.4:55555 column.mapping.config={"person_0_0.csv":{"label":"person","propertiesColMap":{"0":"id","1":"name"}},"person_knows_person_0_0.csv":{"label":"knows","srcLabel":"person","dstLabel":"person","srcPkColMap":{"0":"id"},"dstPkColMap":{"1":"id"},"propertiesColMap":{"2":"date"}}} skip.header=true load.after.build=true # This is not required when load.after.build=true # hadoop.endpoint=127.0.0.1:9000 ``` -------------------------------- ### Run GraphScope in Docker container Source: https://github.com/alibaba/graphscope/blob/main/docs/deployment/install_on_local.md Starts a Docker container with a large shared memory size, then installs Python, JDK, and GraphScope inside it. Useful for a clean environment. ```bash docker run --name dev -it --shm-size=4096m ubuntu:latest # inside the docker apt-get update -y && apt-get install python3-pip default-jdk -y python3 -m pip install graphscope ipython tensorflow ``` -------------------------------- ### Run integration tests with tox Source: https://github.com/alibaba/graphscope/blob/main/flex/interactive/sdk/master/README.md Install tox and run the integration tests. ```bash sudo pip install tox tox ``` -------------------------------- ### Configure volumes for loading graph in GraphScope Source: https://github.com/alibaba/graphscope/blob/main/charts/graphscope/README.md Mounts a hostPath volume into the pod and passes the values file during installation. The example mounts `/testingdata` to `/tmp/testingdata`. ```yaml # Mount hostpath `/testingdata` to `/tmp/testingdata` in pod. # cat values.yaml # volumes: enabled: true items: data: type: hostPath field: type: Directory path: /testingdata mounts: - mountPath: /tmp/testingdata ``` ```shell # pass that values file during installation. $ helm install -f values.yaml graphscope/graphscope --generate-name ``` -------------------------------- ### Configure pre-commit hooks Source: https://github.com/alibaba/graphscope/blob/main/docs/development/how_to_contribute.md Sets up the necessary pre-commit hooks after installation. This is required before contributing to ensure secret checks are active. ```bash $ pre-commit install --install-hooks ``` -------------------------------- ### Install development dependencies with gsctl Source: https://github.com/alibaba/graphscope/blob/main/docs/development/dev_guide.md Use the gsctl command-line utility to install all dependencies for development. The command is `gsctl install-deps dev`. For more usage, try `gsctl install-deps -h`. ```bash # pip3 install gsctl gsctl install-deps dev # for more usage, try # gsctl install-deps -h ``` -------------------------------- ### Download pvc.yaml Source: https://github.com/alibaba/graphscope/blob/main/charts/gie-standalone/README.md Downloads the PersistentVolumeClaim manifest. The link is a placeholder to be updated after merging to main. ```bash # TODO: the link need to be updated after merging to main curl -O -S https://raw.githubusercontent.com/shirly121/GraphScope/add_gie_deploy/charts/gie-standalone/tools/pvc.yaml ``` -------------------------------- ### Build the project with Maven Source: https://github.com/alibaba/graphscope/blob/main/docs/interactive_engine/graph_planner.md Navigate to the interactive_engine directory and build the package using Maven, skipping tests and activating the graph-planner-jni profile. ```bash cd interactive_engine mvn clean package -DskipTests -Pgraph-planner-jni ``` -------------------------------- ### Clone and build Giraph examples Source: https://github.com/alibaba/graphscope/blob/main/docs/analytical_engine/tutorial_run_giraph_apps.md Clones the Apache Giraph repository and builds the giraph-examples module with Maven, producing a jar with dependencies. ```bash git clone https://github.com/apache/giraph.git cd giraph/ mvn package -pl :giraph-examples ``` -------------------------------- ### Launch distributed GL processes Source: https://github.com/alibaba/graphscope/blob/main/docs/reference/gnn_engine/quick_start_en.rst Shell script that starts two server and two client processes locally to simulate a distributed setting. It requires gen_test_data.py and test.py in the same directory. ```shell HERE=$(cd "$(dirname "$0")";pwd) rm -rf $HERE/.tmp/tracker mkdir -p $HERE/.tmp/tracker if [ ! -d "$HERE/data" ]; then mkdir -p $HERE/data python $HERE/gen_test_data.py # 你需要把gen_test_data.py、test.py放到shell脚本同一目录下 fi python $HERE/test.py \ --cluster="{\"client_count\": 2, \"server_count\": 2, \"tracker\": \"$HERE/.tmp/tracker\"}" \ --job_name="server" --task_index=0 & sleep 1 python $HERE/test.py \ --cluster="{\"client_count\": 2, \"server_count\": 2, \"tracker\": \"$HERE/.tmp/tracker\"}" \ --job_name="server" --task_index=1 & sleep 1 python $HERE/test.py \ --cluster="{\"client_count\": 2, \"server_count\": 2, \"tracker\": \"$HERE/.tmp/tracker\"}" \ --job_name="client" --task_index=0 & sleep 1 python $HERE/test.py \ --cluster="{\"client_count\": 2, \"server_count\": 2, \"tracker\": \"$HERE/.tmp/tracker\"}" \ --job_name="client" --task_index=1 ``` -------------------------------- ### Clone repository and enter analytical_engine directory Source: https://github.com/alibaba/graphscope/blob/main/docs/analytical_engine/dev_and_test.md Clones the GraphScope repository and changes into the analytical_engine directory. Run after setting up the development environment. ```bash git clone https://github.com/alibaba/GraphScope.git cd analytical_engine ``` -------------------------------- ### GetServiceStatus example Source: https://github.com/alibaba/graphscope/blob/main/docs/flex/interactive/development/java/ServiceManagementApi.md Retrieves the current status of the query service using the GET /v1/service/status endpoint. The example connects to the interactive admin endpoint, calls getServiceStatus(), and prints the status or an error message if the request fails. ```java // Import classes: import com.alibaba.graphscope.interactive.client.Driver; import com.alibaba.graphscope.interactive.client.Session; import com.alibaba.graphscope.interactive.client.common.Result; import com.alibaba.graphscope.interactive.models.ServiceStatus; public class Example { public static void main(String[] args) { Driver driver = Driver.connect(); Session session = driver.session(); //get service status Result status = session.getServiceStatus(); if (!status.isOk()) { System.out.println("Failed to get service status: " + status.getStatusMessage()); } else { System.out.println("Service status: " + status.getValue()); } } } ``` -------------------------------- ### Install development dependencies by cloning GraphScope Source: https://github.com/alibaba/graphscope/blob/main/docs/development/dev_guide.md Alternative method to install dependencies by cloning the GraphScope repository and running the gsctl script from the root directory. The command is `python3 gsctl.py install-deps dev`. ```bash # git clone https://github.com/alibaba/GraphScope.git cd GraphScope && python3 gsctl.py install-deps dev ``` -------------------------------- ### sample() Source: https://github.com/alibaba/graphscope/blob/main/docs/interactive_engine/tinkerpop/supported_gremlin_steps.md Generates a certain number of sample results from the traversal stream. ```APIDOC ## [sample()] ### Description Generate a certain number of sample results. ### Method sample() ### Parameters - **number** (number) - Required - Allow specified number of objects to pass through the stream. ### Request Example ```bash g.V().sample(10) g.V().out().sample(10) ``` ### Response Returns a sample of the specified number of objects. ``` -------------------------------- ### Configure resource requests and limits for GraphScope components Source: https://github.com/alibaba/graphscope/blob/main/charts/graphscope/README.md Adjusts CPU/memory for coordinator, engines, vineyard, and etcd. The example shows default values and passes the values file during installation. ```yaml # cat values.yaml coordinator: resources: requests: cpu: 3.0 memory: 4Gi limits: cpu: 3.0 memory: 4Gi # one engine pod contains a engine container and a vineyard container engines: resources: requests: cpu: 2.0 memory: 4Gi limits: cpu: 2.0 memory: 4Gi vineyard: resources: requests: cpu: 0.5 memory: 512Mi limits: cpu: 0.5 memory: 512Mi ## Init size of vineyard shared memory. shared_mem: 8Gi etcd: resources: requests: cpu: 0.5 memory: 128Mi limits: cpu: 0.5 memory: 128Mi ``` ```shell # pass that values file during installation. $ helm install -f values.yaml graphscope/graphscope --generate-name ```