-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Model edits and bug fixes #17922
Model edits and bug fixes #17922
Conversation
mypy bug workaround no longer needed as we are no longer specifying a metaclass
Drop syntax that can be inferred from Mapped[] type hint: - basic datatypes - mapped_column() expression where the only argument is the datatype Ref: https://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html#migrating-an-existing-mapping
(incorrect type added in a prev. commit)
This is hard to manually inspect - any chance you generated a schema for our model before and after and checked the diff was empty or made sense where there are differences? |
@@ -100,7 +100,7 @@ def _set_previous_progress(self, outputs): | |||
|
|||
workflow_invocation_step_state = model.WorkflowRequestStepState() | |||
workflow_invocation_step_state.workflow_step_id = step_id | |||
workflow_invocation_step_state.value = True |
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.
We have to fix these column definitions. This is just a wild line of code.
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.
Please merge #17902 and follow up with a proper type definitions for that column. The truth is it can be any JSON serializable type - it is sort of up to workflow module to process it - so maybe Any or maybe start with bool
and create a comment somewhere that it will need to be unioned with other types if we add more workflow module types. I'm not sure if conditionals use this or not - probably worth looking into but maybe the typing alone would tell us.
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.
Will do.
It is a pain to review indeed! (and thanks!) I intentionally reviewed these model edits multiple times. I didn't run a script, but I can do that; it won't be a full model comparison (I tried doing that when moving to declarative - it's next to impossible to cover all model details), but I can compare field types and nullability - that's what's most relevant here. I'll do that before merging, to be on the safe side. |
I've compared the model definitions on dev and this branch programmatically, comparing column name, type and nullability. There is no difference. from galaxy.model import mapping
for t in mapping.metadata.tables.values():
for c in t.columns:
print(f"{c.name} {c.type} {c.nullable}")
# run the above on both branches, then diff the output. |
Builds on #17897
To do:
_serialize
method to theWorkflowInvocationMessage
class definition (ref) UPADATE: type-ignore for now.Misc. post-SA20 model edits and bug fixes.
Remove pre-SA20 code (
autocommit
arg in session,future
arg in session and engine)A note on nullability in the database schema versus optionality in the python app:
The nullability of the field in the database schema is derived from the type hint. So:
foo: Mapped[int] = mapped_column()
will addNOT NULL
to the table field definition, whereasfoo: Optional[Mapped[int]] = mapped_column()
will not. Furthermore, thenullable
argument tomapped_column()
takes precedence over this derivation. Thus, it is possible to have a mapped attribute that can containNone
values, but will require a value when saved to the database, and vice versa. Here's an example (comments indicate nullability in the db definition):In SQLAlchemy 1.4:
In SQLAlchemy 2.0:
https://docs.sqlalchemy.org/en/20/orm/declarative_tables.html#mapped-column-derives-the-datatype-and-nullability-from-the-mapped-annotation
How to test the changes?
(Select all options that apply)
License