Skip to content

Commit ab03413

Browse files
authored
Merge branch 'main' into ir_case_when
2 parents bcd1207 + 92da638 commit ab03413

File tree

20 files changed

+225
-103
lines changed

20 files changed

+225
-103
lines changed

.github/workflows/docs.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- dev/docs
1010
tags:
1111
- "v*"
12-
pull_request_target:
12+
pull_request:
1313
branches:
1414
- main
1515
- docs
@@ -26,8 +26,8 @@ jobs:
2626
- name: Checkout Code
2727
uses: actions/checkout@v3
2828
with:
29-
repository: ${{github.event.pull_request.head.repo.full_name}}
30-
ref: ${{github.event.pull_request.head.ref}}
29+
repository: ${{ github.event.pull_request.head.repo.full_name }}
30+
ref: ${{ github.event.pull_request.head.ref }}
3131
submodules: true
3232
fetch-depth: 0
3333

@@ -49,12 +49,12 @@ jobs:
4949
node-version: 16
5050

5151
- name: Leave a marker
52-
if: ${{ steps.changes.outputs.src == 'true' && github.event_name == 'pull_request_target' }}
52+
if: ${{ steps.changes.outputs.src == 'true' && github.event_name == 'pull_request' }}
5353
run: |
5454
touch ${GITHUB_WORKSPACE}/preview-the-docs.mark
5555
5656
- name: Leave the comment on pull request when started
57-
if: ${{ steps.changes.outputs.src == 'true' && github.event_name == 'pull_request_target' }}
57+
if: ${{ steps.changes.outputs.src == 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'alibaba/GraphScope' }}
5858
uses: actions-cool/maintain-one-comment@v3
5959
with:
6060
token: ${{ secrets.GITHUB_TOKEN }}
@@ -171,15 +171,15 @@ jobs:
171171
fi
172172
173173
- name: Preview using surge
174-
if: ${{ steps.changes.outputs.src == 'true' && github.event_name == 'pull_request_target' }}
174+
if: ${{ steps.changes.outputs.src == 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'alibaba/GraphScope' }}
175175
run: |
176176
npm install -g surge
177177
surge ./docs/_build/latest/html \
178178
alibaba-graphscope-build-pr-${{ github.event.number }}.surge.sh \
179179
--token ${{ secrets.SURGE_TOKEN }}
180180
181181
- name: Leave the comment on pull request when succeed
182-
if: ${{ steps.changes.outputs.src == 'true' && github.event_name == 'pull_request_target' }}
182+
if: ${{ steps.changes.outputs.src == 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'alibaba/GraphScope' }}
183183
uses: actions-cool/maintain-one-comment@v3
184184
with:
185185
token: ${{ secrets.GITHUB_TOKEN }}
@@ -201,7 +201,7 @@ jobs:
201201
files: "preview-the-docs.mark"
202202

203203
- name: Leave the comment on pull request when failed
204-
if: ${{ failure() && steps.check_files.outputs.files_exists == 'true' }}
204+
if: ${{ failure() && steps.check_files.outputs.files_exists == 'true' && github.event.pull_request.head.repo.full_name == 'alibaba/GraphScope' }}
205205
uses: actions-cool/maintain-one-comment@v3
206206
with:
207207
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/gss.yml

+2-19
Original file line numberDiff line numberDiff line change
@@ -149,23 +149,6 @@ jobs:
149149
docker build -t ${{ env.GSS_IMAGE }}:${SHORT_SHA} \
150150
-f .github/workflows/docker/graphscope-store.Dockerfile .
151151
152-
- name: Prepare the log directory
153-
run: |
154-
# create the helm installation log directory
155-
mkdir -p ${{ github.workspace }}/k8s-ci-helm-installation-logs
156-
157-
# create the demo fresh of helm installation log directory
158-
mkdir -p ${{ github.workspace }}/k8s-ci-demo-fresh-of-helm-installation-logs
159-
160-
# create the demo script of helm installation with pv log directory
161-
mkdir -p ${{ github.workspace }}/k8s-ci-demo-script-of-helm-installation-with-pv-logs
162-
163-
# create the helm test of helm installation with pv log directory
164-
mkdir -p ${{ github.workspace }}/k8s-ci-helm-test-of-helm-installation-with-pv-logs
165-
166-
# create the demo after restart of helm installation with pv log directory
167-
mkdir -p ${{ github.workspace }}/k8s-ci-demo-after-restart-of-helm-installation-with-pv-logs
168-
169152
- name: Setup SSH
170153
run: |
171154
ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ''
@@ -263,10 +246,10 @@ jobs:
263246
MODE: stop
264247

