Skip to content

Commit 958dbf8

Browse files
authored
eliminate IFileInfo from CLI (dotnet#260)
1 parent 12a5d46 commit 958dbf8

File tree

7 files changed

+18
-70
lines changed

7 files changed

+18
-70
lines changed

src/mlnet.Test/ApprovalTests/ConsoleCodeGeneratorTests.cs

+9-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using Microsoft.ML.CLI.CodeGenerator.CSharp;
1111
using Microsoft.ML.Data;
1212
using Microsoft.VisualStudio.TestTools.UnitTesting;
13-
using mlnet.Test.Utilities;
1413

1514
namespace mlnet.Test
1615
{
@@ -33,10 +32,10 @@ public void GeneratedTrainCodeTest()
3332
MlTask = TaskKind.BinaryClassification,
3433
OutputBaseDir = null,
3534
OutputName = "MyNamespace",
36-
TrainDataset = new MockFileInfo("x:\\dummypath\\dummy_train.csv"),
37-
TestDataset = new MockFileInfo("x:\\dummypath\\dummy_test.csv"),
35+
TrainDataset = "x:\\dummypath\\dummy_train.csv",
36+
TestDataset = "x:\\dummypath\\dummy_test.csv",
3837
LabelName = "Label",
39-
ModelPath = new MockFileInfo("x:\\models\\model.zip")
38+
ModelPath = "x:\\models\\model.zip"
4039
});
4140

4241
(string trainCode, string projectCode, string helperCode) = consoleCodeGen.GenerateCode();
@@ -57,10 +56,10 @@ public void GeneratedProjectCodeTest()
5756
MlTask = TaskKind.BinaryClassification,
5857
OutputBaseDir = null,
5958
OutputName = "MyNamespace",
60-
TrainDataset = new MockFileInfo("x:\\dummypath\\dummy_train.csv"),
61-
TestDataset = new MockFileInfo("x:\\dummypath\\dummy_test.csv"),
59+
TrainDataset = "x:\\dummypath\\dummy_train.csv",
60+
TestDataset = "x:\\dummypath\\dummy_test.csv",
6261
LabelName = "Label",
63-
ModelPath = new MockFileInfo("x:\\models\\model.zip")
62+
ModelPath = "x:\\models\\model.zip"
6463
});
6564

6665
(string trainCode, string projectCode, string helperCode) = consoleCodeGen.GenerateCode();
@@ -81,10 +80,10 @@ public void GeneratedHelperCodeTest()
8180
MlTask = TaskKind.BinaryClassification,
8281
OutputBaseDir = null,
8382
OutputName = "MyNamespace",
84-
TrainDataset = new MockFileInfo("x:\\dummypath\\dummy_train.csv"),
85-
TestDataset = new MockFileInfo("x:\\dummypath\\dummy_test.csv"),
83+
TrainDataset = "x:\\dummypath\\dummy_train.csv",
84+
TestDataset = "x:\\dummypath\\dummy_test.csv",
8685
LabelName = "Label",
87-
ModelPath = new MockFileInfo("x:\\models\\model.zip")
86+
ModelPath = "x:\\models\\model.zip"
8887
});
8988

9089
(string trainCode, string projectCode, string helperCode) = consoleCodeGen.GenerateCode();

src/mlnet.Test/Utilities/MockFileInfo.cs

-18
This file was deleted.

src/mlnet/CodeGenerator/CSharp/CodeGenerator.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ internal string GenerateTrainCode(string usings, string trainer, List<string> tr
105105
Trainer = trainer,
106106
ClassLabels = classLabels,
107107
GeneratedUsings = usings,
108-
Path = settings.TrainDataset.FullName,
109-
TestPath = settings.TestDataset?.FullName,
108+
Path = settings.TrainDataset,
109+
TestPath = settings.TestDataset,
110110
TaskType = settings.MlTask.ToString(),
111111
Namespace = namespaceValue,
112112
LabelName = settings.LabelName,
113-
ModelPath = settings.ModelPath.FullName
113+
ModelPath = settings.ModelPath
114114
};
115115

116116
return trainingAndScoringCodeGen.TransformText();

src/mlnet/CodeGenerator/CSharp/CodeGeneratorSettings.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
using Microsoft.ML.Auto;
2-
using Microsoft.ML.CLI.Utilities.File;
32

43
namespace Microsoft.ML.CLI.CodeGenerator.CSharp
54
{
65
internal class CodeGeneratorSettings
76
{
87
internal string LabelName { get; set; }
98

10-
internal IFileInfo ModelPath { get; set; }
9+
internal string ModelPath { get; set; }
1110

1211
internal string OutputName { get; set; }
1312

1413
internal string OutputBaseDir { get; set; }
1514

16-
internal IFileInfo TrainDataset { get; set; }
15+
internal string TrainDataset { get; set; }
1716

18-
internal IFileInfo TestDataset { get; set; }
17+
internal string TestDataset { get; set; }
1918

2019
internal TaskKind MlTask { get; set; }
2120

src/mlnet/Commands/New/NewCommandHandler.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using Microsoft.ML.CLI.CodeGenerator.CSharp;
1010
using Microsoft.ML.CLI.Data;
1111
using Microsoft.ML.CLI.Utilities;
12-
using Microsoft.ML.CLI.Utilities.File;
1312
using Microsoft.ML.Data;
1413
using NLog;
1514

@@ -111,13 +110,13 @@ internal void GenerateProject(ColumnInferenceResults columnInference, Pipeline p
111110
columnInference,
112111
new CodeGeneratorSettings()
113112
{
114-
TrainDataset = new SystemFileInfo(settings.Dataset),
113+
TrainDataset = settings.Dataset.FullName,
115114
MlTask = taskKind,
116-
TestDataset = settings.TestDataset == null ? null : new SystemFileInfo(settings.TestDataset),
115+
TestDataset = settings.TestDataset?.FullName,
117116
OutputName = settings.Name,
118117
OutputBaseDir = settings.OutputPath.FullName,
119118
LabelName = labelName,
120-
ModelPath = new SystemFileInfo(modelPath)
119+
ModelPath = modelPath.FullName
121120
});
122121
codeGenerator.GenerateOutput();
123122
}

src/mlnet/Utilities/File/IFileInfo.cs

-11
This file was deleted.

src/mlnet/Utilities/File/SystemFileInfo.cs

-20
This file was deleted.

0 commit comments

Comments
 (0)