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

[MISC] argument parser: Move get_help_message to file_validator_base. #1691

Merged
merged 4 commits into from
Apr 8, 2020

Conversation

smehringer
Copy link
Member

Just DRY out some code

@smehringer smehringer requested a review from marehr March 25, 2020 14:07
@smehringer smehringer force-pushed the argument_parser_fix branch 2 times, most recently from a989652 to 3cff7d3 Compare March 25, 2020 14:40
@smehringer
Copy link
Member Author

@marehr polite ping

Copy link
Member

@marehr marehr left a comment

Choose a reason for hiding this comment

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

I'm not sure if omitting text is better for the user. I liked the output before, what are the benefits for the user?

I'm okay with putting a common function in the base to concat the extensions as a function and use it in the get_help_message.

include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Show resolved Hide resolved
test/unit/argument_parser/format_parse_validators_test.cpp Outdated Show resolved Hide resolved
@smehringer
Copy link
Member Author

I'm not sure if omitting text is better for the user. I liked the output before, what are the benefits for the user?

You are right, I didn't notice that there is no mention of the option being an input or output file. I thought there was some more, also regarding the writability stuff. The benefit is, that it poses less of a chance for inconsistencies. I worked on fixing seqan/sharg-parser#77 and adding the compression formats to the help page to each of the two (almost identical...) help page messages called for a DRY version to me.

I'm okay with putting a common function in the base to concat the extensions as a function and use it in the get_help_message.

I'll change it accordingly, and also take a look at the writability

@codecov
Copy link

codecov bot commented Mar 31, 2020

Codecov Report

Merging #1691 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    seqan/seqan3#1691      +/-   ##
==========================================
+ Coverage   97.65%   97.68%   +0.02%     
==========================================
  Files         237      237              
  Lines        9050     9059       +9     
==========================================
+ Hits         8838     8849      +11     
+ Misses        212      210       -2     
Impacted Files Coverage Δ
include/seqan3/argument_parser/validators.hpp 88.88% <100.00%> (+0.13%) ⬆️
include/seqan3/range/views/kmer_hash.hpp 100.00% <0.00%> (ø)
include/seqan3/range/views/take_until.hpp 98.11% <0.00%> (+3.99%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 93de9c7...800af3a. Read the comment docs.

@smehringer smehringer requested a review from marehr March 31, 2020 06:59
Copy link
Member

@marehr marehr left a comment

Choose a reason for hiding this comment

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

Looks great :)

Can you assign someone with proper english skills to double check the phrases? 🙈

@smehringer
Copy link
Member Author

😄 any suggestion? Usually, I would ask @eseiler...

@smehringer smehringer requested a review from rrahn April 2, 2020 06:02
return detail::to_string("Valid input file formats: [",
extensions | views::join(std::string{", "}),
"]");
return "The input file must exist and read permissions must be granted. " +
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure. Is that really necessary with the permissions? That kind of clutters the output. It is clear that you need to have permissions. If not you will get an exception saying that you don't have permissions.
I think if the description reads: An input file with a valid extension: [ext1, ext2, ...]
The other thing is An output file with a valid extension: [ext1, ext2, ...]
Then the code is

return valid_extensions_help_page_message("input file");

And the help page message assembles the string.
Then also it checks if valid extensions is empty and omits the part with the valid extensions. Also note, that we should talk about extensions and not formats.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure. Is that really necessary with the permissions? That kind of clutters the output. It is clear that you need to have permissions.

Well, although "it is obvious that you need them", it is a feature we provide to check for this and I thought this documentation helps to indicate this?

And whatever we decide about the permissions, I think it is important to note that the output file must not exist. This is not the usual behaviour by default as @joergi-w mentioned in his recent issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

And whatever we decide about the permissions, I think it is important to note that the output file must not exist. This is not the usual behaviour by default as @joergi-w mentioned in his recent issue.

Mhmm, I think it is not necessary but I have no strong feelings. But the other points should be adresed. valid formats ➡️ valid extension and if the extension set is empty this string should not be displayed at all.

@smehringer
Copy link
Member Author

I just rebased because there were merge conflicts

@smehringer smehringer requested a review from rrahn April 7, 2020 07:16
if (extensions.empty())
return "";
else
return detail::to_string("Valid file extensions are: [", extensions | views::join(std::string{", "}), "].");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return detail::to_string("Valid file extensions are: [", extensions | views::join(std::string{", "}), "].");
return detail::to_string("Valid file extensions are: [", extensions | std::views::join(std::string{", "}), "].");

And check that there is no seqan3 views join include.
Regarding detail::to_string. Isn't this part of the dependencies @marehr tried to remove from the argument parser? This could be written as str1 + str2 + str3

Copy link
Member Author

Choose a reason for hiding this comment

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

The detail::to_string is still present in many parts of the code. He sais this one is an open ToDo and he might reimplement the function so using it here won't make a difference?

Copy link
Member

Choose a reason for hiding this comment

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

This one is tough, because the seqan3::views::join isn't the same as the std::view::join.

I had to warkaround it, but it is okay for me to use seqan3::views::join here. Also keep the detail::to_string.

In this case it is fine as it is.

"Valid file extensions are: [fa, fasta, sam, bam].");

seqan3::input_file_validator validator2{};
EXPECT_EQ(validator2.get_help_page_message(), "The input file must exist and read permissions must be granted. ");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
EXPECT_EQ(validator2.get_help_page_message(), "The input file must exist and read permissions must be granted. ");
EXPECT_EQ(validator2.get_help_page_message(), "The input file must exist and read permissions must be granted.");

?

"Valid file formats are: [fa, fasta, sam, bam].");
seqan3::output_file_validator validator2{};
EXPECT_EQ(validator2.get_help_page_message(), "The output file must not exist already and write permissions must "
"be granted. ");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"be granted. ");
"be granted.");

?

@smehringer smehringer requested a review from rrahn April 7, 2020 11:01
@smehringer
Copy link
Member Author

@rrahn I still have no rights to restart jobs on Jenkins. The error is unrelated. Maybe you can restart Jenkins.

Copy link
Contributor

@rrahn rrahn left a comment

Choose a reason for hiding this comment

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

lgtm. I'll check jenkins for the rights.

@smehringer smehringer merged commit 1165343 into seqan:master Apr 8, 2020
wvdtoorn pushed a commit to wvdtoorn/seqan3 that referenced this pull request Apr 15, 2020
…seqan#1691)

* [MISC] argument parser: Refine get_help_page_message for in/output file validators.
@smehringer smehringer deleted the argument_parser_fix branch May 29, 2020 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants