Skip to content

Commit

Permalink
fix compile app with string oid graph, add a simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
siyuan0322 committed Feb 2, 2021
1 parent 129722f commit a1f33e3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python/graphscope/framework/dag_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def create_app(graph, app):
config = {
types_pb2.APP_ALGO: utils.s_to_attr(app.algo),
types_pb2.GRAPH_TYPE: utils.graph_type_to_attr(graph.graph_type),
types_pb2.OID_TYPE: utils.s_to_attr(graph.schema.oid_type),
types_pb2.OID_TYPE: utils.s_to_attr(
utils.normalize_data_type_str(graph.schema.oid_type)
),
types_pb2.VID_TYPE: utils.s_to_attr(graph.schema.vid_type),
types_pb2.V_DATA_TYPE: utils.s_to_attr(
utils.data_type_to_cpp(graph.schema.vdata_type)
Expand Down
28 changes: 28 additions & 0 deletions python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,28 @@ def p2p_property_graph(graphscope_session):
yield g


@pytest.fixture(scope="module")
def p2p_property_graph_string(graphscope_session):
g = graphscope_session.load_from(
edges={
"knows": (
Loader("{}/p2p-31_property_e_0".format(property_dir), header_row=True),
["src_label_id", "dst_label_id", "dist"],
("src_id", "person"),
("dst_id", "person"),
),
},
vertices={
"person": Loader(
"{}/p2p-31_property_v_0".format(property_dir), header_row=True
),
},
generate_eid=False,
oid_type="string",
)
yield g


@pytest.fixture(scope="module")
def p2p_property_graph_undirected(graphscope_session):
g = graphscope_session.load_from(
Expand Down Expand Up @@ -501,6 +523,12 @@ def p2p_project_undirected_graph(p2p_property_graph_undirected):
yield pg


@pytest.fixture(scope="module")
def p2p_project_directed_graph_string(p2p_property_graph_string):
pg = p2p_property_graph_string.project_to_simple(0, 0, 0, 2)
yield pg


@pytest.fixture(scope="module")
def projected_pg_no_edge_data(arrow_property_graph):
pg = arrow_property_graph.project_to_simple(0, 0, None, None)
Expand Down
6 changes: 6 additions & 0 deletions python/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@ def test_app_on_undirected_graph(
assert np.all(ctx10.to_numpy("r", vertex_range={"begin": 1, "end": 4}) == [0, 0, 0])


def test_run_app_on_string_oid_graph(p2p_project_directed_graph_string):
ctx = sssp(p2p_project_directed_graph_string, src="6")
r1 = ctx.to_dataframe({"node": "v.id", "r": "r"})
assert r1[r1["node"] == "6"].r.values[0] == 0.0


def test_error_on_parameters_not_correct(arrow_project_graph):
# Incorrect type of parameters
with pytest.raises(ValueError, match="could not convert string to float"):
Expand Down

0 comments on commit a1f33e3

Please sign in to comment.