Пример #1
0
def test_run_cython_pie_app(graphscope_session, p2p_property_graph,
                            sssp_result, random_gar):
    SSSP_PIE.to_gar(random_gar)
    a1 = SSSP_PIE()
    ctx1 = a1(p2p_property_graph, src=6)
    r1 = (ctx1.to_dataframe({
        "node": "v:person.id",
        "r": "r:person"
    }).sort_values(by=["node"]).to_numpy(dtype=float))
    r1[r1 == 1000000000.0] = float("inf")
    assert np.allclose(r1, sssp_result["directed"])
    ctx2 = a1(p2p_property_graph, src=6, other="a", yet_other=[1, 2, 3])
    r2 = (ctx2.to_dataframe({
        "node": "v:person.id",
        "r": "r:person"
    }).sort_values(by=["node"]).to_numpy(dtype=float))
    r2[r2 == 1000000000.0] = float("inf")
    assert np.allclose(r2, sssp_result["directed"])
    # load from gar
    a2 = load_app(random_gar)
    ctx3 = a2(p2p_property_graph, src=6)
    r3 = (ctx3.to_dataframe({
        "node": "v:person.id",
        "r": "r:person"
    }).sort_values(by=["node"]).to_numpy(dtype=float))
    r3[r3 == 1000000000.0] = float("inf")
    assert np.allclose(r3, sssp_result["directed"])
    # args is not supported
    with pytest.raises(
            InvalidArgumentError,
            match="Only support using keyword arguments in cython app"):
        a3 = load_app(random_gar)
        ctx4 = a3(p2p_property_graph, 6, src=6)
Пример #2
0
def test_error_on_create_cython_app(
    graphscope_session, dynamic_property_graph, dynamic_project_graph, random_gar
):
    SSSP_Pregel.to_gar(random_gar)
    with pytest.raises(InvalidArgumentError, match="App is uncompatible with graph"):
        a1 = load_app("SSSP_Pregel", random_gar)
        a1(dynamic_property_graph, src=4)

    with pytest.raises(InvalidArgumentError, match="App is uncompatible with graph"):
        a2 = load_app("SSSP_Pregel", random_gar)
        a2(dynamic_project_graph, src=4)
Пример #3
0
def test_run_cython_pregel_app(
    graphscope_session, p2p_property_graph, sssp_result, random_gar
):
    SSSP_Pregel.to_gar(random_gar)
    a1 = SSSP_Pregel()
    ctx1 = a1(p2p_property_graph, src=6)
    r1 = (
        ctx1.to_dataframe({"node": "v:person.id", "r": "r:person"})
        .sort_values(by=["node"])
        .to_numpy(dtype=float)
    )
    r1[r1 == 1000000000.0] = float("inf")
    assert np.allclose(r1, sssp_result["directed"])
    # redundant params is ok
    ctx2 = a1(p2p_property_graph, src=6, other="a", yet_other=[1, 2, 3])
    r2 = (
        ctx2.to_dataframe({"node": "v:person.id", "r": "r:person"})
        .sort_values(by=["node"])
        .to_numpy(dtype=float)
    )
    r2[r2 == 1000000000.0] = float("inf")
    assert np.allclose(r2, sssp_result["directed"])
    # load from gar
    a2 = load_app("SSSP_Pregel", random_gar)
    ctx3 = a2(p2p_property_graph, src=6)
    r3 = (
        ctx3.to_dataframe({"node": "v:person.id", "r": "r:person"})
        .sort_values(by=["node"])
        .to_numpy(dtype=float)
    )
    r3[r3 == 1000000000.0] = float("inf")
    assert np.allclose(r3, sssp_result["directed"])
    # args is not supported
    with pytest.raises(
        InvalidArgumentError, match="Only support using keyword arguments in cython app"
    ):
        a3 = load_app("SSSP_Pregel", random_gar)
        ctx4 = a3(p2p_property_graph, 6, src=6)
    # combine
    a5 = SSSP_Pregel_Combine()
    ctx5 = a5(p2p_property_graph, src=6)
    r5 = (
        ctx5.to_dataframe({"node": "v:person.id", "r": "r:person"})
        .sort_values(by=["node"])
        .to_numpy(dtype=float)
    )
    r5[r5 == 1000000000.0] = float("inf")
    assert np.allclose(r5, sssp_result["directed"])
    # aggregator test
    a6 = Aggregators_Pregel_Test()
    a6(p2p_property_graph)
