Setting up a computer in AiiDA

import urllib.parse as urlparse
import ipywidgets as ipw
from traitlets import dlink
from aiidalab_widgets_base import SshComputerSetup
from aiidalab_widgets_base import AiidaComputerSetup
from aiidalab_widgets_base import ComputerDatabaseWidget
# Create dictionary that contains URL arguments.
parsed_url = urlparse.parse_qs(urlparse.urlsplit(jupyter_notebook_url).query)
url_args = {}
for key, value in parsed_url.items():
    url_args[key] = '\n'.join(value) if isinstance(value, (tuple, list)) else value

Step 1: Setup ssh

Note: The password is used only to set up the ssh connection and is never stored.

database_connected = False
def connect_database(_=None):
    global database_connected
    if database_connected:
        return
    # SSH computer setup.
    dlink((database, 'hostname'), (sshcomputer, 'hostname'))
    dlink((database, 'proxy_hostname'), (sshcomputer, 'proxy_hostname'))

    # AiiDA computer setup.
    dlink((database, 'label'), (aiidacomputer, 'label'))
    dlink((database, 'hostname'), (aiidacomputer, 'hostname'))
    dlink((database, 'description'), (aiidacomputer, 'description'))
    dlink((database, 'work_dir'), (aiidacomputer, 'work_dir'))
    dlink((database, 'mpirun_command'), (aiidacomputer, 'mpirun_command'))
    dlink((database, 'mpiprocs_per_machine'), (aiidacomputer, 'mpiprocs_per_machine'))
    dlink((database, 'prepend_text'), (aiidacomputer, 'prepend_text'))
    dlink((database, 'append_text'), (aiidacomputer, 'append_text'))
    dlink((database, 'transport'), (aiidacomputer, 'transport'))
    dlink((database, 'scheduler'), (aiidacomputer, 'scheduler'))
    dlink((database, 'safe_interval'), (aiidacomputer, 'safe_interval'))

    database_connected = True

database = ComputerDatabaseWidget()
database.update_btn.on_click(connect_database)
database_accordion = ipw.Accordion(children=[database], selected_index=None)
database_accordion.set_title(0, 'Computer database')
display(database_accordion)
sshcomputer = SshComputerSetup(**url_args)
display(sshcomputer)

Step 2: Setup & Test AiiDA Computer

aiidacomputer = AiidaComputerSetup(**url_args)
display(aiidacomputer)