-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Delay ConnectionModelView init until it's accessed #29946
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
Delay ConnectionModelView init until it's accessed #29946
Conversation
|
|
fc383a1 to
8cb998b
Compare
This removed the "lazy" initialization of ConnectionModelView (and ConnectionForm used by it) that happens when the webserver first launches, and moves the corresponding logic to until the view is actually being accessed. This further delays the provider manager from loading connection form widgets until the last possible moment and speeds up the webserver's startup sequence. While this does make the connection form view a bit slower (only the first time since the result is cached), the slowdown should not be as noticeable since the provider manager should generally be partially loaded into memory at that point.
8cb998b to
ffb55cd
Compare
This makes sure we only init when the view is accessed (instead of on startup) without relying on Flask-Appbuilder internals.
| if self._edit_columns is type(self)._edit_columns and has_request_context(): | ||
| self._edit_columns = [*self._edit_columns, *(k for k, _ in self._iter_extra_field_names())] | ||
| return self._edit_columns |
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.
Do add and edit columns differ? Could this be simply be return self.add_columns?
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 can, I’m mostly just not sure whether we’d want them to be different at some point, and separating the two doesn’t feel wrong (since they are logically different).
ashb
left a comment
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.
So long as we have sufficient tests to ensure that the form still continues to work 👍 (I don't know if we do or don't.)
|
The form class works (those tests I changed cover it); whether the UI continues to work is more suspective. I did test it by hand but it’s difficult to automate. |
|
I also tested it manually and it seems to work fine. |
|
Nice one BTW. |
This removed the "lazy" initialization of ConnectionModelView (and ConnectionForm used by it) that happens when the webserver first launches, and moves the corresponding logic to until the view is actually being accessed.
This further delays the provider manager from loading connection form widgets until the last possible moment and speeds up the webserver's startup sequence.
While this does make the connection form view a bit slower (only the first time since the result is cached), the slowdown should not be as noticeable since the provider manager should generally be partially loaded into memory at that point.