Skip to content

Modified how DataViewTypes are registered - #4187

Merged
bpstark merged 6 commits into
dotnet:masterfrom
bpstark:bug4121
Sep 13, 2019
Merged

Modified how DataViewTypes are registered#4187
bpstark merged 6 commits into
dotnet:masterfrom
bpstark:bug4121

Conversation

@bpstark

@bpstark bpstark commented Sep 7, 2019

Copy link
Copy Markdown
Contributor

The DataViewManager registers DataViewTypes to determine how to
represent the the data within ML.Net. However, there was a bug in how
types were being queried. Types that were being registered via an
Attribute were being added to the manager with only that Attribute.
However, when queried from the manager all custom Attributes were being
passed.
To solve this we need to only pass custom Attributes that are relevant
to the Manager. All Type attributes now inherit from a single
TypeAttribute class such that we can filter custom attributes for
relevant types.

Fixes #4121

The DataViewManager registers DataViewTypes to determine how to
represent the the data within ML.Net. However, there was a bug in how
types were being queried. Types that were being registered via an
Attribute were being added to the manager with only that Attribute.
However, when queried from the manager all custom Attributes were being
passed.
To solve this we need to only pass custom Attributes that are relevant
to the Manager. All Type attributes now inherit from a single
TypeAttribute class such that we can filter custom attributes for
relevant types.
@bpstark
bpstark requested a review from a team as a code owner September 7, 2019 00:13
@dnfclas

dnfclas commented Sep 7, 2019

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met. #Resolved

Comment thread src/Microsoft.ML.DataView/DataViewType.cs Outdated
Comment thread src/Microsoft.ML.Data/Data/DataViewTypeManager.cs Outdated
Comment thread src/Microsoft.ML.Data/Data/DataViewTypeManager.cs Outdated
@eerhardt

eerhardt commented Sep 9, 2019

Copy link
Copy Markdown
Member

We should use the scenario from #4121 to test whether this change fixes the problem. Use an [OnnxSequenceType] attribute with a [ColumnName] attribute and make sure you can execute the ONNX file correctly. #Resolved

@bpstark

bpstark commented Sep 9, 2019

Copy link
Copy Markdown
Contributor Author

@eerhardt The tests added here do capture the issue of #4121, I have simply reduced the issue down to its simplest forms to make it a unit testable component. #Resolved

Since the DataViewManager works only on DataViewTypeAttributes, we do
not need to subclass attributes, but only the filter on the
DataViewTypeAttribute instead.
@bpstark
bpstark requested a review from yaeldekel September 9, 2019 16:44
@eerhardt

eerhardt commented Sep 9, 2019

Copy link
Copy Markdown
Member

I have simply reduced the issue down to its simplest forms

There are things that can go wrong when doing that.

  1. The reduced scenario may not represent the original issue accurately.
  2. There may be more issues that need fixing in the original scenario than just the reduced first issue hit.
  3. In the future, someone may add/change code in the product that would break the original scenario, but not your reduced scenario test.

In a case like this, capturing the original scenario in a test case to ensure it is fixed, and prevent future regressions, is ideal. #Resolved

While the unit test added previously addressed the underlying issue,
this test case proves that the issue in Bug #4121 is now completely
resolved, and there should be no further issues.
Comment thread test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj Outdated
Comment thread test/Microsoft.ML.Tests/OnnxSequenceTypeWithAttributesTest.cs Outdated
Did not want to polute the repo with large models so was able to find an
existing model which had an appropriate output such that we could still
verify the same behavior.
Comment thread src/Microsoft.ML.Data/Data/DataViewTypeManager.cs Outdated
Brian Stark added 2 commits September 10, 2019 12:15
Since the the register function is part of the public API we cannot
remove/change it. However, I have marked that form of the call to be
obsolete, and instead have created a new register API which takes in
only a singular DataViewTypeAttribute. This will allow us to keep
existing functionality while still providing guidance on how the API
should actually be used. Once we increment the major version of the API
we can then remove the obsoleted version of register.
While working locally, the test were not working on the CI job. this
appeared to be due to issues with path for the model, as well as not
using OnnxFact.
@bpstark
bpstark requested a review from yaeldekel September 11, 2019 21:05
@eerhardt

eerhardt commented Sep 12, 2019

Copy link
Copy Markdown
Member

@wschin - can you comment on the changes? What were the scenarios necessary for having an Enumerable of attributes?

Looking at #3263 (the original PR) I assume it has to do with you can have multiple ImageTypeAttributes with different height and width values.

@bpstark, Can you explain why you made that change to the API? #Resolved

@bpstark

bpstark commented Sep 12, 2019

Copy link
Copy Markdown
Contributor Author

@eerhardt According to the usage the only types which are ever passed to the DataViewManager register function are subclassed from DataViewTypeAttribute. according to the schema doc which @yaeldekel referenced we are only allowed to ever have at most 1 DataViewTypeAttribute associated with a given member var. As such we can never have more than 1 attribute passed to the register function. #Resolved

@eerhardt

eerhardt commented Sep 12, 2019

Copy link
Copy Markdown
Member

Sounds fine to me. Please make sure @wschin signs off on this change, since he has the full background. #Resolved

@bpstark

bpstark commented Sep 12, 2019

Copy link
Copy Markdown
Contributor Author

@wschin could you please take a look at my change. #Resolved

@bpstark
bpstark merged commit 34cfdfb into dotnet:master Sep 13, 2019
@bpstark
bpstark deleted the bug4121 branch September 13, 2019 20:43
@ghost ghost locked as resolved and limited conversation to collaborators Mar 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using OnnxSequenceType and ColumnName attributes together doesn't work

6 participants