-
Notifications
You must be signed in to change notification settings - Fork 61
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
Prevent clashing MPComponent IDs #332
Conversation
by appending counter to every duplicate ID and incrementing until unique
@yang-ruoxi Do you have another example where we could test this fix? |
thanks @janosh ! You can try running |
Thanks also @janosh. The underlying issue with the counter, I think, was that a solution that might work in a single-threaded demo context might not working when deploying with gunicorn (if I remember correctly, it was some time ago). I refer to the catch-all issue #265, but a design improvement would be to try to avoid these |
Thanks for the update. All these caveats in different design decisions are really good to know!
Could you push that to a branch? Maybe we can pick this up. |
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 this is good to merge (without the print
statement), as an interim fix.
Yes, I'd be happy to; I'd also like to get the TaskDocument component merged (I'm not sure if this has drifted away from the MP implementation, but would be good to use it on the task detail pages), and I also have a branch which updates the example apps with |
Oki, merging now.
Not much if at all I think but @yang-ruoxi would know. |
following merge of materialsproject/crystaltoolkit#332
* mv examples/{CHGNet_examples,basics}.ipynb * clean up crystaltoolkit_relax_viewer.ipynb following merge of materialsproject/crystaltoolkit#332 * bump ruff
This PR fixes the error
by appending a counter to every duplicate ID and incrementing it until the ID is unique. Not sure if this is an elegant solution. The current code explicit warns against this:
crystaltoolkit/crystal_toolkit/core/mpcomponent.py
Lines 194 to 203 in a291123
But based on the frequency with which I encounter this error in my personal use (and apparently even MP production), maybe worth a try? Perhaps @mkhorton who wrote that comment 2 years ago remembers what other unexpected behavior changing the IDs might have?
Minimal code to trigger the error
The double call to
StructureMoleculeComponent
with identicalid
seems contrived/non-sensical but is what happens naturally in contexts like a dev server where code changes trigger a hot-reload.