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

[FEATURE] Allow overwrite existing files, add flags for permission handling #2009

Conversation

Irallia
Copy link
Contributor

@Irallia Irallia commented Aug 6, 2020

Resolves seqan/product_backlog#50.

Please do not merge before the naming discussion of the enum on gitter has ended.

Existing Ideas:

enum output_file_open_mode
{
   overwritable / rewritable,
   exclusive
};

There is something in system.io from Microsoft that sounds good: https://docs.microsoft.com/de-de/dotnet/api/system.io.filemode?view=netcore-3.1 :

enum FileMode
{
    open_or_create,
    create_new
};
enum accept_existing_file
{
    true / yes,
    false / no
};

Rust:

enum OpenOptions
{
    create,
    create_new
};

2020-08-31

Discussion result:

enum output_file_open_options
{
    open_or_create,
    create_new
};

You call this validator like:

seqan3::output_file_validator{seqan3::output_file_open_options::open_or_create});

@Irallia Irallia self-assigned this Aug 6, 2020
@Irallia Irallia force-pushed the feature/argument_parser/allow_overwrite_existing_files branch 3 times, most recently from 497ff94 to b4ad152 Compare August 7, 2020 14:16
@codecov
Copy link

codecov bot commented Aug 10, 2020

Codecov Report

Merging #2009 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2009   +/-   ##
=======================================
  Coverage   97.95%   97.96%           
=======================================
  Files         264      264           
  Lines       10045    10050    +5     
=======================================
+ Hits         9840     9845    +5     
  Misses        205      205           
Impacted Files Coverage Δ
include/seqan3/argument_parser/validators.hpp 89.20% <100.00%> (+0.31%) ⬆️

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 205674c...c94d251. Read the comment docs.

Copy link
Member

@joergi-w joergi-w left a comment

Choose a reason for hiding this comment

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

Thank you for this draft PR! I agree with the implementation and the tests are actually good (they cover all combinations of file formats and the boolean flag). I think after cleaning up the comments you can switch it to a "real" PR.

@@ -600,10 +600,16 @@ template <typename file_t = void>
class output_file_validator : public file_validator_base
{
public:
//!\brief Stores, if it is valid to overwrite the output file.
bool allow_overwrite = false; // ToDo: bool oder enum? Für jedes File einzeln entscheiden, also zum Pfad dazugeben? Oder als Vektor angeben?
Copy link
Member

Choose a reason for hiding this comment

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

append cannot be implemented with the argument parser, as the user receives the file name and opens the file themself (with or without append flag). So I suggest to only focus on the binary distinction of the output file "may exist or not".

Note: If we would not handle it at all, the decision (of throwing an error if the file exists) could be still be made by the app developer after obtaining the filename.

include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
@Irallia Irallia marked this pull request as ready for review August 17, 2020 08:47
@Irallia Irallia force-pushed the feature/argument_parser/allow_overwrite_existing_files branch 6 times, most recently from 71b2c62 to 21fa77e Compare August 26, 2020 10:59
@Irallia Irallia requested a review from joergi-w August 28, 2020 09:21
Copy link
Member

@joergi-w joergi-w left a comment

Choose a reason for hiding this comment

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

Mostly documentation ideas...

doc/tutorial/argument_parser/index.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
@@ -575,6 +574,15 @@ class input_file_validator : public file_validator_base
}
};

//!\brief Stores, if it is valid to overwrite the output file.
enum output_file_open_mode
Copy link
Member

Choose a reason for hiding this comment

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

Question (no need to change, just an opinion):
How about naming it accept_existing_file?
Because mode expresses nothing useful about the function of this enum.

include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
test/unit/argument_parser/format_parse_validators_test.cpp Outdated Show resolved Hide resolved
test/unit/argument_parser/format_parse_validators_test.cpp Outdated Show resolved Hide resolved
test/unit/argument_parser/format_parse_validators_test.cpp Outdated Show resolved Hide resolved
@Irallia Irallia requested a review from joergi-w August 28, 2020 14:57
Copy link
Member

@joergi-w joergi-w left a comment

Choose a reason for hiding this comment

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

Thanks! 👍