Пример #4
0
def test_load_app_from_gar(random_gar, not_exist_gar, non_zipfile_gar):
    # file not exist, also works with permission denied
    with pytest.raises(FileNotFoundError, match="No such file or directory"):
        ast1 = load_app(not_exist_gar)
    # not a zip file
    with pytest.raises(ValueError, match="not a zip file"):
        ast2 = load_app(non_zipfile_gar)
    # type error
    with pytest.raises(ValueError, match="Wrong type"):
        ast3 = load_app([1, 2, 3, 4])
    with pytest.raises(ValueError, match="Wrong type"):
        ast4 = load_app(gar=None)
    SSSP_Pregel.to_gar(random_gar)
    ast1 = load_app(random_gar)
    assert isinstance(ast1, AppAssets)
Пример #5
0
def test_create_cython_app(
    graphscope_session, p2p_property_graph, arrow_project_graph, random_gar, empty_gar
):
    SSSP_Pregel.to_gar(random_gar)
    a1 = load_app("SSSP_Pregel", random_gar)
    a1(p2p_property_graph, src=6)
    # algo not found in gar resource
    with pytest.raises(InvalidArgumentError, match="App not found in gar: sssp"):
        a2 = load_app("sssp", random_gar)
        a2(p2p_property_graph, src=6)

    # no `.gs_conf.yaml` in empty gar, raise KeyError exception
    with pytest.raises(KeyError):
        a3 = load_app("SSSP_Pregel", empty_gar)
        a3(p2p_property_graph, src=6)

    # cython app only support arrow property graph
    with pytest.raises(InvalidArgumentError, match="App is uncompatible with graph"):
        a4 = load_app("SSSP_Pregel", random_gar)
        a4(arrow_project_graph, src=6)
Пример #6
0
def test_error_on_create_cython_app(
    graphscope_session,
    p2p_property_graph,
    dynamic_property_graph,
    random_gar,
    empty_gar,
):
    SSSP_Pregel.to_gar(random_gar)
    with pytest.raises(InvalidArgumentError,
                       match="App is uncompatible with graph"):
        a1 = load_app(random_gar)
        a1(dynamic_property_graph, src=4)
    # algo not found in gar resource
    with pytest.raises(InvalidArgumentError,
                       match="App not found in gar: sssp"):
        a2 = load_app(gar=random_gar, algo="sssp")
        a2(p2p_property_graph, src=6)
    # no `.gs_conf.yaml` in empty gar, raise KeyError exception
    with pytest.raises(KeyError):
        a3 = load_app(gar=empty_gar, algo="SSSP_Pregel")
        a3(p2p_property_graph, src=6)
Пример #7
0
def test_giraph_app(
    demo_jar,
    graphscope_session,
    projected_graph_sssp_class,
):
    graphscope_session.add_lib(demo_jar)
    vformat = "giraph:com.alibaba.graphscope.example.giraph.format.P2PVertexInputFormat"
    eformat = "giraph:com.alibaba.graphscope.example.giraph.format.P2PEdgeInputFormat"
    g = projected_p2p_graph_loaded_by_giraph(graphscope_session, demo_jar,
                                             vformat, eformat)

    giraph_sssp = load_app(
        algo="giraph:com.alibaba.graphscope.example.giraph.SSSP")
    giraph_sssp(g, sourceId=6)
    g.unload()
Пример #8
0
 def call(self, graph, **kwargs):
     app_assets = load_app(gar=garfile.read_bytes(), algo=module_name)
     return app_assets(graph, **kwargs)
Пример #9
0
 def call(self, graph, **kwargs):
     app_assets = load_app(algo=algo_name, gar=garfile.read_bytes())
     return app_assets(graph, **kwargs)