53 lines
1.7 KiB
C#

using Python.Runtime;
using System;
using static System.Net.Mime.MediaTypeNames;
using System.IO;
using System.Reflection;
using System.Dynamic;
namespace dopt.TOM
{
public class Plugin : SharpPython.BasePlugin
{
internal const string langMainBaseFolderName = "bin";
internal const string langMainStopSearchFolderName = "python";
internal const string doptTOMPluginLibraryUsage = "1";
protected dynamic tomWrapperPipelines;
public Plugin(string runtimePath) : base(SharpPython.PyOptimLevels.O, threaded: false, runtimePath: runtimePath, verbose: true)
{
base.Initialise();
using (Py.GIL())
{
tomWrapperPipelines = Py.Import("tom_plugin.pipeline");
}
}
//private void Run() // for testing purposes
//{
// if (!_initialised) Initialise();
// using (Py.GIL())
// {
// dynamic np = Py.Import("numpy");
// Console.WriteLine(np.cos(np.pi * 2));
// dynamic rand = Py.Import("random");
// Console.WriteLine(rand.randint(1, 2));
// dynamic pathlib = Py.Import("pathlib");
// dynamic ret = pathlib.Path.cwd();
// Console.WriteLine(ret);
// }
// Finalise();
//}
public void RunOnCSV(string identifier, string filename)
{
AssertNotDisposed();
using (Py.GIL())
{
dynamic tomWrapperPipeline = Py.Import("tom_plugin.pipeline");
tomWrapperPipeline.run_on_csv_data(identifier, filename);
}
}
}
}