-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Centralized notebook for managing AiiDA codes #188
Merged
edan-bainglass
merged 14 commits into
aiidalab:main
from
edan-bainglass:code-setup-notebook
Jan 10, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e1b4e39
Add external notebook for managing codes
edan-bainglass 78ddccd
Refresh available codes on code creation
edan-bainglass 102043c
Improve pagination
edan-bainglass 008a11f
Remove pandas dependency
edan-bainglass b6e4c5c
Fix table reset from null-result searches
edan-bainglass 8fd2256
Simplify new code setup observation
edan-bainglass 3ff3c40
Change only active filter to only hidden
edan-bainglass a37c265
Fix filter overriding
edan-bainglass 168da67
Add tooltip to show all codes button
edan-bainglass 21843ac
Improve control layout
edan-bainglass 8fb61a3
Adjust capitalization
edan-bainglass d277602
Update use of AWB class w.r.t changes in AWB
edan-bainglass c892ea2
Add refresh button
edan-bainglass 67d18dc
Add in-notebook instructions
edan-bainglass File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why observe the
message
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a code was created ("created" in
message
), I rerender the table to refresh and pick up the new code. If none create, no need to refresh.