Skip to content

Commit

Permalink
fix the computer_setup update with dict copy
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed May 19, 2023
1 parent d4de7ce commit e399897
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions aiidalab_widgets_base/computational_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class QuickSetupWidget(ipw.VBox):

default_calc_job_plugin = traitlets.Unicode(allow_none=True)

computer_setup = traitlets.Dict()
computer_setup = traitlets.Dict().tag(sync=True)
code_setup = traitlets.Dict()

def __init__(self, **kwargs):
Expand Down Expand Up @@ -114,9 +114,10 @@ def quick_setup(self, _=None):
The actual setup will be triggered from DetailedSetupWidget from ComputationalResourcesWidget.
"""
from jinja2 import ChainableUndefined, Environment, meta
import copy

# From the remote original setup, fill the template
computer_setup = self.computer_setup
computer_setup = copy.deepcopy(self.computer_setup) # The dict is nested, so we need deepcopy

for key, value in computer_setup.get("setup", {}).items():
env = Environment(undefined=ChainableUndefined)
Expand All @@ -134,12 +135,12 @@ def quick_setup(self, _=None):
else:
computer_setup["setup"][key] = value

self.computer_setup = {**self.computer_setup}
self.computer_setup = computer_setup
print(self.computer_setup)


class DetailedSetupWidget(ipw.VBox):
computer_setup = traitlets.Dict()
computer_setup = traitlets.Dict().tag(sync=True)
code_setup = traitlets.Dict()

def __init__(self, **kargs):
Expand Down Expand Up @@ -318,7 +319,9 @@ def __init__(self, description="Select code:", path_to_root="../", **kwargs):

def _quick_setup(self, change):
if change["new"] is not None:
print("HETNNNNN")
self.detailed_setup.aiida_computer_setup.computer_setup = change["new"]
self.detailed_setup.aiida_computer_setup._observe_computer_setup()
# self.detailed_setup.code_setup = self.comp_resources_database.code_setup

def quick_setup(self, _=None):
Expand Down Expand Up @@ -814,7 +817,7 @@ def _observe_ssh_config(self, _=None):
class AiidaComputerSetup(ipw.VBox):
"""Inform AiiDA about a computer."""

computer_setup = traitlets.Dict(allow_none=True)
computer_setup = traitlets.Dict(allow_none=True).tag(sync=True)
message = traitlets.Unicode()

def __init__(self, **kwargs):
Expand Down

0 comments on commit e399897

Please sign in to comment.