Seperate out the PullAI on the front end
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Python.Runtime;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace PythonInterop {
|
||||
|
||||
@@ -22,19 +21,27 @@ namespace PythonInterop {
|
||||
PythonEngine.BeginAllowThreads();
|
||||
}
|
||||
|
||||
// This is thread blocking, runs on the main thread, and takes multiple minutes so probabaly need to run on a background thread at some point
|
||||
public void PullAI() {
|
||||
using (Py.GIL()) {
|
||||
dynamic datapuller = Py.Import("datapuller");
|
||||
using (datapuller.pull()){ }
|
||||
}
|
||||
}
|
||||
|
||||
public void TrainAI() {
|
||||
using (Py.GIL()) {
|
||||
dynamic datapuller = Py.Import("ai-trainer");
|
||||
dynamic result = datapuller.TrainAI();
|
||||
dynamic trainer = Py.Import("ai-trainer");
|
||||
using (trainer.TrainAI()){ }
|
||||
}
|
||||
}
|
||||
|
||||
public int PredictAI(string StockSymbol) {
|
||||
using (Py.GIL()) {
|
||||
dynamic main = Py.Import("ai-predictor");
|
||||
int result = main.Predict(StockSymbol);
|
||||
return result;
|
||||
dynamic predictor = Py.Import("ai-predictor");
|
||||
using (dynamic x = predictor.Predict(StockSymbol)) {
|
||||
int result = (int)x;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user