Ejemplo n.º 1
0
def test_serialize_roundtrip(gs_session_distributed, p2p_property_dir):
    graph = gs_session_distributed.load_from(
        edges={
            "knows": (
                Loader("{}/p2p-31_property_e_0".format(p2p_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(p2p_property_dir),
                   header_row=True),
        },
        generate_eid=False,
    )
    graph.serialize("/tmp/serialize")
    new_graph = Graph.deserialize("/tmp/serialize", gs_session_distributed)
    pg = new_graph.project_to_simple(0, 0, 0, 2)
    ctx = graphscope.sssp(pg, src=6)
    ret = (ctx.to_dataframe({
        "node": "v.id",
        "r": "r"
    },
                            vertex_range={
                                "end": 6
                            }).sort_values(by=["node"]).to_numpy(dtype=float))
    expect = np.array([[1.0, 260.0], [2.0, 229.0], [3.0, 310.0], [4.0, 256.0],
                       [5.0, 303.0]])
    assert np.all(ret == expect)
Ejemplo n.º 2
0
def test_serialize_roundtrip(p2p_property_dir):
    gs_image, gie_manager_image = get_gs_image_on_ci_env()
    sess = graphscope.session(
        num_workers=2,
        k8s_gs_image=gs_image,
        k8s_gie_graph_manager_image=gie_manager_image,
        k8s_coordinator_cpu=0.5,
        k8s_coordinator_mem="2500Mi",
        k8s_vineyard_cpu=0.1,
        k8s_vineyard_mem="512Mi",
        k8s_engine_cpu=0.1,
        k8s_engine_mem="1500Mi",
        k8s_vineyard_shared_mem="2Gi",
        k8s_volumes=get_k8s_volumes(),
    )
    graph = sess.load_from(
        edges={
            "knows": (
                Loader("{}/p2p-31_property_e_0".format(p2p_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(p2p_property_dir),
                   header_row=True),
        },
        generate_eid=False,
    )
    graph.serialize("/tmp/serialize")
    graph.unload()
    new_graph = Graph.deserialize("/tmp/serialize", sess)
    pg = new_graph.project_to_simple(0, 0, 0, 2)
    ctx = graphscope.sssp(pg, src=6)
    ret = (ctx.to_dataframe({
        "node": "v.id",
        "r": "r"
    },
                            vertex_range={
                                "end": 6
                            }).sort_values(by=["node"]).to_numpy(dtype=float))
    expect = np.array([[1.0, 260.0], [2.0, 229.0], [3.0, 310.0], [4.0, 256.0],
                       [5.0, 303.0]])
    assert np.all(ret == expect)