Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix namespace issue in CSharpGenerator and some refactoring #339

Merged
merged 13 commits into from
Jun 12, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class Arguments : IPartitionedPathParserFactory
{
[Argument(ArgumentType.Multiple, HelpText = "Column definitions used to override the Partitioned Path Parser. Expected with the format name:type:numeric-source, e.g. col=MyFeature:R4:1",
ShortName = "col", SortOrder = 1)]
public Microsoft.ML.Runtime.Data.PartitionedFileLoader.Column[] Columns;
public PartitionedFileLoader.Column[] Columns;

[Argument(ArgumentType.AtMostOnce, HelpText = "Data type of each column.")]
public DataKind Type = DataKind.Text;
Expand Down
5 changes: 2 additions & 3 deletions src/Microsoft.ML.PipelineInference/TransformInference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ML;
using Microsoft.ML.Runtime.CommandLine;
using Microsoft.ML.Runtime.Data;
using Microsoft.ML.Runtime.EntryPoints;
Expand Down Expand Up @@ -712,7 +711,7 @@ public override IEnumerable<SuggestedTransform> Apply(IntermediateColumn[] colum
{
Name = columnNameQuoted.ToString(),
Source = columnNameQuoted.ToString(),
ResultType = ML.Transforms.DataKind.R4
ResultType = ML.Data.DataKind.R4
Copy link
Contributor

@TomFinley TomFinley Jun 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResultType = ML.Data.DataKind.R4 [](start = 28, length = 32)

Huh... this is problematic. Classes in runtime referring to the entry-point derived API. I know you didn't do this, but this is a serious problem.

});
}

Expand All @@ -721,7 +720,7 @@ public override IEnumerable<SuggestedTransform> Apply(IntermediateColumn[] colum
ch.Info("Suggested conversion to numeric for boolean features.");
var args = new SubComponent<IDataTransform, SignatureDataTransform>("Convert",
new[] { $"{columnArgument}type=R4" });
var epInput = new ML.Transforms.ColumnTypeConverter { Column = epColumns.ToArray(), ResultType = ML.Transforms.DataKind.R4 };
var epInput = new ML.Transforms.ColumnTypeConverter { Column = epColumns.ToArray(), ResultType = ML.Data.DataKind.R4 };
ColumnRoutingStructure.AnnotatedName[] columnsSource =
epColumns.Select(c => new ColumnRoutingStructure.AnnotatedName { IsNumeric = false, Name = c.Name }).ToArray();
ColumnRoutingStructure.AnnotatedName[] columnsDest =
Expand Down
363 changes: 177 additions & 186 deletions src/Microsoft.ML/CSharpApi.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using System.Reflection;
using Microsoft.ML.Runtime.CommandLine;
using Microsoft.ML.Runtime.Internal.Tools;
using Microsoft.ML.Runtime.Internal.Utilities;
using Newtonsoft.Json.Linq;

Expand Down Expand Up @@ -67,13 +68,7 @@ public static JObject BuildAllManifests(IExceptionContext ectx, ModuleCatalog ca
{
var jField = new JObject();
jField[FieldNames.Name] = fieldInfo.Name;
var type = fieldInfo.PropertyType;
// Dive inside Optional.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Optional<>))
type = type.GetGenericArguments()[0];
// Dive inside Nullable.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
type = type.GetGenericArguments()[0];
var type = CSharpGeneratorUtils.ExtractOptionalOrNullableType(fieldInfo.PropertyType);
// Dive inside Var.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Var<>))
type = type.GetGenericArguments()[0];
Expand Down Expand Up @@ -308,14 +303,7 @@ private static JToken BuildTypeToken(IExceptionContext ectx, FieldInfo fieldInfo
jo[FieldNames.ItemType] = typeString;
return jo;
}

// Dive inside Optional.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Optional<>))
type = type.GetGenericArguments()[0];

// Dive inside Nullable.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
type = type.GetGenericArguments()[0];
type = CSharpGeneratorUtils.ExtractOptionalOrNullableType(type);

// Dive inside Var.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Var<>))
Expand Down
Loading