Skip to content

Commit

Permalink
fix(interactive): Fixing tutorial examples for Interactive (#4212)
Browse files Browse the repository at this point in the history
Fixing tutorial examples for Interactive and add them to CI
  • Loading branch information
zhanglei1949 authored Sep 11, 2024
1 parent 1e3573f commit 4bc52fa
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 129 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/flex-interactive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
uses: mxschmitt/action-tmate@v3
if: false

- name: Test
- name: Test gsctl
run: |
# install gsctl
python3 -m pip install ${GITHUB_WORKSPACE}/python/dist/*.whl
Expand All @@ -69,6 +69,24 @@ jobs:
# destroy instance
gsctl instance destroy --type interactive -y
- name: Test basic examples
run: |
# build gs_interactive wheel package
cd ${GITHUB_WORKSPACE}/flex/interactive/sdk
bash generate_sdk.sh -g python
cd python && pip3 install -r requirements.txt && python3 setup.py build_proto
python3 setup.py bdist_wheel
pip3 install dist/*.whl
gsctl instance deploy --type interactive --image-registry graphscope --image-tag latest --interactive-config ${GITHUB_WORKSPACE}/flex/tests/hqps/interactive_config_test.yaml
sleep 20
# test
cd ${GITHUB_WORKSPACE}/flex/interactive/sdk/examples/python
export INTERACTIVE_ADMIN_ENDPOINT=http://localhost:7777
python3 basic_example.py
# destroy instance
gsctl instance destroy --type interactive -y
- name: Upload Coverage
uses: codecov/codecov-action@v3
continue-on-error: true
Expand Down
34 changes: 18 additions & 16 deletions flex/engines/graph_db/database/graph_db_operations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ Result<std::string> GraphDBOperations::CreateVertex(
input_json["vertex_request"].size() == 0 ||
(input_json.contains("edge_request") == true &&
input_json["edge_request"].is_array() == false)) {
return Result<std::string>(
return Result<std::string>(gs::Status(
StatusCode::INVALID_SCHEMA,
"Invalid input json, vertex_request and edge_request should be array "
"and not empty");
"and not empty"));
}
const Schema& schema = session.schema();
// input vertex data and edge data
Expand All @@ -53,10 +53,11 @@ Result<std::string> GraphDBOperations::CreateVertex(
for (auto& edge_insert : input_json["edge_request"]) {
edge_data.push_back(inputEdge(edge_insert, schema, session));
}
LOG(INFO) << "CreateVertex edge_data: " << edge_data.size();
} catch (std::exception& e) {
return Result<std::string>(
StatusCode::INVALID_SCHEMA,
" Bad input parameter : " + std::string(e.what()));
gs::Status(StatusCode::INVALID_SCHEMA,
" Bad input parameter : " + std::string(e.what())));
}
auto insert_result =
insertVertex(std::move(vertex_data), std::move(edge_data), session);
Expand All @@ -73,9 +74,9 @@ Result<std::string> GraphDBOperations::CreateEdge(GraphDBSession& session,
std::vector<EdgeData> edge_data;
// Check if the input json contains edge_request
if (input_json.is_array() == false || input_json.size() == 0) {
return Result<std::string>(
return Result<std::string>(gs::Status(
StatusCode::INVALID_SCHEMA,
"Invalid input json, edge_request should be array and not empty");
"Invalid input json, edge_request should be array and not empty"));
}
const Schema& schema = session.schema();
// input edge data
Expand All @@ -85,8 +86,8 @@ Result<std::string> GraphDBOperations::CreateEdge(GraphDBSession& session,
}
} catch (std::exception& e) {
return Result<std::string>(
StatusCode::INVALID_SCHEMA,
" Bad input parameter : " + std::string(e.what()));
gs::Status(StatusCode::INVALID_SCHEMA,
" Bad input parameter : " + std::string(e.what())));
}
auto insert_result = insertEdge(std::move(edge_data), session);
if (insert_result.ok()) {
Expand All @@ -106,8 +107,8 @@ Result<std::string> GraphDBOperations::UpdateVertex(
vertex_data.push_back(inputVertex(input_json, schema, session));
} catch (std::exception& e) {
return Result<std::string>(
StatusCode::INVALID_SCHEMA,
" Bad input parameter : " + std::string(e.what()));
gs::Status(StatusCode::INVALID_SCHEMA,
" Bad input parameter : " + std::string(e.what())));
}
auto update_result = updateVertex(std::move(vertex_data), session);
if (update_result.ok()) {
Expand All @@ -127,8 +128,8 @@ Result<std::string> GraphDBOperations::UpdateEdge(GraphDBSession& session,
edge_data.push_back(inputEdge(input_json, schema, session));
} catch (std::exception& e) {
return Result<std::string>(
StatusCode::INVALID_SCHEMA,
" Bad input parameter : " + std::string(e.what()));
gs::Status(StatusCode::INVALID_SCHEMA,
" Bad input parameter : " + std::string(e.what())));
}
auto update_result = updateEdge(std::move(edge_data), session);
if (update_result.ok()) {
Expand Down Expand Up @@ -259,7 +260,8 @@ EdgeData GraphDBOperations::inputEdge(const nlohmann::json& edge_json,
}
std::string property_name = "";
if (edge_json["properties"].size() == 1) {
edge.property_value = Any(jsonToString(edge_json["properties"][0]["value"]));
edge.property_value =
Any(jsonToString(edge_json["properties"][0]["value"]));
property_name = edge_json["properties"][0]["name"];
}
auto check_result = checkEdgeSchema(schema, edge, src_label, dst_label,
Expand Down Expand Up @@ -312,14 +314,14 @@ Status GraphDBOperations::checkEdgeSchema(const Schema& schema, EdgeData& edge,
edge.src_label_id = schema.get_vertex_label_id(src_label);
edge.dst_label_id = schema.get_vertex_label_id(dst_label);
edge.edge_label_id = schema.get_edge_label_id(edge_label);
auto &result = schema.get_edge_property_names(edge.src_label_id, edge.dst_label_id,
edge.edge_label_id);
auto& result = schema.get_edge_property_names(
edge.src_label_id, edge.dst_label_id, edge.edge_label_id);
if (is_get) {
if (result.size() >= 1) {
property_name = result[0];
} else {
property_name = "";
}
}
} else {
// update or add
if (property_name != (result.size() >= 1 ? result[0] : "")) {
Expand Down
Loading

0 comments on commit 4bc52fa

Please sign in to comment.