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

Extract TestFrameworkCommon Project, remove dependency of TestFramework from FT #4346

Merged
merged 16 commits into from
Oct 30, 2019

Conversation

frank-dong-ms-zz
Copy link
Contributor

  1. Extract TestFrameworkCommon from TestFramework
    a. Extract CommonUtilities method, move some utilities from BaseTestClass to CommonUtilities
    b. Move some test attributes from TestFramework to TestFrameworkCommon
    c. Move TestDataset from TestFramework to TestFrameworkCommon and fix corresponding
    reference
    d. Move some schema compare method from TestDataPipeBase to CommonUtilities
    e. TestFrameworkCommon only have public dependency, no internal class dependency
  2. Remove dependency of TestFramework from FT
    a. Remove dependency of TestFramework from FT, now FT dependent on TestFrameworkCommon
    b. Remove unnecessary dependency of Maml from FT
  3. Remove duplicate CompareVec method, also fix bug in CompareVec method
    a. Remove duplicate CompareVec method from CoreBaseTestClass, TestDataPipeBase and
    CopyColumnEstimatorTests, move CompareVec method to CommonUtilities and fix reference
    b. Fix bug in CompareVec method from CoreBaseTestClass class, original line 125 seems problematic.

@frank-dong-ms-zz frank-dong-ms-zz requested a review from a team as a code owner October 17, 2019 20:35
var v2Indices = v2.GetIndices();
for (; ; )
{
int iv1 = v1.IsDense ? iiv1 : iiv1 < v2Indices.Length ? v1Indices[iiv1] : v1.Length;
Copy link
Contributor Author

@frank-dong-ms-zz frank-dong-ms-zz Oct 17, 2019

Choose a reason for hiding this comment

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

v2Indices [](start = 53, length = 9)

Seems like a bug to me, should be v1Indices #Resolved

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! Yes, it does appear to be a bug. Can you please check the callers who are using this function and how those tests are passing?


In reply to: 336252686 [](ancestors = 336252686)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TestEntryPoints class is using this method, these tests will pass as long as v1 and v2 has same indices length, this happens to be true in these tests


In reply to: 336584593 [](ancestors = 336584593,336252686)

@codecov
Copy link

codecov bot commented Oct 17, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@9215ba9). Click here to learn what that means.
The diff coverage is 89.25%.

@@            Coverage Diff            @@
##             master    #4346   +/-   ##
=========================================
  Coverage          ?    74.7%           
=========================================
  Files             ?      885           
  Lines             ?   155046           
  Branches          ?    16903           
=========================================
  Hits              ?   115833           
  Misses            ?    34493           
  Partials          ?     4720
Flag Coverage Δ
#Debug 74.7% <89.25%> (?)
#production 70.22% <ø> (?)
#test 74.7% <89.25%> (?)
Impacted Files Coverage Δ
...est/Microsoft.ML.Tests/Scenarios/GetColumnTests.cs 100% <ø> (ø)
...est/Microsoft.ML.Predictor.Tests/TestPredictors.cs 66.95% <ø> (ø)
...ft.ML.Tests/TrainerEstimators/TrainerEstimators.cs 92.72% <ø> (ø)
...cenarios/Api/Estimators/MultithreadedPrediction.cs 100% <ø> (ø)
...osoft.ML.Tests/Transformers/WordEmbeddingsTests.cs 100% <ø> (ø)
...TestFrameworkCommon/Attributes/AttributeHelpers.cs 0% <ø> (ø)
...estFrameworkCommon/Attributes/OnnxFactAttribute.cs 88.88% <ø> (ø)
test/Microsoft.ML.Tests/AnomalyDetectionTests.cs 100% <ø> (ø)
...ML.Tests/Scenarios/IrisPlantClassificationTests.cs 100% <ø> (ø)
...ests/TrainerEstimators/MatrixFactorizationTests.cs 97.84% <ø> (ø)
... and 52 more

@frank-dong-ms-zz frank-dong-ms-zz requested a review from a team as a code owner October 18, 2019 00:02
<!--<PackageReference Include="Microsoft.ML" Version="1.3.1" />
<PackageReference Include="Microsoft.ML.Ensemble" Version="0.15.1" />
<PackageReference Include="Microsoft.ML.FastTree" Version="1.3.1" />-->
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
Copy link
Contributor

