-
Notifications
You must be signed in to change notification settings - Fork 180
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
refactor(robot-server): Use a non-nullable indexed enum for protocol_kind
#15822
refactor(robot-server): Use a non-nullable indexed enum for protocol_kind
#15822
Conversation
protocol_kind
SQL columnprotocol_kind
parsed_rtp = json.loads(run_time_parameter_values) | ||
else: | ||
parsed_rtp = {} | ||
if not isinstance(protocol_kind, ProtocolKind): |
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.
Now that protocol_kind: Form default is ProtocolKind.STANDARD, do we need to set it here explicitly?
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.
It's weird. We should not, but apparently we do. See the TODO
comments above.
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 cleans things up, and sets up the DB for faster access.
Thank you for putting this up!
46f8a52
to
f4e4207
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.
LGTM!
else {} | ||
) | ||
if not isinstance(protocol_kind, ProtocolKind): | ||
protocol_kind = ProtocolKind.STANDARD |
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 previously if the protocol kind specified in the request was not one of the defined kinds then it would raise an error. Are we intentionally ignoring it now?
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.
In the actual running server, FastAPI will still reject invalid protocolKind
s.
{
"id": "InvalidRequest",
"title": "Invalid Request",
"detail": "value is not a valid enumeration member; permitted: 'standard', 'quick-transfer'",
"source": {
"pointer": "/protocolKind"
},
"errorCode": "4000"
}
This is a weird unit-test-only conditional.
I think this can be fixed by adopting FastAPI's newer Annotated[...]
syntax instead of the current = Depends(...)
syntax, which I'm working on on the side.
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.
Ah right right!
Ya, switching to Annotated
would be nice.
1ab48ab
into
split-database-into-v5-and-v6
Overview
Some tweaks to the
protocol.protocol_kind
SQL column, to throw in with database changes that we're doing anyway.Changelog
str
.NULL
values.NULL
was semantically identical toProtocolKind.STANDARD
and was only stored by the 4->5 migration. Our older migration system could only addnullable=True
columns, but that's no longer the case.Database compatibility and merge sequencing
This intends to follow the plan started in #15650, which I understand as this:
The current public release is on schema 4.edge
is on schema 5. #15650 abandons schema 5 in favor of 5.1. After #15650 merges, this PR, and a few others from @sanni-t, will merge in quick succession to modify 5.1 in-place. Then, a final PR will turn 5.1 into 6 and create a 5.0->6 migration. The aim of all of this is to make a few improvements on the database from what we have in 5, without introducing a migration for each of those improvements, and without tossing away the schema-5.0 data that's accumulated on all our internal robots.Test Plan and Hands on Testing
EXPLAIN QUERY PLAN
in thesqlite3
CLI and make sure the index is working properly.Otherwise, I'm leaning on automated tests.
Review requests
Risk assessment
This will make the final PR in the plan, which finalizes the 5->6 split, slightly more complicated. It's one more change that we have to remember to handle correctly.