Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(interactive): Implement HttpIrMetaReader to Get Meta Data From Remote Http Service #3908

Merged
merged 44 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6336844
[GIE Compiler] support reading ir meta from meta service by http api
shirly121 May 29, 2024
5582553
remove useless files
shirly121 May 29, 2024
d35c5bb
minor fix
shirly121 May 29, 2024
f785414
[GIE Compiler] support reading graph statistics using meta sdk
shirly121 May 30, 2024
3513782
minor fix
shirly121 May 30, 2024
6c3a32a
refine reading statistics interface
shirly121 May 31, 2024
e9e7b5a
todo: after merge the get_statistics pr, fix the ci
zhanglei1949 Jun 3, 2024
49d7d5f
Merge branch 'main' into ir_get_meta
shirly121 Jun 6, 2024
83e3a31
add necessary config for irConfigs
BingqingLyu Jun 6, 2024
e1292e2
add necessary config for irConfigs
BingqingLyu Jun 6, 2024
675db21
Merge remote-tracking branch 'origin/main' into ir_get_meta
shirly121 Jun 11, 2024
0e72f83
Merge branch 'ir_get_meta' of github.com:shirly121/GraphScope into ir…
shirly121 Jun 11, 2024
dc6ba31
fix ci
zhanglei1949 Jun 12, 2024
906766f
Merge branch 'main' into ir_get_meta
zhanglei1949 Jun 12, 2024
53eab57
[GIE Compiler] refine according to reviews
shirly121 Jun 13, 2024
6996274
fix ci issues
shirly121 Jun 13, 2024
063fa0e
minor fix
shirly121 Jun 13, 2024
dcf0f8d
minor fix
shirly121 Jun 13, 2024
229d92e
minor fix
shirly121 Jun 13, 2024
fb6c702
Merge branch 'main' into ir_get_meta
zhanglei1949 Jun 13, 2024
77f2bb0
fixing ci
zhanglei1949 Jun 13, 2024
c719c21
Merge branch 'main' into ir_get_meta
longbinlai Jun 13, 2024
867cdde
Merge branch 'main' into ir_get_meta
BingqingLyu Jun 14, 2024
c53a009
minor refine config
BingqingLyu Jun 14, 2024
3072239
fix ci tests
shirly121 Jun 14, 2024
7e9d687
Merge branch 'ir_get_meta' of github.com:shirly121/GraphScope into ir…
shirly121 Jun 14, 2024
8ec0447
fixing hqps ci
zhanglei1949 Jun 14, 2024
076ffec
minor fix
shirly121 Jun 14, 2024
3e22d82
Merge branch 'ir_get_meta' of github.com:shirly121/GraphScope into ir…
shirly121 Jun 14, 2024
ba4d2d7
minor refine
BingqingLyu Jun 14, 2024
1912d5f
Merge branch 'main' into ir_get_meta
longbinlai Jun 14, 2024
23a0509
Merge branch 'main' into ir_get_meta
zhanglei1949 Jun 14, 2024
64dd138
Merge branch 'main' into ir_get_meta
BingqingLyu Jun 14, 2024
aa256f8
fix packaging
zhanglei1949 Jun 14, 2024
767303b
Merge branch 'main' into ir_get_meta
zhanglei1949 Jun 14, 2024
4a6c36d
minor update in values.yaml
BingqingLyu Jun 17, 2024
5cb7940
Merge branch 'main' into ir_get_meta
BingqingLyu Jun 19, 2024
e5b41a7
Merge branch 'main' into ir_get_meta
zhanglei1949 Jun 20, 2024
9d14d68
Merge branch 'main' into ir_get_meta
BingqingLyu Jun 24, 2024
eea8a78
fix: set snapshot id as the latest in frontend cache, to avoid incons…
BingqingLyu Jun 25, 2024
0b94c17
Merge branch 'main' into ir_get_meta
zhanglei1949 Jun 25, 2024
bca39bb
fixing ci
zhanglei1949 Jun 25, 2024
ef92dc9
Merge branch 'main' into ir_get_meta
zhanglei1949 Jun 25, 2024
4736052
fix
zhanglei1949 Jun 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/interactive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ jobs:
./tests/hqps/query_test ${GS_TEST_DIR}/flex/ldbc-sf01-long-date/audit_graph_schema.yaml \
/tmp/csr-data-dir/

- name: Test get graph meta from admin service
env:
GS_TEST_DIR: ${{ github.workspace }}/gstest
INTERACTIVE_WORKSPACE: /tmp/interactive_workspace
run: |
cd ${GITHUB_WORKSPACE}/flex/tests/hqps
sed -i 's/default_graph: ldbc/default_graph: modern_graph/g' ./engine_config_test.yaml
sed -i 's/mode: local/mode: http/g' ./engine_config_test.yaml
pip3 install argparse
pip3 install neo4j >= 4.4.19
bash hqps_compiler_get_meta_test.sh ${INTERACTIVE_WORKSPACE} ./engine_config_test.yaml
sed -i 's/mode: http/mode: local/g' ./engine_config_test.yaml
sed -i 's/default_graph: modern_graph/default_graph: ldbc/g' ./engine_config_test.yaml

