Skip to content

Make TextLoader.ArgumentsCore.Separator internal #2059

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

Merged
merged 6 commits into from
Jan 25, 2019

Conversation

mareklinka
Copy link
Contributor

Since TextLoader.ArgumentsCore.Separator is only used for the command line interface, #2041 aims to make the field internal so that it doesn't show for API users. In order to facilitate this hiding, the CmdParser.GetArgumentInfo had to be updated to reflect on both public and private fields of the provided type.

At the same time, the API-serving SeparatorChars field was renamed to simply Separators.

Work in progress. More fields might be turned internal, depending on discussion in the issue.

Fixes #2041

Allow CmdParser.GetArgumentInfo to search through non-public fields
@TomFinley TomFinley requested review from sfilipi, codemzs, yaeldekel, Ivanidzo4ka and TomFinley and removed request for sfilipi January 9, 2019 20:32
@@ -466,7 +466,7 @@ private static ArgumentInfo GetArgumentInfo(Type type, object defaults)
var map = new Dictionary<string, Argument>();
Argument def = null;

foreach (FieldInfo field in type.GetFields())
foreach (FieldInfo field in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
Copy link
Contributor

@TomFinley TomFinley Jan 9, 2019

Choose a reason for hiding this comment

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

BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance [](start = 55, length = 68)

Cool. Thank you for working on this @mareklinka! As mentioned in the associated issue, we might need to do something like this in one or two more places.

@mareklinka mareklinka force-pushed the feature/2041_HideSeparator branch from 16a5d4a to 2987cd9 Compare January 10, 2019 20:55
@mareklinka
Copy link
Contributor Author

As mentioned, I refactored the LightGbmArguments.UpdateParameters method to pay attention to the ArgumentAttribute. I wrote three simple unit tests as a safety net for the refactoring, these should be removed before merging as they don't provide any real value (and increase maintenance costs later on).

I was unsure whether to do any additional checks on the attribute (e.g. check Visibility, similar to what CmdParser.GetArgumentInfo does) - let me know if anything is necessary here, I'll add it.

cc @TomFinley

@Ivanidzo4ka
Copy link
Contributor

Ivanidzo4ka commented Jan 16, 2019

Can you also touch

foreach (var fieldInfo in _type.GetFields())

? #Resolved

@mareklinka
Copy link
Contributor Author

Just to let everyone involved here know, I will be be out of range of a computer for the next 7 days so if more changes are required, I'll work on them once I get back.

if (attribute == null)
{
continue;
}
Copy link
Member

Choose a reason for hiding this comment

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

} [](start = 20, length = 1)

stylistic nit: no { } for one line instructions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, force of habit. Fixed.


private ArgumentAttribute GetAttribute(FieldInfo field)
{
return field.GetCustomAttribute<ArgumentAttribute>(false);
Copy link
Member

@sfilipi sfilipi Jan 17, 2019

Choose a reason for hiding this comment

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

since it is used only inside the function above, keep it as a delegate inside that function.


namespace Microsoft.ML.RunTests
{
public class SmokeTests
Copy link
Member

Choose a reason for hiding this comment

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

public class SmokeTests [](start = 3, length = 24)

were you planning to remove those?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. Done.

@sfilipi
Copy link
Member

sfilipi commented Jan 17, 2019

thanks for working on this @mareklinka. It looks good to me, and i'll be good to sign off as soon as the SmokeTests.cs is gone.


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

@mareklinka mareklinka force-pushed the feature/2041_HideSeparator branch from 8ba84b7 to a2b2ebc Compare January 24, 2019 13:58
Small style fixes
@mareklinka mareklinka force-pushed the feature/2041_HideSeparator branch from a2b2ebc to f01c12f Compare January 24, 2019 13:59
@mareklinka mareklinka changed the title [WIP] Make TextLoader.ArgumentsCore.Separator internal Make TextLoader.ArgumentsCore.Separator internal Jan 24, 2019
@mareklinka
Copy link
Contributor Author

Alright, hopefully that should be everything. Removed the smoke tests and fixed the style issues. Merged with current master and resolved conflicts. Let's see if it checks out.

@codecov
Copy link

codecov bot commented Jan 24, 2019

Codecov Report

Merging #2059 into master will decrease coverage by 0.01%.
The diff coverage is 89.47%.

@@            Coverage Diff             @@
##           master    #2059      +/-   ##
==========================================
- Coverage   66.08%   66.06%   -0.02%     
==========================================
  Files         638      638              
  Lines      116423   116428       +5     
  Branches    14846    14847       +1     
==========================================
- Hits        76939    76921      -18     
- Misses      35231    35257      +26     
+ Partials     4253     4250       -3

Copy link
Contributor

@TomFinley TomFinley left a comment

Choose a reason for hiding this comment

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

This looks good to me, thank you @mareklinka! Sorry for delay...

Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka left a comment

Choose a reason for hiding this comment

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

:shipit:

@TomFinley TomFinley merged commit 1dd8c83 into dotnet:master Jan 25, 2019
@mareklinka mareklinka deleted the feature/2041_HideSeparator branch February 4, 2019 15:51
@ghost ghost locked as resolved and limited conversation to collaborators Mar 25, 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.

4 participants