-
Notifications
You must be signed in to change notification settings - Fork 74
require FORCE_FLAG_KW uniformly for overwrites by put and create #721
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
base: main
Are you sure you want to change the base?
Conversation
tests are upcoming. |
irods/manager/data_object_manager.py
Outdated
if force: | ||
options[kw.FORCE_FLAG_KW]='' | ||
|
||
if self.exists(path) and kw.FORCE_FLAG_KW not in options: |
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.
Let's reverse the conditions as is being done in put
:
if self.exists(path) and kw.FORCE_FLAG_KW not in options: | |
if kw.FORCE_FLAG_KW not in options and self.exists(path): |
irods/manager/data_object_manager.py
Outdated
# TODO: We could deprecate and then later remove the force parameter in favor of FORCE_FLAG_KW. | ||
# That seems in order, since FORCE_FLAG_KW is the predominant pattern for asserting overwrites. |
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.
Go ahead and make an issue for this to attach to the TODO.
@@ -319,6 +319,9 @@ def put( | |||
) | |||
else: | |||
obj = irods_path | |||
if kw.FORCE_FLAG_KW not in options and self.exists(obj): | |||
raise ex.OVERWRITE_WITHOUT_FORCE_FLAG | |||
options.pop(kw.FORCE_FLAG_KW, None) |
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 say we don't need to pop
this, but if it seems better to do so, perhaps a "why" comment would be appropriate.
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.
Popping is a matter of form, I think. Don't allow options to be included for an API call that doesn't respect them
thought experiment question.... about blast radius... how many existing python applications will start to fail on their puts and need to be updated to support a force flag? second question... |
That's a good question. If we're introducing a breaking change, then that means a major version bump. |
#132 is a bug so, although this would be a behavioral change, I would expect this in a minor release if not a patch release since the current behavior is incorrect. Thoughts? |
If it's a bug, then yes. I agree it's fine to include it in a minor/patch release. |
i'm leaning to 'number go up' and people can tweak their force flag usage. we're not going to accidentally overwrite MORE things... it will be fewer things. |
No source installations will fail, because the default behavior of
We now have a situation in which we can leverage that then:
at which point we can really just delete the force keyword, even without deprecating first. |
I'm having trouble even reading that comment. force and negative and false... |
Sorry. It was written in a hurry and without clarity of thought. I'm going to redo it. |
So in a nutshell, we can replace
with
and in fact no applications should break. That's because despite removing the Note - I wouldn't be so very keen to get rid of an option like There are other uses of a force parameter in the PRC presently, but they don't alias to use of FORCE_FLAG_KW. |
that makes sense. thank you |
To the more direct question: Yes, definitely a valid concern, as applications will break due to the PRC now honoring the semantics of FORCE_FLAG_KW unless we change the default value of Yes, I need to do a little more work on the docstring... |
you know what? Nevermind. I'm wrong. @trel is correct. What a complete mess. The traditional behavior of allowing an overwrite despite the advertised default of force=False is, well, a blatant lie to the application developer. Unfortunately, to correct that, we have to break applications. We should wait for a major release. |
The alternative, if we want something sensible in v3.1.1 to somewhat solve this mess but not break others' source code, is this:
In this way, even in the upcoming The disadvantage: honoring the FORCE_FLAG_KW semantics will require that application programmers always explicitly specify That alone is really enough to make me opt to wait for a major release. |
If I understand the main confusion/difference... the PRC Not sure that helps resolve our decision here, but it's definitely part of the conversation. |
Adding this as a discush item. |
Ok, better idea ... since the CREATE/OPEN api doesn't respect That is, we won't change the As we've discussed, the deviation of this call from its advertised behavior (truncating / overwriting even with force=False) is a bug in itself, which most likely very few, or no-one, may be relying on. |
I agree that that is a much better approach. Making it clear that this is specific to the PRC is good. Alternative names:
|
More names:
|
|
Say no more. Now a part of this PR...! That was my first choice too, among Kory's suggestions. |
…write PUT will respect FORCE_FLAG_KW, to mimic iput; whereas create will now respect the force=True option when requested.
My thoughts
|
data loss from CREATE feels very wrong data loss (aka overwrite) from PUT does not feel as incorrect.. just a bit, perhaps, pointy/dangerous/surprising for a new user. |
No description provided.