4141
4242function prepare_workspace() {
4343 # receive args
44+ if [ $# -lt 1 ] || [ $# -gt 2 ]; then
45+ echo " Usage: prepare_workspace <workspace> [graph_yaml]"
46+ echo " workspace: the path to the workspace"
47+ echo " graph_yaml: the path to the graph yaml file. If not provided, will use the default graph"
48+ echo " if specified, we assume the remote_path is set in the graph yaml"
49+ exit 1
50+ fi
4451 local workspace=$1
45- if [ -z " ${workspace} " ]; then
46- workspace=" /tmp/interactive_workspace"
52+ local graph_yaml=" "
53+ if [ $# -eq 2 ]; then
54+ graph_yaml=$2
4755 fi
56+ echo " workspace: ${workspace} , graph_yaml: ${graph_yaml} "
4857 # if workspace is not exist, create it
49- if [ ! -d " ${workspace} " ]; then
50- mkdir -p ${workspace}
51- mkdir -p ${workspace} /conf/
52- else
53- if [ -f " ${workspace} /conf/interactive_config.yaml" ]; then
54- echo " Workspace ${workspace} already exists"
55- return 0
56- fi
58+ mkdir -p ${workspace} /conf/
59+ mkdir -p ${workspace} /METADATA
60+ mkdir -p ${workspace} /log
61+ if [ -f " ${workspace} /conf/interactive_config.yaml" ]; then
62+ echo " Workspace ${workspace} already exists"
63+ return 0
5764 fi
5865 # prepare interactive_config.yaml
5966 engine_config_path=" ${workspace} /conf/interactive_config.yaml"
6067 cp ${DEFAULT_INTERACTIVE_CONFIG_FILE} $engine_config_path
6168 # make sure the line which start with default_graph is changed to default_graph: ${DEFAULT_GRAPH_NAME}
6269 sed -i " s/default_graph:.*/default_graph: ${DEFAULT_GRAPH_NAME} /" $engine_config_path
63- echo " Using default graph: ${DEFAULT_GRAPH_NAME} to start the service"
64-
65- # copy the builtin graph
6670 builtin_graph_dir=" ${workspace} /data/${DEFAULT_GRAPH_NAME} "
6771 mkdir -p $builtin_graph_dir
68- builtin_graph_import_path=" ${builtin_graph_dir} /import.yaml"
6972 builtin_graph_schema_path=" ${builtin_graph_dir} /graph.yaml"
7073 builtin_graph_data_path=" ${builtin_graph_dir} /indices"
71- cp /opt/flex/share/${DEFAULT_GRAPH_NAME} /graph.yaml ${builtin_graph_schema_path}
72- cp /opt/flex/share/${DEFAULT_GRAPH_NAME} /bulk_load.yaml ${builtin_graph_import_path}
73- export FLEX_DATA_DIR=/opt/flex/share/gs_interactive_default_graph/
74- builtin_graph_loader_cmd=" ${BULK_LOADER_BINARY_PATH} -g ${builtin_graph_schema_path} -d ${builtin_graph_data_path} -l ${builtin_graph_import_path} "
75- echo " Loading builtin graph: ${DEFAULT_GRAPH_NAME} with command: $builtin_graph_loader_cmd "
76- eval $builtin_graph_loader_cmd || (echo " Failed to load builtin graph: ${DEFAULT_GRAPH_NAME} " && exit 1)
77- echo " Successfully loaded builtin graph: ${DEFAULT_GRAPH_NAME} "
74+ if [ -z " ${graph_yaml} " ]; then
75+ # construct the builtin graph.
76+ builtin_graph_import_path=" ${builtin_graph_dir} /import.yaml"
77+ cp /opt/flex/share/${DEFAULT_GRAPH_NAME} /graph.yaml ${builtin_graph_schema_path}
78+ cp /opt/flex/share/${DEFAULT_GRAPH_NAME} /bulk_load.yaml ${builtin_graph_import_path}
79+ export FLEX_DATA_DIR=/opt/flex/share/gs_interactive_default_graph/
80+ builtin_graph_loader_cmd=" ${BULK_LOADER_BINARY_PATH} -g ${builtin_graph_schema_path} -d ${builtin_graph_data_path} -l ${builtin_graph_import_path} "
81+ echo " Loading builtin graph: ${DEFAULT_GRAPH_NAME} with command: $builtin_graph_loader_cmd "
82+ eval $builtin_graph_loader_cmd || (echo " Failed to load builtin graph: ${DEFAULT_GRAPH_NAME} " && exit 1)
83+ echo " Successfully loaded builtin graph: ${DEFAULT_GRAPH_NAME} "
84+ else
85+ if [ ! -f " ${graph_yaml} " ]; then
86+ echo " Graph yaml file ${graph_yaml} does not exist"
87+ exit 1
88+ fi
89+ # check if remote_path is set in the graph yaml
90+ remote_path=$( grep " remote_path" ${graph_yaml} | cut -d' :' -f2 | tr -d ' ' )
91+ if [ -z " ${remote_path} " ]; then
92+ echo " remote_path is not set in the graph yaml"
93+ exit 1
94+ fi
95+ cp ${graph_yaml} ${builtin_graph_schema_path}
96+ # The indices will be downloaded to ${builtin_graph_data_path} when starting the service
97+ fi
7898}
7999
80100function launch_service() {
81101 # expect 1 arg
82- if [ $# -ne 1 ]; then
83- echo " Usage: launch_service <workspace>"
102+ if [ $# -lt 1 ] || [ $# -gt 2 ]; then
103+ echo " Usage: launch_service <workspace> [graph_yaml] "
84104 exit 1
85105 fi
86106 local workspace=$1
107+ if [ $# -eq 2 ]; then
108+ local graph_yaml=$2
109+ fi
87110 engine_config_path=" ${workspace} /conf/interactive_config.yaml"
88111 # start the service
89112 start_cmd=" ${INTERACTIVE_SERVER_BIN} -c ${engine_config_path} "
90113 start_cmd=" ${start_cmd} -w ${workspace} "
91- start_cmd=" ${start_cmd} --enable-admin-service true"
92114 start_cmd=" ${start_cmd} --start-compiler true"
115+ if [ -n " ${graph_yaml} " ]; then
116+ start_cmd=" ${start_cmd} -g ${graph_yaml} "
117+ start_cmd=" ${start_cmd} --data-path ${workspace} /data/${DEFAULT_GRAPH_NAME} /indices"
118+ else
119+ start_cmd=" ${start_cmd} --enable-admin-service true"
120+ fi
93121 echo " Starting the service with command: $start_cmd "
94122 if $ENABLE_COORDINATOR ; then start_cmd=" ${start_cmd} &" ; fi
95123 eval $start_cmd
153181
154182ENABLE_COORDINATOR=false
155183WORKSPACE=/tmp/interactive_workspace
184+ CUSTOM_GRAPH_YAML=" "
156185while [[ $# -gt 0 ]]; do
157186 case $1 in
158187 -w | --workspace)
@@ -164,6 +193,15 @@ while [[ $# -gt 0 ]]; do
164193 WORKSPACE=$1
165194 shift
166195 ;;
196+ -g | --graph)
197+ shift
198+ if [[ $# -eq 0 || $1 == -* ]]; then
199+ echo " Option -g requires an argument." >&2
200+ exit 1
201+ fi
202+ CUSTOM_GRAPH_YAML=$1
203+ shift
204+ ;;
167205 -c | --enable-coordinator)
168206 ENABLE_COORDINATOR=true
169207 shift
@@ -189,8 +227,11 @@ while [[ $# -gt 0 ]]; do
189227 esac
190228done
191229
230+ # When a custom graph yaml is specified, we only need to start the query
231+ # service, coordinator and admin service should not be started
232+ prepare_workspace $WORKSPACE ${CUSTOM_GRAPH_YAML}
233+ launch_service $WORKSPACE ${CUSTOM_GRAPH_YAML}
234+ if [ -z " ${CUSTOM_GRAPH_YAML} " ]; then
235+ launch_coordinator $PORT_MAPPING
236+ fi
192237
193- prepare_workspace $WORKSPACE
194- launch_service $WORKSPACE
195- # Note that the COORDINATOR_CONFIG_FILE should be inside the container
196- launch_coordinator $PORT_MAPPING
0 commit comments