Skip to content

Commit

Permalink
Put product version with git commit into model.zip/version.txt (#3173)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivanidzo4ka authored Apr 12, 2019
1 parent 326727f commit 37ed336
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Microsoft.ML.Core/Data/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using Microsoft.ML.Internal.Utilities;
Expand Down Expand Up @@ -304,9 +305,10 @@ public static RepositoryWriter CreateNew(Stream stream, IExceptionContext ectx =
Contracts.CheckValueOrNull(ectx);
ectx.CheckValue(stream, nameof(stream));
var rep = new RepositoryWriter(stream, ectx, useFileSystem);
var versionInfo = FileVersionInfo.GetVersionInfo(typeof(RepositoryWriter).Assembly.Location);
using (var ent = rep.CreateEntry(DirTrainingInfo, "Version.txt"))
using (var writer = Utils.OpenWriter(ent.Stream))
writer.WriteLine(typeof(RepositoryWriter).Assembly.GetName().Version);
writer.WriteLine(versionInfo.ProductVersion);
return rep;
}

Expand Down
3 changes: 2 additions & 1 deletion test/Microsoft.ML.Functional.Tests/ModelFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.ML.Calibrators;
using Microsoft.ML.Data;
using Microsoft.ML.Functional.Tests.Datasets;
Expand Down Expand Up @@ -67,7 +68,7 @@ public void DetermineNugetVersionFromModel()
{
// The only line in the file is the version of the model.
var line = reader.ReadLine();
Assert.Equal(@"1.0.0.0", line);
Assert.Matches(new Regex(@"(\d+).(\d+)\.(\d+)\.(\d+) \@BuiltBy:(.)* \@SrcCode:(.)*"), line);
}
}
}
Expand Down

0 comments on commit 37ed336

Please sign in to comment.