265248
- name: upload the k8s logs to artifact
266-
if: ${{ always() }}
249+
if: ${{ failure() }}
267250
uses: actions/upload-artifact@v3
268251
continue-on-error: true
269252
with:
270253
name: k8s-test-logs
271-
path: ${{ github.workspace }}/k8s-ci-*-logs
254+
path: ${{ github.workspace }}/helm-installation-logs
272255

charts/graphscope-store/values.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ image:
2525
registry: registry.cn-hongkong.aliyuncs.com
2626
repository: graphscope/graphscope-store
2727
# Overrides the image tag whose default is the chart appVersion.
28-
tag: "0.22.0"
28+
tag: "0.23.0"
2929
digest: ""
3030
## Specify a imagePullPolicy
3131
## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'

coordinator/gscoordinator/cluster_builder.py

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1+
#! /usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright 2020-2023 Alibaba Group Holding Limited.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
119
import base64
220
import json
321
import logging
422
import os
523

624
try:
725
from kubernetes import client as kube_client
8-
from kubernetes import config as kube_config
9-
from kubernetes import watch as kube_watch
10-
from kubernetes.client import AppsV1Api
11-
from kubernetes.client import CoreV1Api
12-
from kubernetes.client.rest import ApiException as K8SApiException
13-
from kubernetes.config import ConfigException as K8SConfigException
1426
except ImportError:
1527
kube_client = None
16-
kube_config = None
17-
kube_watch = None
18-
AppsV1Api = None
19-
CoreV1Api = None
20-
K8SApiException = None
21-
K8SConfigException = None
22-
23-
from pprint import pprint
2428

2529
from graphscope.deploy.kubernetes.resource_builder import ResourceBuilder
2630
from graphscope.deploy.kubernetes.utils import get_service_endpoints

docs/images/gsflex-case1.png

55.6 KB
Loading

docs/images/gsflex-case2.png

55.7 KB
Loading

docs/images/gsflex-case3.png

54.3 KB
Loading

docs/images/gsflex-case4.png

54.5 KB
Loading

docs/images/gsflex-overview.png

72.5 KB
Loading

docs/overview/getting_started.md

+87-5
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Graph neural networks (GNNs) combines superiority of both graph analytics and ma
116116