@joergi-w joergi-w requested review from a team and marehr and removed request for a team August 28, 2020 15:08
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.

Waiting on naming

@eseiler
Copy link
Member

eseiler commented Aug 31, 2020

@Irallia Irallia force-pushed the feature/argument_parser/allow_overwrite_existing_files branch 2 times, most recently from 3fc5b0a to 85ee726 Compare August 31, 2020 10:45
@Irallia Irallia requested a review from marehr August 31, 2020 11:01
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.

first round :)

include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
test/snippet/argument_parser/validators_output_file.cpp Outdated Show resolved Hide resolved
test/unit/argument_parser/format_parse_validators_test.cpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
test/unit/argument_parser/format_parse_validators_test.cpp Outdated Show resolved Hide resolved
test/unit/argument_parser/format_parse_validators_test.cpp Outdated Show resolved Hide resolved
@Irallia Irallia force-pushed the feature/argument_parser/allow_overwrite_existing_files branch from 85ee726 to 7632f75 Compare September 3, 2020 17:04
@Irallia Irallia requested a review from marehr September 3, 2020 17:14
@marehr
Copy link
Member

marehr commented Sep 8, 2020

Core-Meeting 2020-09-08

We want semi-regularity (that means default constructible) and as default case is conservative with seqan3::output_file_open_options::create_new.

@Irallia Irallia force-pushed the feature/argument_parser/allow_overwrite_existing_files branch 2 times, most recently from dda81ea to bed6158 Compare September 8, 2020 11:26
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 didn't go through all test cases. Thank you!

include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
test/snippet/argument_parser/validators_output_file.cpp Outdated Show resolved Hide resolved
test/unit/argument_parser/format_parse_validators_test.cpp Outdated Show resolved Hide resolved
test/unit/argument_parser/format_parse_validators_test.cpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
@Irallia Irallia requested a review from marehr September 8, 2020 19:48
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.

Sorry for being late; This is just some nail polish :)

include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
include/seqan3/argument_parser/validators.hpp Outdated Show resolved Hide resolved
test/snippet/argument_parser/validators_output_file.cpp Outdated Show resolved Hide resolved
test/unit/argument_parser/format_parse_validators_test.cpp Outdated Show resolved Hide resolved
test/unit/argument_parser/format_parse_validators_test.cpp Outdated Show resolved Hide resolved
test/unit/argument_parser/format_parse_validators_test.cpp Outdated Show resolved Hide resolved
@Irallia Irallia force-pushed the feature/argument_parser/allow_overwrite_existing_files branch from 171f5e5 to a85540b Compare September 22, 2020 13:39
…ermission

[TEST] Update validator test
[DOC] Update changelog, update (tutorial) documentation and code documentation

Signed-off-by: Lydia Buntrock <lydia.buntrock@fu-berlin.de>
@Irallia Irallia force-pushed the feature/argument_parser/allow_overwrite_existing_files branch from a85540b to c94d251 Compare September 22, 2020 13:56
@Irallia Irallia requested a review from marehr September 23, 2020 08:38
@marehr marehr merged commit bc5e30a into seqan:master Sep 28, 2020
@joergi-w
Copy link
Member

@seqan/core Can we still include this in the current 3.0.2 release or do we have to wait for the next one? I think many applications can already benefit from this.

@eseiler eseiler mentioned this pull request Sep 28, 2020
27 tasks
@marehr
Copy link
Member

marehr commented Sep 28, 2020

@joergi-w We didn't plan it for this release and I think we shouldn't do last minute changes.

@Irallia We noticed that you put the changelog entry in the 3.0.2 section, can you create a new PR that moves that in the 3.0.3 section?

Irallia added a commit to Irallia/seqan3 that referenced this pull request Sep 28, 2020
…gs for permission handling' PR (seqan#2009)

Signed-off-by: Lydia Buntrock <lydia.buntrock@fu-berlin.de>
@Irallia
Copy link
Contributor Author

Irallia commented Sep 28, 2020

@Irallia We noticed that you put the changelog entry in the 3.0.2 section, can you create a new PR that moves that in the 3.0.3 section?

Done in: #2177

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.

Allow to overwrite existing output files.
4 participants