diff --git a/dopt.TOM/Plugin.cs b/dopt.TOM/Plugin.cs index dcbcbe2..efe43be 100644 --- a/dopt.TOM/Plugin.cs +++ b/dopt.TOM/Plugin.cs @@ -15,13 +15,25 @@ namespace dopt.TOM protected dynamic tomWrapperPipelines; public Plugin(string runtimePath = "") : base(SharpPython.PyOptimLevels.O, threaded: false, runtimePath: runtimePath, verbose: true) { + // keep these env variables within C#, but set them again in Python to mitigate issues in propagation from C# to Python + 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(); + 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); + // set environment variables directly in Python + using (PyDict kwargs = new PyDict()) + { + kwargs.SetItem("LANG_MAIN_BASE_FOLDERNAME", new PyString("bin")); + kwargs.SetItem("LANG_MAIN_STOP_SEARCH_FOLDERNAME", new PyString("python")); + kwargs.SetItem("DOPT_TOM_PLUGIN_LIBRARY_USAGE", new PyString("1")); + // Call function with no positional arguments, only keyword arguments + os.environ.update.Invoke(new PyTuple(), kwargs); + } tomWrapperPipelines = Py.Import("tom_plugin.pipeline"); } } diff --git a/dopt.TOM/dopt.TOM.csproj b/dopt.TOM/dopt.TOM.csproj index 92c9f75..4c31f94 100644 --- a/dopt.TOM/dopt.TOM.csproj +++ b/dopt.TOM/dopt.TOM.csproj @@ -3,7 +3,7 @@ netstandard2.0 x64 - 0.1.3-alpha1 + 0.1.3 x64 diff --git a/dopt.TOMTests/Tests.cs b/dopt.TOMTests/Tests.cs index 5c06f55..284a985 100644 --- a/dopt.TOMTests/Tests.cs +++ b/dopt.TOMTests/Tests.cs @@ -4,7 +4,7 @@ [TestClass] public sealed class PluginTests { - public const string rtPath = @"A:\Arbeitsaufgaben\MOP-TOM\tom-plugin-deploy\bin"; + public const string rtPath = @"A:\Arbeitsaufgaben\MOP-TOM\deployment\integration-test\bin"; public const string dummyData = @"Dummy_Dataset_N_1000.csv"; [TestMethod] public void RunPipelineOnTestData()