apply new architecture with base plugin dopt.SharpPython

This commit is contained in:
Florian Förster 2025-06-19 09:52:49 +02:00
parent 9ccab97fe7
commit 566cf8b9a9
2 changed files with 7 additions and 24 deletions

View File

@ -15,39 +15,22 @@ namespace dopt.TOM
protected dynamic tomWrapperPipelines; protected dynamic tomWrapperPipelines;
public Plugin(string runtimePath) : base(SharpPython.PyOptimLevels.O, threaded: false, runtimePath: runtimePath, verbose: true) public Plugin(string runtimePath) : base(SharpPython.PyOptimLevels.O, threaded: false, runtimePath: runtimePath, verbose: true)
{ {
Environment.SetEnvironmentVariable("LANG_MAIN_BASE_FOLDERNAME", langMainBaseFolderName, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("LANG_MAIN_STOP_SEARCH_FOLDERNAME", langMainStopSearchFolderName, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("DOPT_TOM_PLUGIN_LIBRARY_USAGE", doptTOMPluginLibraryUsage, EnvironmentVariableTarget.Process);
base.Initialise(); base.Initialise();
using (Py.GIL()) using (Py.GIL())
{ {
dynamic os = Py.Import("os");
os.putenv("LANG_MAIN_BASE_FOLDERNAME", langMainBaseFolderName);
os.putenv("LANG_MAIN_STOP_SEARCH_FOLDERNAME", langMainStopSearchFolderName);
os.putenv("DOPT_TOM_PLUGIN_LIBRARY_USAGE", doptTOMPluginLibraryUsage);
tomWrapperPipelines = Py.Import("tom_plugin.pipeline"); 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) public void RunOnCSV(string identifier, string filename)
{ {
AssertNotDisposed(); AssertNotDisposed();
using (Py.GIL()) using (Py.GIL())
{ {
dynamic tomWrapperPipeline = Py.Import("tom_plugin.pipeline"); tomWrapperPipelines.run_on_csv_data(identifier, filename);
tomWrapperPipeline.run_on_csv_data(identifier, filename);
} }
} }
} }

View File

@ -3,12 +3,12 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<Version>0.1.1-beta1</Version> <Version>0.1.2</Version>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="dopt.SharpPython" Version="0.4.2" /> <PackageReference Include="dopt.SharpPython" Version="0.4.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>