Skip to content

Commit

Permalink
Minor cleanup.
Browse files Browse the repository at this point in the history
- Remove dead code in PredictionEngine.cs
- Fix build warnings
  • Loading branch information
eerhardt committed Apr 28, 2021
1 parent d8fe817 commit f4e4081
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.AutoML/Experiment/Experiment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class Experiment<TRunDetail, TMetrics> where TRunDetail : RunDetail
private readonly IList<SuggestedPipelineRunDetail> _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;
Expand Down
25 changes: 0 additions & 25 deletions src/Microsoft.ML.Data/Prediction/PredictionEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.ML.Data;
using Microsoft.ML.Runtime;

namespace Microsoft.ML
{

/// <summary>
/// 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.
Expand All @@ -19,7 +17,6 @@ internal sealed class PipeEngine<TDst>
where TDst : class, new()
{
private readonly ICursorable<TDst> _cursorablePipe;
private long _counter;

internal PipeEngine(IHostEnvironment env, IDataView pipe, bool ignoreMissingColumns, SchemaDefinition schemaDefinition = null)
{
Expand All @@ -28,12 +25,10 @@ internal PipeEngine(IHostEnvironment env, IDataView pipe, bool ignoreMissingColu
env.AssertValueOrNull(schemaDefinition);

_cursorablePipe = env.AsCursorable<TDst>(pipe, ignoreMissingColumns, schemaDefinition);
_counter = 0;
}

public IEnumerable<TDst> RunPipe(bool reuseRowObject)
{
var curCounter = _counter;
using (var cursor = _cursorablePipe.GetCursor())
{
TDst row = null;
Expand All @@ -44,16 +39,9 @@ public IEnumerable<TDst> 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++;
}
}

/// <summary>
Expand Down Expand Up @@ -114,19 +102,6 @@ public abstract class PredictionEngineBase<TSrc, TDst> : IDisposable
[BestFriend]
private protected ITransformer Transformer { get; }

[BestFriend]
private static Func<DataViewSchema, IRowToRowMapper> 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)
Expand Down

0 comments on commit f4e4081

Please sign in to comment.