update structure, vis application
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
ifeq ($(PYTHON_EXEC),)
|
||||
PYTHON_EXEC=python3
|
||||
endif
|
||||
PYTHON_CONFIG=$(PYTHON_EXEC)-config
|
||||
PYTHON_LDFLAGS=$(shell echo `$(PYTHON_CONFIG) --ldflags` | sed 's/^-L\([^[:space:]]*\).*$$/\1/')/lib$(PYTHON_EXEC)*.a
|
||||
all:
|
||||
rm ../../libdraw.so; \
|
||||
$(CXX) --shared app2.cpp --std=c++2a -I../.. -I/usr/local/opt/matplotplusplus/include -L../.. -L/usr/local/opt/matplotplusplus/lib/ -lmatplot -laquery -o ../../libdraw.so
|
||||
py:
|
||||
rm ../../libdraw.so; \
|
||||
$(CXX) --shared app.cpp --std=c++2a -I../.. `$(PYTHON_CONFIG) --cflags` -O0 -g3 $(PYTHON_LDFLAGS) ../../libaquery.a -o ../../libdraw.so
|
||||
exe:
|
||||
$(CXX) app.cpp --std=c++2a -I../.. `$(PYTHON_CONFIG) --cflags` -O0 -g3 $(PYTHON_LDFLAGS) ../../libaquery.a -o a.out
|
||||
info:
|
||||
$(info $(PYTHON_LDFLAGS))
|
||||
@@ -0,0 +1,47 @@
|
||||
#include <Python.h>
|
||||
#include <random>
|
||||
#include <ctime>
|
||||
#include <cstdio>
|
||||
#include "server/vector_type.hpp"
|
||||
#include "sdk/aquery.h"
|
||||
#include "unistd.h"
|
||||
__AQEXPORT__(bool)
|
||||
draw(vector_type<int> x, vector_type<int> y) {
|
||||
puts("sibal!");
|
||||
auto pid = fork();
|
||||
int status = 0;
|
||||
if (pid == 0) {
|
||||
//PyOS_AfterFork();
|
||||
Py_InitializeEx
|
||||
Py_Initialize();
|
||||
|
||||
PyRun_SimpleString("print(globals())");
|
||||
PyRun_SimpleString("import os");
|
||||
PyRun_SimpleString("sys.path.append(os.getcwd()+'/demo/Python Integration')");
|
||||
//PyErr_Print();
|
||||
PyRun_SimpleString("print('fuck')");
|
||||
auto py_strapp = PyUnicode_DecodeFSDefault("app");
|
||||
auto py_module = PyImport_Import(py_strapp);
|
||||
// Py_DECREF(py_strapp);
|
||||
auto py_entrypt = PyObject_GetAttrString(py_module, "draw");
|
||||
|
||||
auto mvx = PyMemoryView_FromMemory((char*)x.container, x.size * sizeof(int), PyBUF_WRITE),
|
||||
mvy = PyMemoryView_FromMemory((char*)y.container, y.size * sizeof(int), PyBUF_WRITE);
|
||||
PyObject_CallObject(py_entrypt, PyTuple_Pack(2, mvx, mvy));
|
||||
// Py_DECREF(mvx);
|
||||
// Py_DECREF(mvy);
|
||||
// Py_DECREF(py_entrypt);
|
||||
// Py_DECREF(py_module);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
while(wait(&status) > 0);
|
||||
//getchar();
|
||||
}
|
||||
return true;
|
||||
//return Py_FinalizeEx() >= 0;
|
||||
}
|
||||
|
||||
int main(){
|
||||
draw({1,2,3}, {4,5,6});
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def draw(x, y):
|
||||
plt.figure()
|
||||
|
||||
plt.plot(x.cast('i', shape=(len(x)//4, )),
|
||||
y.cast('i', shape=(len(y)//4, )))
|
||||
plt.show()
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "server/vector_type.hpp"
|
||||
#include "sdk/aquery.h"
|
||||
#include "matplot/matplot.h"
|
||||
|
||||
__AQEXPORT__(bool)
|
||||
draw(vector_type<int> x, vector_type<int> y) {
|
||||
using namespace matplot;
|
||||
auto plt = gca();
|
||||
plt->plot(vector_type_std{x}, vector_type_std{y});
|
||||
show();
|
||||
return true;
|
||||
}
|
||||
+3
-3
@@ -23,6 +23,6 @@ This folder contains a demo workflow for the two types of triggers.
|
||||
- Create an Interval-based Trigger that executes payload `demoi` every 5 seconds
|
||||
- Create a Conditional Trigger that executes payload `democa` whenever condition `democq` returns a true. While condition `democq` is tested every time new data is inserted to table `source`.
|
||||
- Loads test data by running [demo/test.a](/demo/test.a)
|
||||
- Use query `select predict(x) from test` to get predictions of the test data from current random forest.
|
||||
- In AQuery prompt, an extra `exec` command after the query is needed to execute the query.
|
||||
- Use query `select test(x, y) from test` will also calculate l2 error.
|
||||
- Use query `select predict(x) from test` to get predictions of the test data from current random forest.
|
||||
- In AQuery prompt, an extra `exec` command after the query is needed to execute the query.
|
||||
- Use query `select test(x, y) from test` will also calculate l2 error.
|
||||
|
||||
Reference in New Issue
Block a user