-
Notifications
You must be signed in to change notification settings - Fork 982
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
Use DeclarativeBase as base class for SA models #17897
Conversation
mypy bug workaround no longer needed as we are no longer specifying a metaclass
c63f037
to
d46eb8d
Compare
Test failure unrelated. |
lib/galaxy/managers/base.py
Outdated
@@ -999,7 +999,7 @@ class ModelFilterParser(HasAModelManager): | |||
# (as the model informs how the filter params are parsed) | |||
# I have no great idea where this 'belongs', so it's here for now | |||
|
|||
model_class: Type[model._HasTable] | |||
model_class: Type[Union[model.Base, model.DatasetInstance]] |
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.
DatasetInstance
doesn't look right here. If you do need to be more precise consider parameterizing this with a generic ?
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 need a union here only because hda and ldda are not mapped declaratively. model_class
is the type for all SA models. All models but these two are mapped declaratively, which gives them a metadata
instance variable. The hda and ldda models also have a metadata
variable, which is why they can't be mapped declaratively (they will be eventually). Now, all declaratively mapped models inherit from DeclarativeBase
. So the closest way to describe the type of all our models is the union of DeclarativeBase
and the 2 non-declaratively mapped models - which both subclass DatasetInstance
. This is tighter than the previous implementation (_HasTable
, before that _BaseModel
) which relied on the parent having a table
variable.
d46eb8d
to
eea15e5
Compare
eea15e5
to
652d36f
Compare
Already merged as part of #17662 |
Post-SA2.0 model fixes (cherry-picked from #17662):
Use proper DeclarativeBase as base class, as per sqlalchemy documentation.
mypy bug workaround no longer needed as we are no longer specifying a metaclass.
Use FromClause as the correct type instead of Table
Fix
table/__table__/HasTable
for models. HasTable was a hack to accommodate declarative mapping without changing thousands of lines that referred to thetable
attribute of model instances.The one
type:ignore
added to managers.datasets can be removed after we map DatasetInstance models declaratively.How to test the changes?
(Select all options that apply)
License