-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Centralized notebook for managing AiiDA codes (#188)
This PR introduces an external notebook to manage AiiDA codes.
- Loading branch information
1 parent
b9ad441
commit 7b626ab
Showing
2 changed files
with
451 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from aiida import load_profile\n", | ||
"\n", | ||
"load_profile();" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "html" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"%%html\n", | ||
"\n", | ||
"<style>\n", | ||
" .output_subarea {\n", | ||
" max-width: none !important;\n", | ||
" }\n", | ||
" .header-tr {\n", | ||
" column-gap: 5px;\n", | ||
" }\n", | ||
" .th {\n", | ||
" padding: 2px 5px;\n", | ||
" font-weight: bold;\n", | ||
" color: #fff;\n", | ||
" text-align: center;\n", | ||
" background-color: #000;\n", | ||
" }\n", | ||
" .tr:hover {\n", | ||
" background-color: #f5f5f5;\n", | ||
" }\n", | ||
" hr {\n", | ||
" border-top: 1px solid #d3d3d3;\n", | ||
" }\n", | ||
"</style>\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# AiiDAlab code setup\n", | ||
"\n", | ||
"This page provides an interface for creating and managing AiiDA codes on local or remote machines.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"<hr>\n", | ||
"\n", | ||
"## Create new code\n", | ||
"\n", | ||
"To create a new AiiDA code for use in a calculation, follow these steps:\n", | ||
"\n", | ||
"#### Quick setup (using [AiiDA resource registry](https://github.com/aiidateam/aiida-resource-registry) recipes)\n", | ||
"\n", | ||
"1. Select the domain of your remote machine\n", | ||
"2. Select the computer recipe\n", | ||
"3. Select the code recipe\n", | ||
"4. Complete the remaining fields (these depend on the combination selected in steps 1-3)\n", | ||
"5. Click **Quick setup**\n", | ||
"\n", | ||
"#### Manual setup (create new resources from scratch)\n", | ||
"\n", | ||
"1. Tick the checkbox above the **Quick setup** button\n", | ||
"2. Follow along with the provided instructions\n", | ||
"\n", | ||
"Newly created codes will be available in the **Available codes** section, as well as in code selectors provided in various apps.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import ipywidgets as ipw\n", | ||
"from aiidalab_widgets_base.computational_resources import ResourceSetupBaseWidget\n", | ||
"from aiidalab_widgets_base.utils import StatusHTML\n", | ||
"\n", | ||
"setup_message = StatusHTML(clear_after=15)\n", | ||
"\n", | ||
"widget = ResourceSetupBaseWidget()\n", | ||
"ipw.dlink(\n", | ||
" (widget, \"message\"),\n", | ||
" (setup_message, \"message\"),\n", | ||
")\n", | ||
"\n", | ||
"ipw.VBox(\n", | ||
" children=[\n", | ||
" widget,\n", | ||
" setup_message,\n", | ||
" ]\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"<hr>\n", | ||
"\n", | ||
"## Available codes\n", | ||
"\n", | ||
"Below are the available codes in the AiiDA database. Use the controls to filter the list by label, executable path, and visibility. You can mark individual codes as _hidden_ to exclude them from code selectors used in apps (note that some apps may enforce the inclusion of hidden codes). Click **Unhide all** to include all codes. If codes are deleted from the database, click **Refresh codes** to reflect the change in the list.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from home.code_setup import create_paginated_table, fetch_code_data\n", | ||
"\n", | ||
"output = ipw.Output()\n", | ||
"\n", | ||
"\n", | ||
"def render():\n", | ||
" data = fetch_code_data()\n", | ||
" paginated_table = create_paginated_table(data)\n", | ||
" output.clear_output()\n", | ||
" with output:\n", | ||
" display(paginated_table)\n", | ||
"\n", | ||
"\n", | ||
"refresh_button = ipw.Button(\n", | ||
" description=\"Refresh codes\",\n", | ||
" button_style=\"primary\",\n", | ||
" icon=\"refresh\",\n", | ||
" tooltip=\"Refresh the list of codes\",\n", | ||
" layout=ipw.Layout(width=\"fit-content\"),\n", | ||
")\n", | ||
"refresh_button.on_click(lambda _: render())\n", | ||
"\n", | ||
"display(\n", | ||
" ipw.VBox(\n", | ||
" children=[\n", | ||
" refresh_button,\n", | ||
" output,\n", | ||
" ]\n", | ||
" )\n", | ||
")\n", | ||
"\n", | ||
"render()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def on_code_setup_message_change(change):\n", | ||
" if \"created\" in change[\"new\"]:\n", | ||
" render()\n", | ||
"\n", | ||
"\n", | ||
"widget.aiida_code_setup.observe(\n", | ||
" on_code_setup_message_change,\n", | ||
" \"message\",\n", | ||
")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "base", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.