@harishsk harishsk Oct 21, 2019

Choose a reason for hiding this comment

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

I am guessing this is no longer needed? If not, can you please delete it? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, will remove these


In reply to: 337122073 [](ancestors = 337122073)

CheckSameSchemas(data1.Schema, data3.Schema);
CheckSameSchemas(data1.Schema, data4.Schema);
CheckSameSchemas(data1.Schema, data5.Schema);
CommonUtilities.CheckSameSchemas(data1.Schema, data2.Schema);
Copy link
Contributor

@harishsk harishsk Oct 21, 2019

Choose a reason for hiding this comment

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

CommonUtilities [](start = 12, length = 15)

Does CommonUtilities sounds a bit too generic as a name? How about TestCommon or TestUtilities? I would appreciate it if another reviewer can chime in on this on whether this needs to be changed or okay as is. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is good suggestion, will modify this


In reply to: 337126027 [](ancestors = 337126027)


private static void Fail(bool relax, string fmt, params object[] args)
{
Log("*** Failure: " + fmt, args);
Copy link
Member

@eerhardt eerhardt Oct 21, 2019

Choose a reason for hiding this comment

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

This won't fail the test. Instead of Fail we should use the Assert class in xunit. #Resolved

return f;
}

[Conditional("DEBUG")]
Copy link
Member

@eerhardt eerhardt Oct 21, 2019

Choose a reason for hiding this comment

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

I don't understand why we have these methods. These are tests, you should use the Assert class in xunit. If any conditions fail, it should fail the test, no matter if this is DEBUG or not. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is copied from Contracts Utilities class and this is also widely used in our test project like below, so are these also abuse and should be fixed?

protected bool EqualTypes(DataViewType type1, DataViewType type2, bool exactTypes)
{
Contracts.AssertValue(type1);
Contracts.AssertValue(type2);

        return exactTypes ? type1.Equals(type2) : type1.SameSizeAndItemType(type2);
    }

In reply to: 337248885 [](ancestors = 337248885)

Copy link
Member

@eerhardt eerhardt Oct 21, 2019

Choose a reason for hiding this comment

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

Just Assert.IsNotNull instead of Contracts.AssertValue #Resolved

</ItemGroup>

<ItemGroup>
<NativeAssemblyReference Include="LdaNative" />
Copy link
Member

@eerhardt eerhardt Oct 22, 2019

Choose a reason for hiding this comment

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

I don't believe these add any value, since we never actually execute the TestFrameworkCommon project. These NativeAssemblyReference are only necessary for projects that get executed (like real test projects).

You can remove this whole ItemGroup. #Resolved

Copy link
Contributor Author

@frank-dong-ms-zz frank-dong-ms-zz Oct 22, 2019

Choose a reason for hiding this comment

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

I see, thanks, will remove these.
Copied these from TestFramework project, then I realized there are some tests in TestFramework and TestFramework project needs these, but sounds like TestFramework project shouldn't have any real test cases to me?


In reply to: 337707632 [](ancestors = 337707632)

{
public static class TestCommon
{
public static string GetOutputPath(string name, string outDir)
Copy link
Member

@eerhardt eerhardt Oct 22, 2019

Choose a reason for hiding this comment

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

This seems backwards to me. Shouldn't outDir go before name? Just like how Path.Combine(outDir, name) does? #Closed

Copy link
Contributor

@harishsk harishsk left a comment

Choose a reason for hiding this comment

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

:shipit:

@codemzs
Copy link
Member

codemzs commented Oct 24, 2019

@frank-dong-ms Thanks and looks good to me!

Copy link
Member

@codemzs codemzs left a comment

Choose a reason for hiding this comment

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

:shipit:

@frank-dong-ms-zz frank-dong-ms-zz merged commit 36fab9b into dotnet:master Oct 30, 2019
@frank-dong-ms-zz frank-dong-ms-zz deleted the nightly-build branch November 6, 2019 05:25
@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.

5 participants