From 2a7232b1151d2725667db24db8e6744a7d2179fb Mon Sep 17 00:00:00 2001 From: Michael Sharp Date: Wed, 3 Jan 2024 12:09:28 -0700 Subject: [PATCH 1/5] Split out non concurrent test collections. --- Microsoft.ML.sln | 22 ++++++++ .../Properties/AssemblyInfo.cs | 2 + .../Properties/AssemblyInfo.cs | 2 + .../Properties/AssemblyInfo.cs | 1 + .../Properties/AssemblyInfo.cs | 2 +- .../Properties/AssemblyInfo.cs | 1 + .../Properties/AssemblyInfo.cs | 1 + .../UnitTests/TestResourceDownload.cs | 2 +- .../Microsoft.ML.TensorFlow.Tests.csproj | 32 +++++++++++ .../TensorFlowEstimatorTests.cs | 0 .../TensorflowTests.cs | 0 .../Microsoft.ML.Tests/DatabaseLoaderTests.cs | 55 +++++++++++++------ .../Microsoft.ML.Tests.csproj | 22 -------- .../Microsoft.ML.TorchSharp.Tests.csproj | 42 ++++++++++++++ .../NerTests.cs | 0 .../ObjectDetectionTests.cs | 0 .../QATests.cs | 13 ----- .../TextClassificationTests.cs | 0 18 files changed, 143 insertions(+), 54 deletions(-) create mode 100644 test/Microsoft.ML.TensorFlow.Tests/Microsoft.ML.TensorFlow.Tests.csproj rename test/{Microsoft.ML.Tests => Microsoft.ML.TensorFlow.Tests}/TensorFlowEstimatorTests.cs (100%) rename test/{Microsoft.ML.Tests/ScenariosWithDirectInstantiation => Microsoft.ML.TensorFlow.Tests}/TensorflowTests.cs (100%) create mode 100644 test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj rename test/{Microsoft.ML.Tests => Microsoft.ML.TorchSharp.Tests}/NerTests.cs (100%) rename test/{Microsoft.ML.Tests => Microsoft.ML.TorchSharp.Tests}/ObjectDetectionTests.cs (100%) rename test/{Microsoft.ML.Tests => Microsoft.ML.TorchSharp.Tests}/QATests.cs (94%) rename test/{Microsoft.ML.Tests => Microsoft.ML.TorchSharp.Tests}/TextClassificationTests.cs (100%) diff --git a/Microsoft.ML.sln b/Microsoft.ML.sln index 5e81a5f3b0..2137c9eb15 100644 --- a/Microsoft.ML.sln +++ b/Microsoft.ML.sln @@ -170,6 +170,10 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Microsoft.ML.FSharp.Tests", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Data.Analysis.PerformanceTests", "test\Microsoft.Data.Analysis.PerformanceTests\Microsoft.Data.Analysis.PerformanceTests.csproj", "{FB8A8823-CC6C-4C2F-8539-05FBFB7C91CD}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.ML.TorchSharp.Tests", "test\Microsoft.ML.TorchSharp.Tests\Microsoft.ML.TorchSharp.Tests.csproj", "{AB8D68F1-6C3E-41FD-B0EC-A093E009341D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.ML.TensorFlow.Tests", "test\Microsoft.ML.TensorFlow.Tests\Microsoft.ML.TensorFlow.Tests.csproj", "{763FF013-8309-4680-A769-B54E7BB99612}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -798,6 +802,22 @@ Global {FB8A8823-CC6C-4C2F-8539-05FBFB7C91CD}.Release|Any CPU.Build.0 = Release|Any CPU {FB8A8823-CC6C-4C2F-8539-05FBFB7C91CD}.Release|x64.ActiveCfg = Release|Any CPU {FB8A8823-CC6C-4C2F-8539-05FBFB7C91CD}.Release|x64.Build.0 = Release|Any CPU + {AB8D68F1-6C3E-41FD-B0EC-A093E009341D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AB8D68F1-6C3E-41FD-B0EC-A093E009341D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AB8D68F1-6C3E-41FD-B0EC-A093E009341D}.Debug|x64.ActiveCfg = Debug|Any CPU + {AB8D68F1-6C3E-41FD-B0EC-A093E009341D}.Debug|x64.Build.0 = Debug|Any CPU + {AB8D68F1-6C3E-41FD-B0EC-A093E009341D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AB8D68F1-6C3E-41FD-B0EC-A093E009341D}.Release|Any CPU.Build.0 = Release|Any CPU + {AB8D68F1-6C3E-41FD-B0EC-A093E009341D}.Release|x64.ActiveCfg = Release|Any CPU + {AB8D68F1-6C3E-41FD-B0EC-A093E009341D}.Release|x64.Build.0 = Release|Any CPU + {763FF013-8309-4680-A769-B54E7BB99612}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {763FF013-8309-4680-A769-B54E7BB99612}.Debug|Any CPU.Build.0 = Debug|Any CPU + {763FF013-8309-4680-A769-B54E7BB99612}.Debug|x64.ActiveCfg = Debug|Any CPU + {763FF013-8309-4680-A769-B54E7BB99612}.Debug|x64.Build.0 = Debug|Any CPU + {763FF013-8309-4680-A769-B54E7BB99612}.Release|Any CPU.ActiveCfg = Release|Any CPU + {763FF013-8309-4680-A769-B54E7BB99612}.Release|Any CPU.Build.0 = Release|Any CPU + {763FF013-8309-4680-A769-B54E7BB99612}.Release|x64.ActiveCfg = Release|Any CPU + {763FF013-8309-4680-A769-B54E7BB99612}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -881,6 +901,8 @@ Global {C3D82402-F207-4F19-8C57-5AF0FBAF9682} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4} {041CB5CD-5832-413E-A894-D9DBED210B16} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4} {FB8A8823-CC6C-4C2F-8539-05FBFB7C91CD} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4} + {AB8D68F1-6C3E-41FD-B0EC-A093E009341D} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4} + {763FF013-8309-4680-A769-B54E7BB99612} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {41165AF1-35BB-4832-A189-73060F82B01D} diff --git a/src/Microsoft.ML.Core/Properties/AssemblyInfo.cs b/src/Microsoft.ML.Core/Properties/AssemblyInfo.cs index 433ad2fa1c..68b9250eeb 100644 --- a/src/Microsoft.ML.Core/Properties/AssemblyInfo.cs +++ b/src/Microsoft.ML.Core/Properties/AssemblyInfo.cs @@ -14,6 +14,8 @@ [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.OnnxTransformerTest" + PublicKey.Value)] [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.AutoML.Tests" + PublicKey.Value)] [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.PerformanceTests" + PublicKey.Value)] +[assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.TorchSharp.Tests" + PublicKey.TestValue)] +[assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.TensorFlow.Tests" + PublicKey.TestValue)] [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.EntryPoints" + PublicKey.Value)] [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.Maml" + PublicKey.Value)] diff --git a/src/Microsoft.ML.Data/Properties/AssemblyInfo.cs b/src/Microsoft.ML.Data/Properties/AssemblyInfo.cs index c0b9e1782c..12c25255d5 100644 --- a/src/Microsoft.ML.Data/Properties/AssemblyInfo.cs +++ b/src/Microsoft.ML.Data/Properties/AssemblyInfo.cs @@ -14,6 +14,8 @@ [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.TimeSeries.Tests" + PublicKey.Value)] [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.PerformanceTests" + PublicKey.Value)] [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.AutoML.Tests" + PublicKey.Value)] +[assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.TorchSharp.Tests" + PublicKey.TestValue)] +[assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.TensorFlow.Tests" + PublicKey.TestValue)] [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.PerformanceTests" + PublicKey.Value)] [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.EntryPoints" + PublicKey.Value)] diff --git a/src/Microsoft.ML.ImageAnalytics/Properties/AssemblyInfo.cs b/src/Microsoft.ML.ImageAnalytics/Properties/AssemblyInfo.cs index 3f769a0e11..8dd51f9671 100644 --- a/src/Microsoft.ML.ImageAnalytics/Properties/AssemblyInfo.cs +++ b/src/Microsoft.ML.ImageAnalytics/Properties/AssemblyInfo.cs @@ -6,5 +6,6 @@ using Microsoft.ML; [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.Tests" + PublicKey.TestValue)] +[assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.TensorFlow.Tests" + PublicKey.TestValue)] [assembly: WantsToBeBestFriends] diff --git a/src/Microsoft.ML.TensorFlow/Properties/AssemblyInfo.cs b/src/Microsoft.ML.TensorFlow/Properties/AssemblyInfo.cs index 765fc88d8f..b3954bc10e 100644 --- a/src/Microsoft.ML.TensorFlow/Properties/AssemblyInfo.cs +++ b/src/Microsoft.ML.TensorFlow/Properties/AssemblyInfo.cs @@ -5,5 +5,5 @@ using System.Runtime.CompilerServices; using Microsoft.ML; -[assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.Tests" + PublicKey.TestValue)] +[assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.TensorFlow.Tests" + PublicKey.TestValue)] [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.Vision" + PublicKey.Value)] diff --git a/src/Microsoft.ML.Transforms/Properties/AssemblyInfo.cs b/src/Microsoft.ML.Transforms/Properties/AssemblyInfo.cs index 5468600d22..012d0eaf64 100644 --- a/src/Microsoft.ML.Transforms/Properties/AssemblyInfo.cs +++ b/src/Microsoft.ML.Transforms/Properties/AssemblyInfo.cs @@ -7,6 +7,7 @@ [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.Ensemble" + PublicKey.Value)] [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.Core.Tests" + PublicKey.TestValue)] +[assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.TensorFlow.Tests" + PublicKey.TestValue)] [assembly: InternalsVisibleTo(assemblyName: "RunTests" + InternalPublicKey.Value)] [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.EntryPoints" + PublicKey.Value)] diff --git a/src/Microsoft.ML.Vision/Properties/AssemblyInfo.cs b/src/Microsoft.ML.Vision/Properties/AssemblyInfo.cs index db4c6427b6..cd8cb8383a 100644 --- a/src/Microsoft.ML.Vision/Properties/AssemblyInfo.cs +++ b/src/Microsoft.ML.Vision/Properties/AssemblyInfo.cs @@ -6,3 +6,4 @@ using Microsoft.ML; [assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.Tests" + PublicKey.TestValue)] +[assembly: InternalsVisibleTo(assemblyName: "Microsoft.ML.TensorFlow.Tests" + PublicKey.TestValue)] diff --git a/test/Microsoft.ML.Core.Tests/UnitTests/TestResourceDownload.cs b/test/Microsoft.ML.Core.Tests/UnitTests/TestResourceDownload.cs index a473abd265..9b361cb946 100644 --- a/test/Microsoft.ML.Core.Tests/UnitTests/TestResourceDownload.cs +++ b/test/Microsoft.ML.Core.Tests/UnitTests/TestResourceDownload.cs @@ -14,7 +14,7 @@ using Xunit; using Xunit.Abstractions; -[assembly: CollectionBehavior(DisableTestParallelization = true)] +//[assembly: CollectionBehavior(DisableTestParallelization = true)] namespace Microsoft.ML.Core.Tests.UnitTests { diff --git a/test/Microsoft.ML.TensorFlow.Tests/Microsoft.ML.TensorFlow.Tests.csproj b/test/Microsoft.ML.TensorFlow.Tests/Microsoft.ML.TensorFlow.Tests.csproj new file mode 100644 index 0000000000..cf12310b38 --- /dev/null +++ b/test/Microsoft.ML.TensorFlow.Tests/Microsoft.ML.TensorFlow.Tests.csproj @@ -0,0 +1,32 @@ + + + Microsoft.ML.TensorFlow.Tests + Test + $(NoWarn) + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs b/test/Microsoft.ML.TensorFlow.Tests/TensorFlowEstimatorTests.cs similarity index 100% rename from test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs rename to test/Microsoft.ML.TensorFlow.Tests/TensorFlowEstimatorTests.cs diff --git a/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs b/test/Microsoft.ML.TensorFlow.Tests/TensorflowTests.cs similarity index 100% rename from test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs rename to test/Microsoft.ML.TensorFlow.Tests/TensorflowTests.cs diff --git a/test/Microsoft.ML.Tests/DatabaseLoaderTests.cs b/test/Microsoft.ML.Tests/DatabaseLoaderTests.cs index 4f7ebef980..3fbea9f62f 100644 --- a/test/Microsoft.ML.Tests/DatabaseLoaderTests.cs +++ b/test/Microsoft.ML.Tests/DatabaseLoaderTests.cs @@ -227,33 +227,54 @@ public void IrisSdcaMaximumEntropy() [X86X64FactAttribute("The SQLite un-managed code, SQLite.interop, only supports x86/x64 architectures.")] public void TestLoadDatetimeColumnWithNullValue() { - var connectionString = "DataSource=Dummy;Mode=Memory;Version=3;Timeout=120;Cache=Shared"; - using (var connection = new SQLiteConnection(connectionString)) + try { - connection.Open(); - using (var command = new SQLiteCommand(connection)) + var connectionString = "DataSource=Dummy;Mode=Memory;Version=3;Timeout=120;Cache=Shared"; + using (var connection = new SQLiteConnection(connectionString)) { - command.CommandText = """ + connection.Open(); + using (var command = new SQLiteCommand(connection)) + { + command.CommandText = """ BEGIN; CREATE TABLE IF NOT EXISTS Datetime (datetime Datetime NULL); INSERT INTO Datetime VALUES (NULL); INSERT INTO Datetime VALUES ('2018-01-01 00:00:00'); COMMIT; """; - command.ExecuteNonQuery(); + command.ExecuteNonQuery(); + } + } + var mlContext = new MLContext(seed: 1); + var loader = mlContext.Data.CreateDatabaseLoader(new DatabaseLoader.Column("datetime", DbType.DateTime, 0)); + var source = new DatabaseSource(SQLiteFactory.Instance, connectionString, "SELECT datetime FROM Datetime"); + var data = loader.Load(source); + var datetimes = data.GetColumn("datetime").ToArray(); + datetimes.Count().Should().Be(2); + + // Convert null value to DateTime.MinValue, aka 0001-01-01 00:00:00 + // This is the default behavior of TextLoader as well. + datetimes[0].Should().Be(DateTime.MinValue); + datetimes[1].Should().Be(new DateTime(2018, 1, 1, 0, 0, 0)); + } + finally + { + //Clean up in memory db if anything happens + var connectionString = "DataSource=Dummy;Mode=Memory;Version=3;Timeout=120;Cache=Shared"; + using (var connection = new SQLiteConnection(connectionString)) + { + connection.Open(); + using (var command = new SQLiteCommand(connection)) + { + command.CommandText = """ + BEGIN; + DROP TABLE IF EXISTS Datetime; + COMMIT; + """; + command.ExecuteNonQuery(); + } } } - var mlContext = new MLContext(seed: 1); - var loader = mlContext.Data.CreateDatabaseLoader(new DatabaseLoader.Column("datetime", DbType.DateTime, 0)); - var source = new DatabaseSource(SQLiteFactory.Instance, connectionString, "SELECT datetime FROM Datetime"); - var data = loader.Load(source); - var datetimes = data.GetColumn("datetime").ToArray(); - datetimes.Count().Should().Be(2); - - // Convert null value to DateTime.MinValue, aka 0001-01-01 00:00:00 - // This is the default behavior of TextLoader as well. - datetimes[0].Should().Be(DateTime.MinValue); - datetimes[1].Should().Be(new DateTime(2018, 1, 1, 0, 0, 0)); } /// diff --git a/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj b/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj index b74a92f484..b56709ffc2 100644 --- a/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj +++ b/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj @@ -6,8 +6,6 @@ Test $(NoWarn) - - None @@ -16,7 +14,6 @@ - @@ -32,21 +29,12 @@ - - - - - - - - - @@ -60,16 +48,13 @@ - - - @@ -78,13 +63,6 @@ - - - - - - - diff --git a/test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj b/test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj new file mode 100644 index 0000000000..173ad83cb6 --- /dev/null +++ b/test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj @@ -0,0 +1,42 @@ + + + Microsoft.ML.TorchSharp.Tests + Test + $(NoWarn) + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.ML.Tests/NerTests.cs b/test/Microsoft.ML.TorchSharp.Tests/NerTests.cs similarity index 100% rename from test/Microsoft.ML.Tests/NerTests.cs rename to test/Microsoft.ML.TorchSharp.Tests/NerTests.cs diff --git a/test/Microsoft.ML.Tests/ObjectDetectionTests.cs b/test/Microsoft.ML.TorchSharp.Tests/ObjectDetectionTests.cs similarity index 100% rename from test/Microsoft.ML.Tests/ObjectDetectionTests.cs rename to test/Microsoft.ML.TorchSharp.Tests/ObjectDetectionTests.cs diff --git a/test/Microsoft.ML.Tests/QATests.cs b/test/Microsoft.ML.TorchSharp.Tests/QATests.cs similarity index 94% rename from test/Microsoft.ML.Tests/QATests.cs rename to test/Microsoft.ML.TorchSharp.Tests/QATests.cs index 49f5d0a683..8684ce0a9d 100644 --- a/test/Microsoft.ML.Tests/QATests.cs +++ b/test/Microsoft.ML.TorchSharp.Tests/QATests.cs @@ -4,24 +4,11 @@ using System; using System.Collections.Generic; -using System.Data; -using System.Diagnostics; -using System.Linq; -using System.Text; -using Apache.Arrow; -using ICSharpCode.SharpZipLib.Tar; -using Microsoft.Data.Analysis; using Microsoft.ML.Data; using Microsoft.ML.RunTests; -using Microsoft.ML.Runtime; -using Microsoft.ML.TestFramework.Attributes; using Microsoft.ML.TorchSharp; -using Microsoft.ML.TorchSharp.NasBert; -using TorchSharp; -using TorchSharp.Modules; using Xunit; using Xunit.Abstractions; -using static TorchSharp.torch.utils; namespace Microsoft.ML.Tests { diff --git a/test/Microsoft.ML.Tests/TextClassificationTests.cs b/test/Microsoft.ML.TorchSharp.Tests/TextClassificationTests.cs similarity index 100% rename from test/Microsoft.ML.Tests/TextClassificationTests.cs rename to test/Microsoft.ML.TorchSharp.Tests/TextClassificationTests.cs From 28f0a238bdfb396f88b8b8a1af21a1ca3b19d982 Mon Sep 17 00:00:00 2001 From: Michael Sharp Date: Wed, 3 Jan 2024 13:52:36 -0700 Subject: [PATCH 2/5] Fix Core Tests --- test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj b/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj index 475eb5dbb1..e8817060c3 100644 --- a/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj +++ b/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj @@ -37,6 +37,7 @@ + From c1a5179c7f9ad2d246626dbea0500f271574bead Mon Sep 17 00:00:00 2001 From: Michael Sharp Date: Thu, 4 Jan 2024 13:34:13 -0700 Subject: [PATCH 3/5] removed torchsharp and tensorflow tests when not x64 --- eng/helix.proj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eng/helix.proj b/eng/helix.proj index 473774667d..4c5de6b839 100644 --- a/eng/helix.proj +++ b/eng/helix.proj @@ -70,6 +70,8 @@ + + From 64a5a7e58f856f17c29386e45adb8cec6606bbec Mon Sep 17 00:00:00 2001 From: Michael Sharp Date: Fri, 5 Jan 2024 15:42:23 -0700 Subject: [PATCH 4/5] fixes from pr comments --- .../UnitTests/TestResourceDownload.cs | 2 - .../Microsoft.ML.Tests/DatabaseLoaderTests.cs | 63 ++++++++----------- .../Microsoft.ML.TorchSharp.Tests.csproj | 2 - 3 files changed, 25 insertions(+), 42 deletions(-) diff --git a/test/Microsoft.ML.Core.Tests/UnitTests/TestResourceDownload.cs b/test/Microsoft.ML.Core.Tests/UnitTests/TestResourceDownload.cs index 9b361cb946..e3a2f6b49e 100644 --- a/test/Microsoft.ML.Core.Tests/UnitTests/TestResourceDownload.cs +++ b/test/Microsoft.ML.Core.Tests/UnitTests/TestResourceDownload.cs @@ -14,8 +14,6 @@ using Xunit; using Xunit.Abstractions; -//[assembly: CollectionBehavior(DisableTestParallelization = true)] - namespace Microsoft.ML.Core.Tests.UnitTests { public class TestResourceDownload : BaseTestBaseline diff --git a/test/Microsoft.ML.Tests/DatabaseLoaderTests.cs b/test/Microsoft.ML.Tests/DatabaseLoaderTests.cs index 3fbea9f62f..2c9b9ee010 100644 --- a/test/Microsoft.ML.Tests/DatabaseLoaderTests.cs +++ b/test/Microsoft.ML.Tests/DatabaseLoaderTests.cs @@ -227,54 +227,41 @@ public void IrisSdcaMaximumEntropy() [X86X64FactAttribute("The SQLite un-managed code, SQLite.interop, only supports x86/x64 architectures.")] public void TestLoadDatetimeColumnWithNullValue() { - try + var connectionString = "DataSource=Dummy;Mode=Memory;Version=3;Timeout=120;Cache=Shared"; + using (var connection = new SQLiteConnection(connectionString)) { - var connectionString = "DataSource=Dummy;Mode=Memory;Version=3;Timeout=120;Cache=Shared"; - using (var connection = new SQLiteConnection(connectionString)) + connection.Open(); + using (var command = new SQLiteCommand(connection)) { - connection.Open(); - using (var command = new SQLiteCommand(connection)) - { - command.CommandText = """ + // Make sure the table doesn't exist. + command.CommandText = """ BEGIN; - CREATE TABLE IF NOT EXISTS Datetime (datetime Datetime NULL); - INSERT INTO Datetime VALUES (NULL); - INSERT INTO Datetime VALUES ('2018-01-01 00:00:00'); + DROP TABLE IF EXISTS Datetime; COMMIT; """; - command.ExecuteNonQuery(); - } - } - var mlContext = new MLContext(seed: 1); - var loader = mlContext.Data.CreateDatabaseLoader(new DatabaseLoader.Column("datetime", DbType.DateTime, 0)); - var source = new DatabaseSource(SQLiteFactory.Instance, connectionString, "SELECT datetime FROM Datetime"); - var data = loader.Load(source); - var datetimes = data.GetColumn("datetime").ToArray(); - datetimes.Count().Should().Be(2); - - // Convert null value to DateTime.MinValue, aka 0001-01-01 00:00:00 - // This is the default behavior of TextLoader as well. - datetimes[0].Should().Be(DateTime.MinValue); - datetimes[1].Should().Be(new DateTime(2018, 1, 1, 0, 0, 0)); - } - finally - { - //Clean up in memory db if anything happens - var connectionString = "DataSource=Dummy;Mode=Memory;Version=3;Timeout=120;Cache=Shared"; - using (var connection = new SQLiteConnection(connectionString)) - { - connection.Open(); - using (var command = new SQLiteCommand(connection)) - { - command.CommandText = """ + command.ExecuteNonQuery(); + + command.CommandText = """ BEGIN; - DROP TABLE IF EXISTS Datetime; + CREATE TABLE IF NOT EXISTS Datetime (datetime Datetime NULL); + INSERT INTO Datetime VALUES (NULL); + INSERT INTO Datetime VALUES ('2018-01-01 00:00:00'); COMMIT; """; - command.ExecuteNonQuery(); - } + command.ExecuteNonQuery(); } } + var mlContext = new MLContext(seed: 1); + var loader = mlContext.Data.CreateDatabaseLoader(new DatabaseLoader.Column("datetime", DbType.DateTime, 0)); + var source = new DatabaseSource(SQLiteFactory.Instance, connectionString, "SELECT datetime FROM Datetime"); + var data = loader.Load(source); + var datetimes = data.GetColumn("datetime").ToArray(); + datetimes.Count().Should().Be(2); + + // Convert null value to DateTime.MinValue, aka 0001-01-01 00:00:00 + // This is the default behavior of TextLoader as well. + datetimes[0].Should().Be(DateTime.MinValue); + datetimes[1].Should().Be(new DateTime(2018, 1, 1, 0, 0, 0)); } /// diff --git a/test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj b/test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj index 173ad83cb6..5e7eeaf717 100644 --- a/test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj +++ b/test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj @@ -4,8 +4,6 @@ Test $(NoWarn) - - None From a8dfb406da61746fd992e19758104129f7e1f929 Mon Sep 17 00:00:00 2001 From: Michael Sharp Date: Fri, 5 Jan 2024 17:32:52 -0700 Subject: [PATCH 5/5] removing unnecessary line from the proj file --- test/Microsoft.ML.AutoML.Tests/Microsoft.ML.AutoML.Tests.csproj | 2 -- .../Microsoft.ML.CodeGenerator.Tests.csproj | 1 - test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj | 1 - .../Microsoft.ML.TensorFlow.Tests.csproj | 1 - test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj | 1 - .../Microsoft.ML.TorchSharp.Tests.csproj | 1 - 6 files changed, 7 deletions(-) diff --git a/test/Microsoft.ML.AutoML.Tests/Microsoft.ML.AutoML.Tests.csproj b/test/Microsoft.ML.AutoML.Tests/Microsoft.ML.AutoML.Tests.csproj index 39073412f3..dff9aea4b5 100644 --- a/test/Microsoft.ML.AutoML.Tests/Microsoft.ML.AutoML.Tests.csproj +++ b/test/Microsoft.ML.AutoML.Tests/Microsoft.ML.AutoML.Tests.csproj @@ -1,7 +1,5 @@  - $(NoWarn) - None diff --git a/test/Microsoft.ML.CodeGenerator.Tests/Microsoft.ML.CodeGenerator.Tests.csproj b/test/Microsoft.ML.CodeGenerator.Tests/Microsoft.ML.CodeGenerator.Tests.csproj index dd988c14fe..8e328c997c 100644 --- a/test/Microsoft.ML.CodeGenerator.Tests/Microsoft.ML.CodeGenerator.Tests.csproj +++ b/test/Microsoft.ML.CodeGenerator.Tests/Microsoft.ML.CodeGenerator.Tests.csproj @@ -1,7 +1,6 @@  - $(NoWarn) None diff --git a/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj b/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj index e8817060c3..20c173c8d7 100644 --- a/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj +++ b/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj @@ -4,7 +4,6 @@ Test 10.0 - $(NoWarn) None diff --git a/test/Microsoft.ML.TensorFlow.Tests/Microsoft.ML.TensorFlow.Tests.csproj b/test/Microsoft.ML.TensorFlow.Tests/Microsoft.ML.TensorFlow.Tests.csproj index cf12310b38..30b85c955e 100644 --- a/test/Microsoft.ML.TensorFlow.Tests/Microsoft.ML.TensorFlow.Tests.csproj +++ b/test/Microsoft.ML.TensorFlow.Tests/Microsoft.ML.TensorFlow.Tests.csproj @@ -2,7 +2,6 @@ Microsoft.ML.TensorFlow.Tests Test - $(NoWarn) diff --git a/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj b/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj index b56709ffc2..57b7dd3331 100644 --- a/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj +++ b/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj @@ -4,7 +4,6 @@ Microsoft.ML.Tests true Test - $(NoWarn) diff --git a/test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj b/test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj index 5e7eeaf717..32d6552e6d 100644 --- a/test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj +++ b/test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj @@ -2,7 +2,6 @@ Microsoft.ML.TorchSharp.Tests Test - $(NoWarn)