117117
````{dropdown} Prepare data and engine for learning
118118
119-
In our example, we train a Graph Convolutional Network (GCN) model to classify the nodes (papers) into 349 categories, each representing a venue (e.g., pre-print or conference). To accomplish this, we first launch a learning engine and construct a graph with features, following the previous step.
119+
In our example, we train a supervised GraphSAGE model to classify the nodes (papers) into 349 categories, each representing a venue (e.g., pre-print or conference). To accomplish this, we first launch a learning engine and construct a graph with features, following the previous step.
120120
121121
```python
122122
# define the features for learning
@@ -153,8 +153,8 @@ from graphscope.learning.examples import EgoGraphSAGE
153153
from graphscope.learning.examples import EgoSAGESupervisedDataLoader
154154
from graphscope.learning.examples.tf.trainer import LocalTrainer
155155
156-
# supervised GCN.
157-
def train_gcn(graph, node_type, edge_type, class_num, features_num,
156+
# supervised GraphSAGE.
157+
def train_sage(graph, node_type, edge_type, class_num, features_num,
158158
hops_num=2, nbrs_num=[25, 10], epochs=2,
159159
hidden_dim=256, in_drop_rate=0.5, learning_rate=0.01,
160160
):
@@ -195,7 +195,7 @@ def train_gcn(graph, node_type, edge_type, class_num, features_num,
195195
trainer.train(train_data.iterator, loss, optimizer, epochs=epochs)
196196
trainer.test(test_data.iterator, test_acc)
197197
198-
train_gcn(lg, node_type="paper", edge_type="cites",
198+
train_sage(lg, node_type="paper", edge_type="cites",
199199
class_num=349, # output dimension
200200
features_num=130, # input dimension, 128 + kcore + triangle count
201201
)
@@ -265,7 +265,89 @@ print(q2.all().result()) # should print [[v[2], v[3], v[0], v[1]]]
265265

266266

267267
## Graph Learning Quick Start
268+
GNN model training with GraphScope is easy and straightforward. You can use the `graphscope` package to train a GNN model on your local machine. Note that
269+
`tensorflow` is required to run the following example.
268270

269-
TODO(LiSu):
271+
````{dropdown} Example: Training GraphSAGE Model in GraphScope
272+
```python
273+
274+
import graphscope
275+
from graphscope.dataset import load_ogbn_mag
276+
277+
g = load_ogbn_mag()
278+
279+
# define the features for learning
280+
paper_features = [f"feat_{i}" for i in range(128)]
281+
282+
# launch a learning engine.
283+
lg = graphscope.graphlearn(g, nodes=[("paper", paper_features)],
284+
edges=[("paper", "cites", "paper")],
285+
gen_labels=[
286+
("train", "paper", 100, (0, 75)),
287+
("val", "paper", 100, (75, 85)),
288+
("test", "paper", 100, (85, 100))
289+
])
290+
291+
try:
292+
# https://www.tensorflow.org/guide/migrate
293+
import tensorflow.compat.v1 as tf
294+
tf.disable_v2_behavior()
295+
except ImportError:
296+
import tensorflow as tf
297+
298+
import graphscope.learning
299+
from graphscope.learning.examples import EgoGraphSAGE
300+
from graphscope.learning.examples import EgoSAGESupervisedDataLoader
301+
from graphscope.learning.examples.tf.trainer import LocalTrainer
302+
303+
# supervised GraphSAGE
304+
def train_sage(graph, node_type, edge_type, class_num, features_num,
305+
hops_num=2, nbrs_num=[25, 10], epochs=2,
306+
hidden_dim=256, in_drop_rate=0.5, learning_rate=0.01,
307+
):
308+
graphscope.learning.reset_default_tf_graph()
309+
310+
dimensions = [features_num] + [hidden_dim] * (hops_num - 1) + [class_num]
311+
model = EgoGraphSAGE(dimensions, act_func=tf.nn.relu, dropout=in_drop_rate)
312+
313+
# prepare train dataset
314+
train_data = EgoSAGESupervisedDataLoader(
315+
graph, graphscope.learning.Mask.TRAIN,
316+
node_type=node_type, edge_type=edge_type, nbrs_num=nbrs_num, hops_num=hops_num,
317+
)
318+
train_embedding = model.forward(train_data.src_ego)
319+
train_labels = train_data.src_ego.src.labels
320+
loss = tf.reduce_mean(
321+
tf.nn.sparse_softmax_cross_entropy_with_logits(
322+
labels=train_labels, logits=train_embedding,
323+
)
324+
)
325+
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate)
326+
327+
# prepare test dataset
328+
test_data = EgoSAGESupervisedDataLoader(
329+
graph, graphscope.learning.Mask.TEST,
330+
node_type=node_type, edge_type=edge_type, nbrs_num=nbrs_num, hops_num=hops_num,
331+
)
332+
test_embedding = model.forward(test_data.src_ego)
333+
test_labels = test_data.src_ego.src.labels
334+
test_indices = tf.math.argmax(test_embedding, 1, output_type=tf.int32)
335+
test_acc = tf.div(
336+
tf.reduce_sum(tf.cast(tf.math.equal(test_indices, test_labels), tf.float32)),
337+
tf.cast(tf.shape(test_labels)[0], tf.float32),
338+
)
339+
340+
# train and test
341+
trainer = LocalTrainer()
342+
trainer.train(train_data.iterator, loss, optimizer, epochs=epochs)
343+
trainer.test(test_data.iterator, test_acc)
344+
345+
train_sage(lg, node_type="paper", edge_type="cites",
346+
class_num=349, # output dimension
347+
features_num=128, # input dimension
348+
)
349+
350+
```
351+
````
270352

271353

interactive_engine/compiler/src/main/antlr4/GremlinGS.g4

+10-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ traversalMethod
6161
| traversalMethod_inE // inE()[.outV()]
6262
| traversalMethod_bothE // bothE()[.otherV()]
6363
| traversalMethod_limit // limit()
64-
| traversalMethod_valueMap // valueMap()
64+
| traversalMethod_valueMap // valueMap()
65+
| traversalMethod_elementMap // elementMap()
6566
| traversalMethod_order // order()
6667
| traversalMethod_select // select()
6768
| traversalMethod_dedup // dedup()
@@ -199,6 +200,12 @@ traversalMethod_valueMap
199200
: 'valueMap' LPAREN stringLiteralList RPAREN
200201
;
201202

203+
// elementMap()
204+
// elementMap('s1', ...)
205+
traversalMethod_elementMap
206+
: 'elementMap' LPAREN stringLiteralList RPAREN
207+
;
208+
202209
// order()
203210
// order().by
204211
traversalMethod_order
@@ -238,12 +245,14 @@ traversalMethod_select
238245
// by()
239246
// by("name")
240247
// by(valueMap())
248+
// by(elementMap())
241249
// by(out().count())
242250
// by(T.label/T.id)
243251
traversalMethod_selectby
244252
: 'by' LPAREN RPAREN
245253
| 'by' LPAREN stringLiteral RPAREN
246254
| 'by' LPAREN (ANON_TRAVERSAL_ROOT DOT)? traversalMethod_valueMap RPAREN
255+
| 'by' LPAREN (ANON_TRAVERSAL_ROOT DOT)? traversalMethod_elementMap RPAREN
247256
| 'by' LPAREN nestedTraversal RPAREN
248257
| 'by' LPAREN traversalToken RPAREN
249258
;

interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/InterOpCollectionBuilder.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public InterOpCollection build() throws OpArgIllegalException, UnsupportedStepEx
7575
} else if (Utils.equalClass(step, PropertiesStep.class)
7676
|| Utils.equalClass(step, PropertyMapStep.class)
7777
|| Utils.equalClass(step, LabelStep.class)
78-
|| Utils.equalClass(step, IdStep.class)) {
78+
|| Utils.equalClass(step, IdStep.class)
79+
|| Utils.equalClass(step, ElementMapStep.class)) {
7980
opList.add(StepTransformFactory.VALUES_STEP.apply(step));
8081
} else if (Utils.equalClass(step, IsStep.class)) {
8182
opList.add(StepTransformFactory.IS_STEP.apply(step));

interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/antlr4/TraversalMethodVisitor.java

+16
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ public Traversal visitTraversalMethod_valueMap(
279279
GenericLiteralVisitor.getStringLiteralList(ctx.stringLiteralList()));
280280
}
281281

282+
@Override
283+
public Traversal visitTraversalMethod_elementMap(
284+
GremlinGSParser.TraversalMethod_elementMapContext ctx) {
285+
return graphTraversal.elementMap(
286+
GenericLiteralVisitor.getStringLiteralList(ctx.stringLiteralList()));
287+
}
288+
282289
@Override
283290
public Traversal visitTraversalMethod_select(
284291
GremlinGSParser.TraversalMethod_selectContext ctx) {
@@ -335,6 +342,15 @@ public Traversal visitTraversalMethod_select(
335342
nestedVisitor.visitTraversalMethod_valueMap(
336343
byCtx.traversalMethod_valueMap());
337344
step.modulateBy(nestedTraversal.asAdmin());
345+
} else if (byCtx.traversalMethod_elementMap()
346+
!= null) { // select(..).by(elementMap('name'))
347+
TraversalMethodVisitor nestedVisitor =
348+
new TraversalMethodVisitor(
349+
gvisitor, GremlinAntlrToJava.getTraversalSupplier().get());
350+
Traversal nestedTraversal =
351+
nestedVisitor.visitTraversalMethod_elementMap(
352+
byCtx.traversalMethod_elementMap());
353+
step.modulateBy(nestedTraversal.asAdmin());
338354
} else if (byChildCount == 4
339355
&& byCtx.nestedTraversal() != null) { // select(..).by(out().count())
340356
Traversal nestedTraversal = visitNestedTraversal(byCtx.nestedTraversal());

interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/graph/RemoteTestGraph.java

+8
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,14 @@
15071507
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest",
15081508
method = "g_EX11X",
15091509
reason = "unsupported")
1510+
@Graph.OptOut(
1511+
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ElementMapTest",
1512+
method = "g_EX11X_elementMap",
1513+
reason = "cannot get label and id for out and in vertices")
1514+
@Graph.OptOut(
1515+
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ElementMapTest",
1516+
method = "g_V_elementMap",
1517+
reason = "cannot get label and id for out and in vertices")
15101518
// @Graph.OptOut(
15111519
// test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ValueMapTest",
15121520
// method = "g_V_valueMapXname_ageX",

interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/suite/standard/IrGremlinTestSuite.java

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public class IrGremlinTestSuite extends AbstractGremlinSuite {
6464
VertexTest.Traversals.class,
6565
UnfoldTest.Traversals.class,
6666
ValueMapTest.Traversals.class,
67+
ElementMapTest.Traversals.class,
6768
GroupTest.Traversals.class,
6869
GroupCountTest.Traversals.class,
6970

@@ -100,6 +101,7 @@ public class IrGremlinTestSuite extends AbstractGremlinSuite {
100101
VertexTest.Traversals.class,
101102
UnfoldTest.Traversals.class,
102103
ValueMapTest.Traversals.class,
104+
ElementMapTest.Traversals.class,
103105
GroupTest.Traversals.class,
104106
GroupCountTest.Traversals.class,
105107

interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/result/GremlinResultAnalyzer.java

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public static GremlinResultParser analyze(Traversal traversal) {
5353
|| Utils.equalClass(step, SelectStep.class)
5454
|| Utils.equalClass(step, PropertiesStep.class)
5555
|| Utils.equalClass(step, PropertyMapStep.class)
56+
|| Utils.equalClass(step, ElementMapStep.class)
5657
|| Utils.equalClass(step, TraversalMapStep.class)
5758
|| Utils.equalClass(step, MatchStep.class)
5859
|| Utils.equalClass(step, ExprStep.class)

0 commit comments

Comments
 (0)