15
15
using Microsoft . ML . Runtime . EntryPoints ;
16
16
using Microsoft . ML . Runtime . EntryPoints . JsonUtils ;
17
17
using Microsoft . ML . Runtime . FastTree ;
18
+ using Microsoft . ML . Runtime . ImageAnalytics ;
18
19
using Microsoft . ML . Runtime . Internal . Calibration ;
19
20
using Microsoft . ML . Runtime . Internal . Utilities ;
20
21
using Microsoft . ML . Runtime . Learners ;
22
+ using Microsoft . ML . Runtime . LightGBM ;
23
+ using Microsoft . ML . Runtime . Model . Onnx ;
21
24
using Microsoft . ML . Runtime . PCA ;
25
+ using Microsoft . ML . Runtime . PipelineInference ;
26
+ using Microsoft . ML . Runtime . SymSgd ;
22
27
using Microsoft . ML . Runtime . TextAnalytics ;
28
+ using Microsoft . ML . Transforms ;
23
29
using Newtonsoft . Json ;
24
30
using Newtonsoft . Json . Linq ;
25
31
using Xunit ;
@@ -237,37 +243,19 @@ private string GetBuildPrefix()
237
243
[ Fact ( Skip = "Execute this test if you want to regenerate ep-list and _manifest.json" ) ]
238
244
public void RegenerateEntryPointCatalog ( )
239
245
{
246
+ var ( epListContents , jObj ) = BuildManifests ( ) ;
247
+
240
248
var buildPrefix = GetBuildPrefix ( ) ;
241
249
var epListFile = buildPrefix + "_ep-list.tsv" ;
242
- var manifestFile = buildPrefix + "_manifest.json" ;
243
250
244
251
var entryPointsSubDir = Path . Combine ( ".." , "Common" , "EntryPoints" ) ;
245
252
var catalog = ModuleCatalog . CreateInstance ( Env ) ;
246
253
var epListPath = GetBaselinePath ( entryPointsSubDir , epListFile ) ;
247
254
DeleteOutputPath ( epListPath ) ;
248
255
249
- var regex = new Regex ( @"\r\n?|\n" , RegexOptions . Compiled ) ;
250
- File . WriteAllLines ( epListPath , catalog . AllEntryPoints ( )
251
- . Select ( x => string . Join ( "\t " ,
252
- x . Name ,
253
- regex . Replace ( x . Description , "" ) ,
254
- x . Method . DeclaringType ,
255
- x . Method . Name ,
256
- x . InputType ,
257
- x . OutputType )
258
- . Replace ( Environment . NewLine , "" ) )
259
- . OrderBy ( x => x ) ) ;
260
-
256
+ File . WriteAllLines ( epListPath , epListContents ) ;
261
257
262
- var jObj = JsonManifestUtils . BuildAllManifests ( Env , catalog ) ;
263
-
264
- //clean up the description from the new line characters
265
- if ( jObj [ FieldNames . TopEntryPoints ] != null && jObj [ FieldNames . TopEntryPoints ] is JArray )
266
- {
267
- foreach ( JToken entry in jObj [ FieldNames . TopEntryPoints ] . Children ( ) )
268
- if ( entry [ FieldNames . Desc ] != null )
269
- entry [ FieldNames . Desc ] = regex . Replace ( entry [ FieldNames . Desc ] . ToString ( ) , "" ) ;
270
- }
258
+ var manifestFile = buildPrefix + "_manifest.json" ;
271
259
var manifestPath = GetBaselinePath ( entryPointsSubDir , manifestFile ) ;
272
260
DeleteOutputPath ( manifestPath ) ;
273
261
@@ -280,20 +268,49 @@ public void RegenerateEntryPointCatalog()
280
268
}
281
269
}
282
270
283
-
284
271
[ Fact ]
285
272
public void EntryPointCatalog ( )
286
273
{
274
+ var ( epListContents , jObj ) = BuildManifests ( ) ;
275
+
287
276
var buildPrefix = GetBuildPrefix ( ) ;
288
277
var epListFile = buildPrefix + "_ep-list.tsv" ;
289
- var manifestFile = buildPrefix + "_manifest.json" ;
290
278
291
279
var entryPointsSubDir = Path . Combine ( ".." , "Common" , "EntryPoints" ) ;
292
280
var catalog = ModuleCatalog . CreateInstance ( Env ) ;
293
281
var path = DeleteOutputPath ( entryPointsSubDir , epListFile ) ;
294
282
283
+ File . WriteAllLines ( path , epListContents ) ;
284
+
285
+ CheckEquality ( entryPointsSubDir , epListFile ) ;
286
+
287
+ var manifestFile = buildPrefix + "_manifest.json" ;
288
+ var jPath = DeleteOutputPath ( entryPointsSubDir , manifestFile ) ;
289
+ using ( var file = File . OpenWrite ( jPath ) )
290
+ using ( var writer = new StreamWriter ( file ) )
291
+ using ( var jw = new JsonTextWriter ( writer ) )
292
+ {
293
+ jw . Formatting = Formatting . Indented ;
294
+ jObj . WriteTo ( jw ) ;
295
+ }
296
+
297
+ CheckEquality ( entryPointsSubDir , manifestFile ) ;
298
+ Done ( ) ;
299
+ }
300
+
301
+ private ( IEnumerable < string > epListContents , JObject manifest ) BuildManifests ( )
302
+ {
303
+ Env . ComponentCatalog . RegisterAssembly ( typeof ( LightGbmBinaryPredictor ) . Assembly ) ;
304
+ Env . ComponentCatalog . RegisterAssembly ( typeof ( TensorFlowTransform ) . Assembly ) ;
305
+ Env . ComponentCatalog . RegisterAssembly ( typeof ( ImageLoaderTransform ) . Assembly ) ;
306
+ Env . ComponentCatalog . RegisterAssembly ( typeof ( SymSgdClassificationTrainer ) . Assembly ) ;
307
+ Env . ComponentCatalog . RegisterAssembly ( typeof ( AutoInference ) . Assembly ) ;
308
+ Env . ComponentCatalog . RegisterAssembly ( typeof ( SaveOnnxCommand ) . Assembly ) ;
309
+
310
+ var catalog = ModuleCatalog . CreateInstance ( Env ) ;
311
+
295
312
var regex = new Regex ( @"\r\n?|\n" , RegexOptions . Compiled ) ;
296
- File . WriteAllLines ( path , catalog . AllEntryPoints ( )
313
+ var epListContents = catalog . AllEntryPoints ( )
297
314
. Select ( x => string . Join ( "\t " ,
298
315
x . Name ,
299
316
regex . Replace ( x . Description , "" ) ,
@@ -302,39 +319,27 @@ public void EntryPointCatalog()
302
319
x . InputType ,
303
320
x . OutputType )
304
321
. Replace ( Environment . NewLine , "" ) )
305
- . OrderBy ( x => x ) ) ;
322
+ . OrderBy ( x => x ) ;
306
323
307
- CheckEquality ( entryPointsSubDir , epListFile ) ;
308
-
309
- var jObj = JsonManifestUtils . BuildAllManifests ( Env , catalog ) ;
324
+ var manifest = JsonManifestUtils . BuildAllManifests ( Env , catalog ) ;
310
325
311
326
//clean up the description from the new line characters
312
- if ( jObj [ FieldNames . TopEntryPoints ] != null && jObj [ FieldNames . TopEntryPoints ] is JArray )
327
+ if ( manifest [ FieldNames . TopEntryPoints ] != null && manifest [ FieldNames . TopEntryPoints ] is JArray )
313
328
{
314
- foreach ( JToken entry in jObj [ FieldNames . TopEntryPoints ] . Children ( ) )
329
+ foreach ( JToken entry in manifest [ FieldNames . TopEntryPoints ] . Children ( ) )
315
330
if ( entry [ FieldNames . Desc ] != null )
316
331
entry [ FieldNames . Desc ] = regex . Replace ( entry [ FieldNames . Desc ] . ToString ( ) , "" ) ;
317
332
}
318
333
319
- var jPath = DeleteOutputPath ( entryPointsSubDir , manifestFile ) ;
320
- using ( var file = File . OpenWrite ( jPath ) )
321
- using ( var writer = new StreamWriter ( file ) )
322
- using ( var jw = new JsonTextWriter ( writer ) )
323
- {
324
- jw . Formatting = Formatting . Indented ;
325
- jObj . WriteTo ( jw ) ;
326
- }
327
-
328
- CheckEquality ( entryPointsSubDir , manifestFile ) ;
329
- Done ( ) ;
334
+ return ( epListContents , manifest ) ;
330
335
}
331
336
332
337
[ Fact ]
333
338
public void EntryPointInputBuilderOptionals ( )
334
339
{
335
- var catelog = ModuleCatalog . CreateInstance ( Env ) ;
340
+ var catalog = ModuleCatalog . CreateInstance ( Env ) ;
336
341
337
- InputBuilder ib1 = new InputBuilder ( Env , typeof ( LogisticRegression . Arguments ) , catelog ) ;
342
+ InputBuilder ib1 = new InputBuilder ( Env , typeof ( LogisticRegression . Arguments ) , catalog ) ;
338
343
// Ensure that InputBuilder unwraps the Optional<string> correctly.
339
344
var weightType = ib1 . GetFieldTypeOrNull ( "WeightColumn" ) ;
340
345
Assert . True ( weightType . Equals ( typeof ( string ) ) ) ;
@@ -1794,12 +1799,14 @@ public void EntryPointEvaluateRanking()
1794
1799
[ Fact ]
1795
1800
public void EntryPointLightGbmBinary ( )
1796
1801
{
1802
+ Env . ComponentCatalog . RegisterAssembly ( typeof ( LightGbmBinaryPredictor ) . Assembly ) ;
1797
1803
TestEntryPointRoutine ( "breast-cancer.txt" , "Trainers.LightGbmBinaryClassifier" ) ;
1798
1804
}
1799
1805
1800
1806
[ Fact ]
1801
1807
public void EntryPointLightGbmMultiClass ( )
1802
1808
{
1809
+ Env . ComponentCatalog . RegisterAssembly ( typeof ( LightGbmBinaryPredictor ) . Assembly ) ;
1803
1810
TestEntryPointRoutine ( GetDataPath ( @"iris.txt" ) , "Trainers.LightGbmClassifier" ) ;
1804
1811
}
1805
1812
@@ -3736,6 +3743,8 @@ public void EntryPointWordEmbeddings()
3736
3743
[ Fact ]
3737
3744
public void EntryPointTensorFlowTransform ( )
3738
3745
{
3746
+ Env . ComponentCatalog . RegisterAssembly ( typeof ( TensorFlowTransform ) . Assembly ) ;
3747
+
3739
3748
TestEntryPointPipelineRoutine ( GetDataPath ( "Train-Tiny-28x28.txt" ) , "col=Label:R4:0 col=Placeholder:R4:1-784" ,
3740
3749
new [ ] { "Transforms.TensorFlowScorer" } ,
3741
3750
new [ ]
0 commit comments