<jupyter_start><jupyter_text>Setting up a code in AiiDA<jupyter_code>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)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13226744186046513, 'fraction_numerical': 0.0007267441860465116, 'mean_word_length': 7.14792899408284, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '159414', 'license': 'MIT', 'n_tokens_mistral': 461, 'n_tokens_neox': 451, 'n_words': 89, 'path': 'notebooks/setup_code.ipynb', 'repo_name': 'danielhollas/aiidalab-widgets-base', 'size': '1376'}