Open
Description
openedon Feb 2, 2019
System information
- Win10
- .NET Core 2.1/3.0 Preview 2
Issue
Let's say we do loading of data from CSV file using simple POCO class and forget to add LoadColumn
attribute on the properties. Then call to CreateTextLoader<T>/CreateTextReader<T>
fails with NullReferenceException
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.ML.Data.TextLoader.CreateTextReader[TInput](IHostEnvironment host, Boolean hasHeader, Char separator, Boolean allowQuotedStrings, Boolean supportSparse, Boolean trimWhitespace)
at MLConsoleApp1.Program.Main(String[] args) in MLConsoleApp1\Program.cs:line 54
which definitely not user friendly. I track down that to line https://github.com/dotnet/machinelearning/blob/master/src/Microsoft.ML.Data/DataLoadSave/Text/TextLoader.cs#L1344
where you delegate assertion to IHostEnvironment since I running LocalEnvironment, I believe that by default when running in Local environment proper default behavior would be just throw. Right now I could not even imaging that such big usability mistake was made by MS, so I have to manually clone project and compile it locally to track down this error.
Source code / logs
public class SentimentRow
{
public bool Sentiment { get; set; }
public string SentimentText { get; set; }
}
...
var mlContext = new MLContext();
var reader = mlContext.Data.CreateTextLoader<SentimentRow>(hasHeader: true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment