MCPcopy Create free account
hub / github.com/alibaba/GraphScope / pyx_codegen

Function pyx_codegen

python/graphscope/analytical/udf/wrapper.py:73–108  ·  view source on GitHub ↗

Transfer python to cython code with :code:`grape.GRAPECompiler`. Args: algo: class defination of algorithm. defs: list of function to be transfer. program_model: ProgramModel, 'Pregel' or 'PIE'. pyx_header: LinesWrapper, list of pyx source code. vd_type (str): vert

(
    algo,
    defs,
    program_model,
    pyx_header,
    vd_type=None,
    md_type=None,
    pregel_combine=False,
)

Source from the content-addressed store, hash-verified

71
72
73def pyx_codegen(
74 algo,
75 defs,
76 program_model,
77 pyx_header,
78 vd_type=None,
79 md_type=None,
80 pregel_combine=False,
81):
82 """Transfer python to cython code with :code:`grape.GRAPECompiler`.
83
84 Args:
85 algo: class defination of algorithm.
86 defs: list of function to be transfer.
87 program_model: ProgramModel, 'Pregel' or 'PIE'.
88 pyx_header: LinesWrapper, list of pyx source code.
89 vd_type (str): vertex data type.
90 md_type (str): message type.
91 pregel_combine (bool): combinator in pregel model.
92
93 """
94 class_name = getattr(algo, "__name__")
95
96 compiler = GRAPECompiler(class_name, vd_type, md_type, program_model)
97
98 pyx_body = LinesWrapper()
99 for func_name in defs.keys():
100 func = getattr(algo, func_name)
101 cycode = compiler.run(func, pyx_header)
102 pyx_body.putline(cycode)
103
104 # append code body
105 # pyx_wrapper['pyx_code_body'].extend(pyx_code_body)
106 wrap_init(
107 algo, program_model, pyx_header, pyx_body, vd_type, md_type, pregel_combine
108 )

Callers 2

_pie_wrapperFunction · 0.90
_pregel_wrapperFunction · 0.90

Calls 6

runMethod · 0.95
putlineMethod · 0.95
GRAPECompilerClass · 0.90
LinesWrapperClass · 0.90
wrap_initFunction · 0.85
keysMethod · 0.45

Tested by

no test coverage detected