-
Notifications
You must be signed in to change notification settings - Fork 18
UUID as traitlets for threading related widgets #375
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
Conversation
@unkcpz sorry for a delay on this. I'll try to take a closer look and test this next week. Thanks! |
Thanks! Since this PR is separated from the migration to 2.x and it is not manifest the thread issue in 1.6.x, I think you can have a test to make sure everything is working with the new changes in this PR. |
I made some progress today, was able to convert my app to support this branch and did some basic testing. Will try to do more testing tomorrow. |
Hi @danielhollas, do you have any update on using and testing this? I want to try to finalize this and hopefully have QeApp support AiiDA 2.x supported by next week. |
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.
@unkcpz here's my initial review. I agree with the target of merging this next week.
I did some testing within my own application, but need to do a bit more and want to test individual widgets as well.
I have also ran into an interesting edge case that possibly not covered here. I had a widget that passed an AiiDA node to another widget based on the UI interaction (e.g. user clicks a button and AiiDA node is passed to a widget). Presumably because the UI interaction was handled by a different thread than the thread that originally passed the Node, it ran into the same issue as we're solving here, even though the widget itself did not explicitly use threading. So something to be mindful of.
aiidalab_widgets_base/process.py
Outdated
@@ -545,10 +542,10 @@ class ProcessListWidget(ipw.VBox): | |||
|
|||
past_days (int): Sumulations that were submitted in the last `past_days`. | |||
|
|||
incoming_node (int, str, Node): Trait that takes node id or uuid and returns the node that must | |||
incoming_node (tr): Trait that takes node uuid that must |
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.
Any reason why not keep support of passing id
instead of uuid
?
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.
You mean pk
? Do you have any use case for where you what to use primary key, since I think you can use UUID to include all the cases for pk
?
aiidalab_widgets_base/process.py
Outdated
process = change["new"] | ||
if process is None or process.id != getattr(change["old"], "id", None): | ||
process_uuid = change["new"] | ||
if process_uuid is None or process_uuid != change["old"]: |
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.
Can we clean this up a bit to reduce the indentation levels? The first if statement is super confusing to me.
If I understood the logic correctly, this should work?
if process_uuid is None or process_uuid != change["old"]: | |
if process_uuid == change["old"]: | |
return | |
# stop thread (if running) | |
if self._monitor_thread is not None: | |
with self._monitor_thread_lock: | |
self._monitor_thread_stop.set() | |
self._monitor_thread.join() | |
if process_uuid is None: | |
return | |
with self.hold_trait_notifications(): | |
with self._monitor_thread_lock: | |
self._monitor_thread_stop.clear() | |
self._monitor_thread = Thread( | |
target=self._monitor_process, args=(process_uuid,) | |
) | |
self._monitor_thread.start() | |
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.
Yes, fully agree. I try to simplify it more. Please have a test of it. I'll do the test further more on qeApp.
for more information, see https://pre-commit.ci
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.
@danielhollas thanks a lot for the test. I think the main open issue is whether we need to using only the UUID or also support the other entities (label/pk etc.) as the value of those widgets.
I update the ProcessMornitor to try to make it more clear.
aiidalab_widgets_base/process.py
Outdated
@@ -545,10 +542,10 @@ class ProcessListWidget(ipw.VBox): | |||
|
|||
past_days (int): Sumulations that were submitted in the last `past_days`. | |||
|
|||
incoming_node (int, str, Node): Trait that takes node id or uuid and returns the node that must | |||
incoming_node (tr): Trait that takes node uuid that must |
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.
You mean pk
? Do you have any use case for where you what to use primary key, since I think you can use UUID to include all the cases for pk
?
aiidalab_widgets_base/process.py
Outdated
process = change["new"] | ||
if process is None or process.id != getattr(change["old"], "id", None): | ||
process_uuid = change["new"] | ||
if process_uuid is None or process_uuid != change["old"]: |
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.
Yes, fully agree. I try to simplify it more. Please have a test of it. I'll do the test further more on qeApp.
I got this PR tested on QeApp and no issue was found. |
@unkcpz great that you tested it. I didn't get to it this week due to other things. I'll get back to it on Monday, but if you need to merge before than feel free. Next week I will for sure need to do some production calculations so will test this more, perhaps this can be merged but still not released as a full 2.0 version before more testing is done? |
Yes, I think we can set some milestones in the next meeting for |
Hi @yakutovicha, are you reviewing this? I think we can have another alpha release with this merged. Then I can keep on working on QeApp. |
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.
Overall looks good to me.
Looking at the discussion, I see one unclear point, whether to allow to use of node labels together with UUIDs. IMO, it would be ok to keep UUIDs only, as I wrote in the review comments.
@danielhollas please let me know if you agree with that.
aiidalab_widgets_base/process.py
Outdated
@@ -688,7 +695,7 @@ def start_autoupdate(self, update_interval=10): | |||
class ProcessMonitor(traitlets.HasTraits): | |||
"""Monitor a process and execute callback functions at specified intervals.""" | |||
|
|||
process = traitlets.Instance(ProcessNode, allow_none=True) | |||
process_uuid = Unicode(allow_none=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.
What about naming it value
?
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.
Changed. Also test the new API in QE app.
Thanks @unkcpz. I was testing it today / yesterday in my app and did not find any issues, but was not testing all the functionality here. Unfortunately, I had some other urgent stuff to do for tomorrow's meeting. I'll try to do one more round of testing today late evening if I get to it. Otherwise, this is good to merge from my side and release a new alpha version. @yakutovicha I think you're right about the UUID value, I am find with only supporting UUID. One question, how does the Code selection UI looks if there are two computers with the same label? e.g. if one imports nodes from another DB? Perhaps we should display PKs in the Dropdown in such cases, since otherwise the user will only see two identical labels? |
I think they are indistinguishable from the current UI. I agree with you that adding a PK number alongside with the code label would be a good option 👍 |
) - `aiida-core~=2.2` to align with aiida-core version in new docker stack - `aiidalab-widget-base==2.0.0b5` for pinning the widgetnbextension version aiidalab#467 - `widget-bandsplot~=0.5.1` for fixing TDOS background filling issue.
The widget changed are:
ComputationalResourcesWidget
because of QeApp code setup triggerrefresh
it in thread.ComputerDropdownWidget
ProcessListWidget
because thread call in update function for process.ProcessMonitor
thread call injoin
ProcessNodesTreeWidget