-
Notifications
You must be signed in to change notification settings - Fork 178
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
Robot server maximum quick transfer protocols #15590
Conversation
…ic automatically checks the validity of the input remove manual validation of ProtocolKind form input remove redundant `invalid ProtocolKind` test in the create_protocol function of the POST /protocols endpoint. only check protocol limit for quick-transfer protocols
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.
Is the intent here that it's up to the client to react to this and delete a protocol record? why wouldn't we have automatic storage management where the oldest protocol is deleted when you upload a new one?
Yeah, the idea is that the client is responsible for managing the number of quick transfer protocols. |
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.
Looks good overall, I think these additions make sense and are in line with how we've done similar cases. Note below about a minor nitpick on how we gate the maximum number of protocols, but mostly a semantics thing. Aside from that all looks good, but I would update the title of the PR to be in line with our convention before merging.
for protocol in protocol_store.get_all() | ||
if protocol.protocol_kind == ProtocolKind.QUICK_TRANSFER.value | ||
] | ||
if len(quick_transfer_protocols) >= maximum_quick_transfer_protocols: |
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.
This check makes sense but would it be more semantically accurate to test for something like this? :
if (len(quick_transfer_protocols) + 1) > maximum_quick_transfer_protocols:
Because the protocol store is the selection of currently saved protocols, and we can assume it will never have a value greater than our maximum because of this creation case. Checking >=
seems to assume a failure of that rule, where as the len(...) + 1
greater than case assumes that we are below or at the limit and are checking to see if we would exceed it by adding this new protocol.
Either way they will achieve the same result, completely up to you.
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.
Looks good! It's a bit early for that comment as noted, but I don't think it's worth a big fuss.
default=20, | ||
gt=0, | ||
description=( | ||
'The maximum number of "quick transfer protocols" to allow before auto-deleting' |
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'm not sure what the right way to do this sort of thing is, but it is the case that this comment is inaccurate for the state of the code as-of merging this protocol - it's only in #15591 that the autodeletion is actually introduced. I think we should merge it; if we were stricter, I'd say we should have it not mention autodeletion here and then change it in that upcoming pr, but whatever.
… setting and return error if limit is reached (#15590) Co-authored-by: Brent Hagen <[email protected]>
Overview
Quick Transfer protocols are meant to be easy to set up and use protocols from the ODD, so
Let's introduce a robot server setting
maximum_quick_transfer_protocols
to set the maximum number of quick transfer protocols. Then let's use this setting to return a 400 error if we have reached the limit,Closes: PLAT-314 PLAT-317
Test Plan
Changelog
maximum_quick_transfer_protocols
robot server configReview requests
Risk assessment
Low, unreleased