- name: Run codegen test.
env:
GS_TEST_DIR: ${{ github.workspace }}/gstest
Expand Down
7 changes: 7 additions & 0 deletions flex/tests/hqps/engine_config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ compiler:
- FilterIntoJoinRule
- FilterMatchRule
- NotMatchToAntiJoinRule
meta:
reader:
mode: local
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still runs in local mode?

endpoint: localhost:7777 # only for http mode
interval:
graph_meta: 1000 # ms
statistics: 86400000 # ms
endpoint:
default_listen_address: localhost
bolt_connector:
Expand Down
99 changes: 99 additions & 0 deletions flex/tests/hqps/hqps_compiler_get_meta_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash
# Copyright 2020 Alibaba Group Holding Limited.
#
# Licensed 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.
set -e
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
FLEX_HOME=${SCRIPT_DIR}/../../
SERVER_BIN=${FLEX_HOME}/build/bin/interactive_server
GIE_HOME=${FLEX_HOME}/../interactive_engine/
ADMIN_PORT=7777
QUERY_PORT=10000

#
if [ ! $# -eq 2 ]; then
echo "only receives: $# args, need 2"
echo "Usage: $0 <INTERACTIVE_WORKSPACE> <ENGINE_CONFIG>"
exit 1
fi

INTERACTIVE_WORKSPACE=$1
ENGINE_CONFIG_PATH=$2
if [ ! -d ${INTERACTIVE_WORKSPACE} ]; then
echo "INTERACTIVE_WORKSPACE: ${INTERACTIVE_WORKSPACE} not exists"
exit 1
fi
if [ ! -f ${ENGINE_CONFIG_PATH} ]; then
echo "ENGINE_CONFIG: ${ENGINE_CONFIG_PATH} not exists"
exit 1
fi


RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
err() {
echo -e "${RED}[$(date +'%Y-%m-%d %H:%M:%S')] -ERROR- $* ${NC}" >&2
}

info() {
echo -e "${GREEN}[$(date +'%Y-%m-%d %H:%M:%S')] -INFO- $* ${NC}"
}


kill_service(){
info "Kill Service first"
ps -ef | grep "interactive_server" | awk '{print $2}' | xargs kill -9 || true
ps -ef | grep "compiler" | awk '{print $2}' | xargs kill -9 || true
sleep 3
# check if service is killed
info "Kill Service success"
}

# kill service when exit
trap kill_service EXIT

# start engine service and load ldbc graph
start_engine_service(){
#check SERVER_BIN exists
if [ ! -f ${SERVER_BIN} ]; then
err "SERVER_BIN not found"
exit 1
fi

cmd="${SERVER_BIN} -c ${ENGINE_CONFIG_PATH} --enable-admin-service true "
cmd="${cmd} -w ${INTERACTIVE_WORKSPACE} --start-compiler true"

echo "Start engine service with command: ${cmd}"
eval ${cmd}
sleep 10
#check interactive_server is running, if not, exit
ps -ef | grep "interactive_server" | grep -v grep

info "Start engine service success"
}

run_cypher_test() {
# run a simple cypher query: MATCH (n) RETURN count(n)
python3 ./test_count_vertices.py --endpoint localhost:7687
}

kill_service
start_engine_service
# comiper service will fail to start, if the graph meta can not be retrieved
run_cypher_test
kill_service




38 changes: 38 additions & 0 deletions flex/tests/hqps/test_count_vertices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed 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 neo4j import GraphDatabase
from neo4j import Session as Neo4jSession

import argparse

def count_vertices(sess: Neo4jSession):
query = "MATCH (n) RETURN COUNT(n);"
result = sess.run(query)
for record in result:
print(record[0])

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Count the number of vertices in a graph.")
parser.add_argument("--endpoint", type=str, required=True, help="The endpoint to connect.")
args = parser.parse_args()

driver = GraphDatabase.driver(args.endpoint, auth=None)
with driver.session() as session:
count_vertices(session)
driver.close()
12 changes: 12 additions & 0 deletions interactive_engine/compiler/conf/ir.compiler.properties
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,15 @@ calcite.default.charset: UTF-8

# set the max capacity of the result streaming buffer for each query
# per.query.stream.buffer.max.capacity: 256

# set the mode to read ir meta, either from a 'local' file or via remote 'http'.
# ir.meta.reader.mode: local
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration of ir.meta.xx, should be uniformly defined with graph.schema and graph.statistics. In addition, we can really configure those service scheme, to automatically differentiate from local and http. For example,

graph.meta.statistics.uri: http://localhost:8080 -> this is a http file, or
graph.meta.statistics.uri: file:///path/to/local/file -> this is a local file

Also give a uri for schema

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


# if ir.meta.reader.mode is 'http', set the remote ir meta service host
# ir.meta.service.host: localhost:8080

# if ir.meta.reader.mode is 'http', set the interval in milliseconds to fetch ir meta
# ir.meta.fetch.interval.ms: 1000

# if ir.meta.reader.mode is 'http', set the timeout in milliseconds to fetch ir graph statistics
# ir.statistics.fetch.interval.ms: 86400000l
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
import com.alibaba.graphscope.common.client.channel.ChannelFetcher;
import com.alibaba.graphscope.common.client.channel.HostURIChannelFetcher;
import com.alibaba.graphscope.common.client.channel.HostsRpcChannelFetcher;
import com.alibaba.graphscope.common.client.channel.MetaServiceChannelFetcher;
import com.alibaba.graphscope.common.config.Configs;
import com.alibaba.graphscope.common.config.FrontendConfig;
import com.alibaba.graphscope.common.config.GraphConfig;
import com.alibaba.graphscope.common.ir.meta.IrMeta;
import com.alibaba.graphscope.common.ir.meta.IrMetaTracker;
import com.alibaba.graphscope.common.ir.meta.fetcher.DynamicIrMetaFetcher;
import com.alibaba.graphscope.common.ir.meta.fetcher.IrMetaFetcher;
import com.alibaba.graphscope.common.ir.meta.fetcher.StaticIrMetaFetcher;
import com.alibaba.graphscope.common.ir.meta.reader.HttpIrMetaReader;
import com.alibaba.graphscope.common.ir.meta.reader.LocalIrMetaReader;
import com.alibaba.graphscope.common.ir.planner.GraphRelOptimizer;
import com.alibaba.graphscope.common.ir.tools.*;
Expand Down Expand Up @@ -187,7 +190,18 @@ public static void main(String[] args) throws Exception {

private static IrMetaFetcher createIrMetaFetcher(Configs configs, IrMetaTracker tracker)
throws IOException {
return new StaticIrMetaFetcher(new LocalIrMetaReader(configs), tracker);
String readerMode = FrontendConfig.IR_META_READER_MODE.get(configs);
switch (readerMode) {
case "local":
return new StaticIrMetaFetcher(new LocalIrMetaReader(configs), tracker);
case "http":
return new DynamicIrMetaFetcher(
configs,
new HttpIrMetaReader(new MetaServiceChannelFetcher(configs)),
tracker);
default:
throw new IllegalArgumentException("unknown ir meta reader mode: " + readerMode);
}
}

private static GraphProperties getTestGraph(Configs configs) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
*
* * Copyright 2020 Alibaba Group Holding Limited.
* *
* * Licensed 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.
*
*/

package com.alibaba.graphscope.common.client.channel;

import com.alibaba.graphscope.common.config.Configs;
import com.alibaba.graphscope.common.config.FrontendConfig;
import com.google.common.collect.ImmutableList;

import java.net.URI;
import java.util.List;

// read meta service host from config and return it as URI format
public class MetaServiceChannelFetcher implements ChannelFetcher<URI> {
private static final String schema = "http";
private final Configs graphConfig;

public MetaServiceChannelFetcher(Configs graphConfig) {
this.graphConfig = graphConfig;
}

@Override
public List<URI> fetch() {
String host = FrontendConfig.IR_META_SERVICE_HOST.get(graphConfig);
return ImmutableList.of(URI.create(schema + "://" + host));
}

@Override
public Type getType() {
return Type.HTTP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,16 @@

public static final Config<Integer> PER_QUERY_STREAM_BUFFER_MAX_CAPACITY =
Config.intConfig("per.query.stream.buffer.max.capacity", 256);

public static final Config<Long> IR_META_FETCH_INTERVAL_MS =
Config.longConfig("ir.meta.fetch.interval.ms", 1000);

public static final Config<Long> IR_STATISTICS_FETCH_INTERVAL_MS =
Config.longConfig("ir.statistics.fetch.interval.ms", 24 * 3600 * 1000l);

Check warning on line 68 in interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/config/FrontendConfig.java

View check run for this annotation

codefactor.io / CodeFactor

interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/config/FrontendConfig.java#L68

Should use uppercase 'L'. (com.puppycrawl.tools.checkstyle.checks.UpperEllCheck)

public static Config<String> IR_META_READER_MODE =
Config.stringConfig("ir.meta.reader.mode", "local");

public static Config<String> IR_META_SERVICE_HOST =
Config.stringConfig("ir.meta.service.host", "localhost:8080");
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public class PlannerConfig {
public static final Config<String> GRAPH_PLANNER_OPT =
Config.stringConfig("graph.planner.opt", "RBO");
public static final Config<String> GRAPH_PLANNER_RULES =
Config.stringConfig("graph.planner.rules", "");
Config.stringConfig(
"graph.planner.rules",
"FilterIntoJoinRule,FilterMatchRule,ExtendIntersectRule,ExpandGetVFusionRule");
public static final Config<Integer> GRAPH_PLANNER_CBO_GLOGUE_SIZE =
Config.intConfig("graph.planner.cbo.glogue.size", 3);
public static final Config<Integer> JOIN_MIN_PATTERN_SIZE =
Expand Down
Loading
Loading