-
Notifications
You must be signed in to change notification settings - Fork 14
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
Bump traitlets for better performance #401
Conversation
Here's the relevant cProfile output when initializing my app with traitlets 5.4
Notice the huge number of calls to certiain Here's output with 5.9
|
Thanks @danielhollas, fantastic enhancement! How do you get this cProfile? Do I need to put some code in the notebook? I am looking forward to giving this a try on QE app. |
I've essentially just copy pasted the code from the notebook to a python script and ran it through |
Thanks a lot, @danielhollas! It's a great improvement. The only suggestion I have is to add it to the AWB instead. Traits are more of app dependencies rather than a core requirement. It is already a dependency of the home app. I see no problem in adding |
I'd prefer to add to both places. Adding it to AWB means the dependencies of the app need to be bumped to use the new traitlets, bumping it here will make it available even for the old version apps. |
The more I think about this change, the more I am getting convinced that the change should be done in the app(s), not here. People will get a notification that AWB has a newer version, and they can update it as soon as the app is released. This also gives a sense of improvement. |
@yakutovicha well, I've given it a lot of thought as well but arrived at the opposite conclusion. 😄 I am happy to declare a minimum dependency on
Traits are in fact very much a core dependency of the Jupyter ecosystem, as can be seen by looking at which packages depend on it.
Bumping Moreover, since AWB is a core dependency of most AiiDAlab apps, we should be rather conservative with dependency constraints, otherwise we will always run into incompatibility issues (as we often already do). There is an interesting blog post about managing version dependencies in libraries (as opposed to applications). https://hynek.me/articles/semver-will-not-save-you/
Not that I think it is a very good argument, but note that the speedup here will not be that noticeable until the However, I take your point about users getting notified about updates. Previously in |
I've opened an issue for this aiidalab/aiidalab-launch#188 Note that updating |
Let me try to motivate why we shouldn't change the Docker container. We build the Docker container to provide a minimal working environment. We try to minimize the image settings as much as possible, allowing the apps to install almost any dependencies they want. Installing a specific version of
I'm afraid I have to disagree with that statement. We had a broad discussion on what we mean by core dependencies and we devised special procedures for handling them. Our dependency machinery won't attempt to update the core dependency. It will only allow apps to be installed if they can work with the given versions of core dependencies. Traitles can be overridden and are not protected, so they do not fall into this category.
Yes, by design, AiiDAlab relies on pip when installing dependencies. Is it 100% safe? - No, and you've mentioned the reasons. But this is the compromise we came up with so far. If there are better alternatives - let's consider them.
We worked hard to make it a non-core dependency. And, again, core dependencies have a specific meaning and are listed here.
It is a thoughts provoking post, indeed. But it is unclear how it supports the need for current PR's change. However, it speaks volumes about how hard it is to keep a working system. The author proposes to use a specific version of dependencies and bump them/test them often. This can be achieved if communicating with AiiDA through REST API and keeping apps in separate environments. That is what we are eventually aiming for, but that requires a substantial amount of work and redesign. Conclusion Provided the circumstances we are currently in (pip-managed installation, multiple apps, conda environments), I find the change in the current PR is unnecessary. This won't be quick, this might not change the version of traitlets in some cases, and this is not where apps' dependencies are meant to be. |
Hi @danielhollas, we had a short discussion on this in the last aiidalab meeting. I agree with @yakutovicha that this better goes to |
Fair enough, although this was never meant to be a permanent solution, just a temporary quick win. 🤷
This is fine, as long as AWB is published and installed via conda.
I would like to flip this argument though. I think when we added the core dependencies, we were meant to come back to them and decide if we need to specify more of them as core. We definitely did not have a very robust discussion around what should be in the core, at least I don't remember. I would argue that |
I am re-opening this PR as a response to #494 where we found out that the current docker stack is incompatible with traitlets>=5.10, and the container fails to start. I am reiterating my belief that we should try as hard as possible to prevent apps from breaking the container. I will open a new issue with a proposed strategy about how to define and enforce core dependencies. In the interim we reverted AWB dependency back to This PR is just a stopgap solution that upgrades to a known good version of traitlets==5.9, which we upgrade here for performance reasons, as described at the top. This change will be soon reverted as part of an upgrade to Python 3.11 image in #455 which ships with traitlets 5.9 already. |
@yakutovicha @unkcpz could you please give this your blessing (or otherwise), based on discussion in our last meeting? This is currently a blocker for releasing a new image with AiiDA 2.6. Thanks! |
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.
Go ahead @danielhollas!
traitlets>=5.7.0
offer a huge performance improvements when constructing the widgets, and thus significantly improve the initial page load of the app. See ipython/traitlets#777 and https://github.com/ipython/traitlets/blob/main/CHANGELOG.md#570In my brief testing of importing and initializing my app, this update saves around 600ms.
@unkcpz @yakutovicha would you mind giving this a test for QeApp and / or EMPA apps to verify that things still work?
I went through the changelog between our current version (5.4) and new 5.9 and there doesn't appear to be any breaking changes so we should be good.
Note that when we bump Python version in the docker image in #337, the new traitlets version is already there. But I want to do a little more testing there, so this PR is a hotfix in the meantime which will let us test this out independently.