From 77e65ff5a3e70f56b51438cbb14ec8c60eec8fa0 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Tue, 27 Apr 2021 11:40:18 -0500 Subject: [PATCH] Minor cleanup. - Remove dead code in PredictionEngine.cs - Fix build warnings --- .../Dynamic/TensorFlow/ImageClassification.cs | 3 ++- .../Experiment/Experiment.cs | 2 +- .../Prediction/PredictionEngine.cs | 25 ------------------- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/TensorFlow/ImageClassification.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/TensorFlow/ImageClassification.cs index f3201f33890..b88b82c1bc7 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/TensorFlow/ImageClassification.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/TensorFlow/ImageClassification.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using System.Net; +using System.Text; using ICSharpCode.SharpZipLib.GZip; using ICSharpCode.SharpZipLib.Tar; using Microsoft.ML; @@ -129,7 +130,7 @@ private static void Unzip(string path, string targetDir) Stream inStream = File.OpenRead(path); Stream gzipStream = new GZipInputStream(inStream); - TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream); + TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream, Encoding.ASCII); tarArchive.ExtractContents(targetDir); tarArchive.Close(); diff --git a/src/Microsoft.ML.AutoML/Experiment/Experiment.cs b/src/Microsoft.ML.AutoML/Experiment/Experiment.cs index 64a628b6bc7..8b8bbe09f30 100644 --- a/src/Microsoft.ML.AutoML/Experiment/Experiment.cs +++ b/src/Microsoft.ML.AutoML/Experiment/Experiment.cs @@ -28,7 +28,7 @@ internal class Experiment where TRunDetail : RunDetail private readonly IList _history; private readonly IChannel _logger; - private readonly string _operationCancelledMessage = "OperationCanceledException has been caught after maximum experiment time" + + private const string _operationCancelledMessage = "OperationCanceledException has been caught after maximum experiment time" + "was reached, and the running MLContext was stopped. Details: {0}"; private Timer _maxExperimentTimeTimer; diff --git a/src/Microsoft.ML.Data/Prediction/PredictionEngine.cs b/src/Microsoft.ML.Data/Prediction/PredictionEngine.cs index c1639958bdb..92ee5575d8f 100644 --- a/src/Microsoft.ML.Data/Prediction/PredictionEngine.cs +++ b/src/Microsoft.ML.Data/Prediction/PredictionEngine.cs @@ -4,13 +4,11 @@ using System; using System.Collections.Generic; -using System.IO; using Microsoft.ML.Data; using Microsoft.ML.Runtime; namespace Microsoft.ML { - /// /// Utility class to run the pipeline to completion and produce a strongly-typed IEnumerable as a result. /// Doesn't allocate memory for every row: instead, yields the same row object on every step. @@ -19,7 +17,6 @@ internal sealed class PipeEngine where TDst : class, new() { private readonly ICursorable _cursorablePipe; - private long _counter; internal PipeEngine(IHostEnvironment env, IDataView pipe, bool ignoreMissingColumns, SchemaDefinition schemaDefinition = null) { @@ -28,12 +25,10 @@ internal PipeEngine(IHostEnvironment env, IDataView pipe, bool ignoreMissingColu env.AssertValueOrNull(schemaDefinition); _cursorablePipe = env.AsCursorable(pipe, ignoreMissingColumns, schemaDefinition); - _counter = 0; } public IEnumerable RunPipe(bool reuseRowObject) { - var curCounter = _counter; using (var cursor = _cursorablePipe.GetCursor()) { TDst row = null; @@ -44,16 +39,9 @@ public IEnumerable RunPipe(bool reuseRowObject) cursor.FillValues(row); yield return row; - if (curCounter != _counter) - throw Contracts.Except("An attempt was made to keep iterating after the pipe has been reset."); } } } - - public void Reset() - { - _counter++; - } } /// @@ -114,19 +102,6 @@ public abstract class PredictionEngineBase : IDisposable [BestFriend] private protected ITransformer Transformer { get; } - [BestFriend] - private static Func StreamChecker(IHostEnvironment env, Stream modelStream) - { - env.CheckValue(modelStream, nameof(modelStream)); - return schema => - { - var pipe = DataViewConstructionUtils.LoadPipeWithPredictor(env, modelStream, new EmptyDataView(env, schema)); - var transformer = new TransformWrapper(env, pipe); - env.CheckParam(((ITransformer)transformer).IsRowToRowMapper, nameof(transformer), "Must be a row to row mapper"); - return ((ITransformer)transformer).GetRowToRowMapper(schema); - }; - } - [BestFriend] private protected PredictionEngineBase(IHostEnvironment env, ITransformer transformer, bool ignoreMissingColumns, SchemaDefinition inputSchemaDefinition = null, SchemaDefinition outputSchemaDefinition = null)