Skip to content

Commit

Permalink
fix(interactive): Fix description passing for procedure creation (#4223)
Browse files Browse the repository at this point in the history
As titled.

Co-authored-by: yqy <yqyllh@gmail.com>
  • Loading branch information
zhanglei1949 and yqylh committed Sep 11, 2024
1 parent d13f298 commit bb5ebbd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
9 changes: 8 additions & 1 deletion flex/bin/load_plan_and_gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,15 @@ run() {
if [ ${ENGINE_TYPE} == "hqps" ]; then
echo "Engine type is hqps, generating dynamic library for hqps engine."
# if PROCEDURE_DESCRIPTION is not set, use empty string
if [ -z ${PROCEDURE_DESCRIPTION} ]; then
if [ -z "${PROCEDURE_DESCRIPTION}" ]; then
PROCEDURE_DESCRIPTION="Automatic generated description for stored procedure ${PROCEDURE_NAME}."
else
# assume is a file, read the content
if [ -f ${PROCEDURE_DESCRIPTION} ]; then
PROCEDURE_DESCRIPTION=$(cat ${PROCEDURE_DESCRIPTION})
else
PROCEDURE_DESCRIPTION="Automatic generated description for stored procedure ${PROCEDURE_NAME}."
fi
fi
# if PROCEDURE_NAME is not set, use input file name
if [ -z "${PROCEDURE_NAME}" ]; then
Expand Down
12 changes: 10 additions & 2 deletions flex/engines/http_server/codegen_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,16 @@ seastar::future<gs::Result<bool>> CodegenProxy::CallCodegenCmd(
" -o=" + output_dir + " --procedure_name=" + query_name +
" -w=" + work_dir + " --ir_conf=" + engine_config +
" --graph_schema_path=" + graph_schema_path;
std::string desc_file = work_dir + "/" + query_name + ".desc";
if (!procedure_desc.empty()) {
cmd += " --procedure_desc=\'" + procedure_desc + "\'";
std::ofstream ofs(desc_file);
ofs << procedure_desc;
ofs.close();
cmd += " --procedure_desc=" + desc_file;
}
LOG(INFO) << "Start call codegen cmd: [" << cmd << "]";

return hiactor::thread_resource_pool::submit_work([cmd] {
return hiactor::thread_resource_pool::submit_work([cmd, desc_file] {
// auto res = std::system(cmd.c_str());
boost::process::ipstream stdout_pipe;
boost::process::ipstream stderr_pipe;
Expand All @@ -231,6 +235,10 @@ seastar::future<gs::Result<bool>> CodegenProxy::CallCodegenCmd(
codegen_process.wait();
stderr_pipe.close();
stdout_pipe.close();
// remove the desc file if exists
if (std::filesystem::exists(desc_file)) {
std::filesystem::remove(desc_file);
}
int res = codegen_process.exit_code();
if (res != 0) {
return gs::Result<bool>(
Expand Down
5 changes: 5 additions & 0 deletions flex/interactive/sdk/examples/python/basic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ def addEdge(sess: Session, graph_id: str):
)
resp = sess.create_procedure(graph_id, create_proc_request)
assert resp.is_ok()

get_proc_res = sess.get_procedure(graph_id, "test_procedure")
assert get_proc_res.is_ok()
# Check the description of the procedure
assert get_proc_res.get_value().description == "test procedure"

# must start service on the current graph, to let the procedure take effect
resp = sess.restart_service()
Expand Down

0 comments on commit bb5ebbd

Please sign in to comment.