-
Notifications
You must be signed in to change notification settings - Fork 7
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] Remove depencency of seqan3 io #44
[MISC] Remove depencency of seqan3 io #44
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/seqan/sharg-parser/DxuTvYtkqc7W28An5H3BZvMrcwwV |
bced500
to
4d386b9
Compare
4d386b9
to
20cf803
Compare
// Give the seqan3 file type as a template argument to get all valid extensions for this file. | ||
sharg::input_file_validator<seqan3::sequence_file_input<>> validator3{}; | ||
// Give the sharg file type as a template argument to get all valid extensions for this file. | ||
sharg::input_file_validator validator3{seqan3::sequence_file_input<>::valid_formats}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed testing the snippets and unfortunately I get an error for the new notation:
Consolidate compiler generated dependencies of target validators_3_snippet
[ 40%] Building CXX object CMakeFiles/validators_3_snippet.dir/validators_3.cpp.o
/Users/lydia/Repos/sharg-parser/test/snippet/validators_input_file_ext_from_file.cpp: In function 'int main()':
/Users/lydia/Repos/sharg-parser/test/snippet/validators_input_file_ext_from_file.cpp:16:88: error: expected primary-expression before '}' token
16 | sharg::input_file_validator validator3{seqan3::sequence_file_input<>::valid_formats};
| ^
/Users/lydia/Repos/sharg-parser/test/snippet/validators_input_file_ext_from_file.cpp:16:88: error: no matching function for call to 'sharg::input_file_validator::input_file_validator(<brace-enclosed initializer list>)'
In addition, I need with the spelling then further the include: <seqan3/io/sequence_file/input.hpp>
, or was that clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ops. I was to quick. It seems like you access the extensions like this:
seqan3::detail::valid_file_extensions<typename seqan3::sequence_file_input<>::valid_formats>()
I did not know that there is no nice way yet to access the extensions. I don't remember why the file class itself does not have a member for this. @eseiler Do you remember? There is nothing in the core meeting notes. I feel like someone had a say in this but I just don't why the file shouldn't have a member with the allowed extensions like
seqan3::sequence_file_input<>::file_extensions
As an alternative we could add a helper function
seqan3::get_file_extensions<seqan3::sequence_file_input<>>()
that just calls the detail function, or make the detail function public.
Alternative
We could also remove this example for now. As @Irallia mentioned, the snippet will this way need the seqan3 include anyway. Which we don't want. So maybe this has to be deleted anyway or moved to IO snippets. Then this can be tackled as a follow up in seqan3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with the helper is that it is detail
.
I'm not sure why it isn't a member, maybe we never discussed it.
I only remember that we discussed compression extensions.
In the end, I implemented compression extension like this https://github.com/seqan/raptor/blob/45de7f8d3ce5f21a0f5bd9ceb35173acbfa5867d/include/raptor/argument_parsing/validators.hpp#L159-L184
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the IO part in this PR from the argument parser and make this a seqan3 issue about how to access the extensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created an issue for this:
seqan/seqan3#2927
Feel free to add anything or rewrite it.
CHANGELOG.md
Outdated
|
||
#### I/O | ||
|
||
To avoid using seqan3::io we changed the usage of the `seqan3::input_file_validator` from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid using seqan3::io we changed the usage of the `seqan3::input_file_validator` from | |
* To avoid using seqan3::io we changed the usage of the `seqan3::input_file_validator` from |
20cf803
to
c8046b4
Compare
We have still have one io include in
EDIT: Will be done by #41 |
c8046b4
to
605e1ca
Compare
605e1ca
to
3376f2a
Compare
a3d08e1
to
4ac919b
Compare
4ac919b
to
99e578a
Compare
99e578a
to
7fbaa96
Compare
Codecov Report
@@ Coverage Diff @@
## master #44 +/- ##
==========================================
- Coverage 95.23% 95.21% -0.03%
==========================================
Files 13 13
Lines 923 919 -4
==========================================
- Hits 879 875 -4
Misses 44 44
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost done.
CHANGELOG.md
Outdated
* To avoid using seqan3::io we changed the usage of the `seqan3::input_file_validator` and | ||
`seqan3::output_file_validator`, you now have to give the formats explicitly: | ||
`sharg::input_file_validator validator{std::vector{std::string{"exe"}, std::string{"fasta"}}};` and | ||
`sharg::output_file_validator validator{sharg::output_file_open_options::create_new, std::vector{std::string{"exe"}, std::string{"fasta"}}};`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* To avoid using seqan3::io we changed the usage of the `seqan3::input_file_validator` and | |
`seqan3::output_file_validator`, you now have to give the formats explicitly: | |
`sharg::input_file_validator validator{std::vector{std::string{"exe"}, std::string{"fasta"}}};` and | |
`sharg::output_file_validator validator{sharg::output_file_open_options::create_new, std::vector{std::string{"exe"}, std::string{"fasta"}}};`. | |
* In order to avoid using the seqan3 I/O module, you now have to give a list of file extensions explicitly to `sharg::input_file_validator` and | |
`sharg::output_file_validator`: For example `sharg::input_file_validator validator{std::vector<std::string>{{"exe"}, {"fasta"}}};`. Please follow https://github.com/seqan/seqan3/issues/2927 to see how the list of file extensions can be extracted from seqan3 files. |
@@ -12,12 +12,12 @@ | |||
|
|||
#pragma once | |||
|
|||
#include <seqan3/std/algorithm> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can fix that in a separate PR. I will make a follow up issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed here #47
include/sharg/validators.hpp
Outdated
/*!\brief The default extensions of `file_t`. | ||
* \returns A list of default extensions for `file_t`, will be empty if `file_t` is `void`. | ||
* | ||
* \details | ||
* | ||
* If `file_t` does name a valid seqan3 file type that contains a static member `valid_formats` returns the | ||
* extensions of that `file_t` type. Otherwise returns an empty list. | ||
*/ | ||
static std::vector<std::string> default_extensions() | ||
{ | ||
if constexpr (!std::same_as<file_t, void>) | ||
return seqan3::detail::valid_file_extensions<typename file_t::valid_formats>(); | ||
return {}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove the entire function as it makes no sense anymore to provide it? This should also be mentioned in the changelog then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I had to add another function, for not given extensions.
a37a868
to
a6e904f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ONly a single thing!
include/sharg/validators.hpp
Outdated
*/ | ||
explicit output_file_validator(output_file_open_options const mode, | ||
std::vector<std::string> extensions = default_extensions()) | ||
explicit output_file_validator(output_file_open_options const mode, std::vector<std::string> extensions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can do this:
explicit output_file_validator(output_file_open_options const mode, std::vector<std::string> extensions) | |
explicit output_file_validator(output_file_open_options const mode, std::vector<std::string> extensions = {}) |
Which will construct an empty std::vector<std::string>{}
. If it doesn't work,
explicit output_file_validator(output_file_open_options const mode, std::vector<std::string> extensions) | |
explicit output_file_validator(output_file_open_options const mode, std::vector<std::string> extensions = std::vector<std::string>{}) |
Will work for sure.
Your solution works well too but this way we only need a single constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that it took so long. The first version already worked :)
I`ll rebase after your final review. |
LGTM! When you rebase, you can also remove the |
Signed-off-by: Lydia Buntrock <[email protected]>
Signed-off-by: Lydia Buntrock <[email protected]>
Signed-off-by: Lydia Buntrock <[email protected]>
Signed-off-by: Lydia Buntrock <[email protected]>
915bddf
to
204111a
Compare
204111a
to
ec6060f
Compare
There is no 'seqan3/std/ranges', just a new 'seqan3/std/algorithm' but that still fails, if I remove it. |
Resolves #42
To avoid using seqan3::io we changed the usage of the
seqan3::input_file_validator
andseqan3::output_file_validator
, you now have to give the formats explicitly:sharg::input_file_validator validator{std::vector{std::string{"exe"}, std::string{"fasta"}}};
andsharg::output_file_validator validator{sharg::output_file_open_options::create_new, std::vector{std::string{"exe"}, std::string{"fasta"}}};
.I also created a new issue seqan/seqan3#2927 for accessing valid formats from file.