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] Remove depencency of seqan3 io #44

Merged
merged 4 commits into from
Jan 20, 2022

Conversation

Irallia
Copy link
Contributor

@Irallia Irallia commented Jan 5, 2022

Resolves #42

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"}}};.

I also created a new issue seqan/seqan3#2927 for accessing valid formats from file.

@vercel
Copy link

vercel bot commented Jan 5, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/seqan/sharg-parser/DxuTvYtkqc7W28An5H3BZvMrcwwV
✅ Preview: https://sharg-parser-git-fork-irallia-misc-removedepencenc-429826-seqan.vercel.app

@Irallia Irallia changed the title Misc/remove depencency of seqan3 io [MISC] Remove depencency of seqan3 io Jan 5, 2022
@Irallia Irallia force-pushed the MISC/Remove_depencency_of_seqan3_IO branch from bced500 to 4d386b9 Compare January 5, 2022 13:28
@Irallia Irallia self-assigned this Jan 5, 2022
@Irallia Irallia force-pushed the MISC/Remove_depencency_of_seqan3_IO branch from 4d386b9 to 20cf803 Compare January 5, 2022 13:40
Comment on lines 15 to 16
// 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};
Copy link
Contributor Author

@Irallia Irallia Jan 5, 2022

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?

Copy link
Member

@smehringer smehringer Jan 5, 2022

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.

Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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

@Irallia Irallia force-pushed the MISC/Remove_depencency_of_seqan3_IO branch from 20cf803 to c8046b4 Compare January 10, 2022 11:25
@Irallia
Copy link
Contributor Author

Irallia commented Jan 10, 2022

We have still have one io include in include/sharg/auxiliary.hpp:

#include <seqan3/io/stream/concept.hpp>

... seqan3::input_stream_over ...

EDIT: Will be done by #41

@Irallia Irallia force-pushed the MISC/Remove_depencency_of_seqan3_IO branch from c8046b4 to 605e1ca Compare January 10, 2022 11:27
@Irallia Irallia force-pushed the MISC/Remove_depencency_of_seqan3_IO branch from 605e1ca to 3376f2a Compare January 10, 2022 12:20
@Irallia Irallia force-pushed the MISC/Remove_depencency_of_seqan3_IO branch from a3d08e1 to 4ac919b Compare January 10, 2022 12:42
@Irallia Irallia force-pushed the MISC/Remove_depencency_of_seqan3_IO branch from 4ac919b to 99e578a Compare January 10, 2022 12:47
@Irallia Irallia force-pushed the MISC/Remove_depencency_of_seqan3_IO branch from 99e578a to 7fbaa96 Compare January 10, 2022 12:56
@codecov
Copy link

codecov bot commented Jan 10, 2022

Codecov Report

Merging #44 (915bddf) into master (f1104c8) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

❗ Current head 915bddf differs from pull request most recent head ec6060f. Consider uploading reports for the commit ec6060f to get more accurate results
Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
include/sharg/argument_parser.hpp 97.53% <ø> (ø)
include/sharg/validators.hpp 100.00% <100.00%> (ø)

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 f1104c8...ec6060f. Read the comment docs.

@Irallia

This comment has been minimized.

@Irallia Irallia requested review from a team and MitraDarja and removed request for a team January 10, 2022 13:03
@MitraDarja MitraDarja requested review from a team and smehringer and removed request for a team January 11, 2022 14:12
@Irallia Irallia requested review from MitraDarja and a team and removed request for a team and MitraDarja January 11, 2022 16:12
Copy link
Member

@smehringer smehringer left a 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
Comment on lines 31 to 34
* 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"}}};`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* 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>
Copy link
Member

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

Copy link
Member

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 Show resolved Hide resolved
include/sharg/validators.hpp Show resolved Hide resolved
Comment on lines 627 to 633
/*!\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 {};
}
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@smehringer smehringer left a 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!

*/
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)
Copy link
Member

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:

Suggested change
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,

Suggested change
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.

Copy link
Contributor Author

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 :)

@Irallia
Copy link
Contributor Author

Irallia commented Jan 19, 2022

I`ll rebase after your final review.

@smehringer
Copy link
Member

LGTM! When you rebase, you can also remove the seqan3/std/ranges include I think.

Signed-off-by: Lydia Buntrock <[email protected]>
Signed-off-by: Lydia Buntrock <[email protected]>
Signed-off-by: Lydia Buntrock <[email protected]>
@Irallia Irallia force-pushed the MISC/Remove_depencency_of_seqan3_IO branch from 915bddf to 204111a Compare January 20, 2022 11:12
@Irallia Irallia force-pushed the MISC/Remove_depencency_of_seqan3_IO branch from 204111a to ec6060f Compare January 20, 2022 11:18
@Irallia
Copy link
Contributor Author

Irallia commented Jan 20, 2022

LGTM! When you rebase, you can also remove the seqan3/std/ranges include I think.

There is no 'seqan3/std/ranges', just a new 'seqan3/std/algorithm' but that still fails, if I remove it.

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.

[MISC] Remove dependency of seqan3 IO
4 participants