MCPcopy Create free account
hub / github.com/TuGraph-family/tugraph-db / TEST_P

Function TEST_P

test/test_python_plugin_manager.cpp:49–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47};
48
49TEST_P(TestPythonPlugin, PythonPlugin) {
50 using namespace lgraph;
51 using namespace python_plugin;
52 std::string plugin_dir = "./python_plugin";
53 size_t n_workers = 2, n_jobs = 3;
54 n_workers = GetParam().j;
55 n_jobs = GetParam().n;
56 int argc = _ut_argc;
57 char** argv = _ut_argv;
58 Configuration config;
59 config.Add(plugin_dir, "d,dir", true).Comment("Directory where plugin files are stored.");
60 config.Add(n_workers, "j,workers", true).Comment("Number of Python worker threads to use.");
61 config.Add(n_jobs, "n,jobs", true).Comment("Number of Python jobs.");
62 config.ParseAndFinalize(argc, argv);
63 const char* sleep_plugin = "./sleep.py";
64 const char* read_plugin = "./scan_graph.py";
65 const char* write_plugin = "./write_vertex.py";
66 std::string code_sleep;
67 std::string code_read;
68 std::string code_write;
69 {
70 UT_LOG() << "Create test files";
71 code_sleep = R"(
72import time
73def Process(db, input):
74 t = 1
75 try:
76 t = int(input)
77 except:
78 return (False, 'input must be a time duration')
79 print('sleeping for {} seconds'.format(t))
80 time.sleep(t)
81 return (True, '')
82)";
83 code_read = R"(
84def Process(db, input):
85 n = 0
86 try:
87 n = int(input)
88 except:
89 pass
90 if n == 0:
91 n = 1000000
92 txn = db.CreateReadTxn()
93 it = txn.GetVertexIterator()
94 nv = 0
95 while it.IsValid() and nv < n:
96 nv = nv + 1
97 it.Next()
98 return (True, str(nv))
99)";
100 code_write = R"(
101from liblgraph_python_api import *
102def Process(db, input):
103 db.AddVertexLabel("v", [FieldSpec("id",FieldType.INT32,False),FieldSpec("name",FieldType.STRING,True)])
104 txn = db.CreateWriteTxn()
105 id = txn.AddVertex("v", {"id":1, "name":"001"})
106 txn.Commit()

Callers

nothing calls this directly

Calls 15

RemoveDirFunction · 0.85
ParseAndFinalizeMethod · 0.80
GetUserTokenMethod · 0.80
GetLightningGraphMethod · 0.80
LoadPluginFromCodeMethod · 0.80
CallMethod · 0.80
AddMethod · 0.45
RemoveDirMethod · 0.45
OpenGraphMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
ListPluginsMethod · 0.45

Tested by

no test coverage detected