Setting up a code in AiiDAΒΆ

from traitlets import dlink
import ipywidgets as ipw
import urllib.parse as urlparse
from aiidalab_widgets_base import AiiDACodeSetup, CodeDatabaseWidget
parsed_url = urlparse.parse_qs(urlparse.urlsplit(jupyter_notebook_url).query)
args = {}
for key, value in parsed_url.items():
    args[key] = '\n'.join(value) if isinstance(value,(tuple,list)) else value
aiidacode = AiiDACodeSetup(path_to_root="../../", **args)
database_connected = False
def connect_database(_=None):
    global database_connected
    if database_connected:
        return
    dlink((database, 'label'), (aiidacode, 'label'))
    dlink((database, 'description'), (aiidacode, 'description'))
    dlink((database, 'input_plugin'), (aiidacode, 'input_plugin'))
    dlink((database, 'remote_abs_path'), (aiidacode, 'remote_abs_path'))
    dlink((database, 'computer'), (aiidacode, 'computer'))
    dlink((database, 'prepend_text'), (aiidacode, 'prepend_text'))
    dlink((database, 'append_text'), (aiidacode, 'append_text'))

    database_connected = True

database = CodeDatabaseWidget()
database.update_btn.on_click(connect_database)
database_accordion = ipw.Accordion(children=[database], selected_index=None)
database_accordion.set_title(0, 'Code database')
display(database_accordion)
display(aiidacode)