-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98f2673
commit 7a342d3
Showing
4 changed files
with
192 additions
and
2 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
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
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
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,188 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"##############################################################################\n", | ||
"#The app works around 4 major steps\n", | ||
"# (1) Configure the user input\n", | ||
"# (2) Confirm the user input + submit the job\n", | ||
"# (3) Monitor the process during the run\n", | ||
"# (4) Display the final results\n", | ||
"#\n", | ||
"#These steps are linked via the following \n", | ||
"# (1) --> (2): user_inputs, a dictionary of all the user inputs\n", | ||
"# (1) --> (2): mpuc3_code, a code for marketplace usercase 3\n", | ||
"# (2) --> (3): process, the process (MPusercase3 CalcJob) submitted to AiiDA \n", | ||
"# (3) --> (4): output, the ArrayData output from the CalcJob\n", | ||
"#\n", | ||
"#This is an early prototype that is 'stapled' from the pizza example in aiidalab_widgets_base\n", | ||
"#as well as QE example from aiidalab_qe\n", | ||
"#\n", | ||
"#Specific notes/issues on the steps:\n", | ||
"# Step 1:\n", | ||
"# * Perhaps there should be a step 0 that allows the user to choose a model,\n", | ||
"# then the widget can be dynamically updated\n", | ||
"# * The code setup is rather ugly, and creating a custom code crashes\n", | ||
"# * The user should be alerted that if they try to hit submit without \n", | ||
"# choosing a code, that they need to choose a code first\n", | ||
"# Step 2:\n", | ||
"# Step 3:\n", | ||
"# * This is taken almost directly from QE, and is the part I understand the least\n", | ||
"# * Clicking on most outputs causes a crash\n", | ||
"# *** I can't seem to set the 'output' propery correctly\n", | ||
"# Step 4:\n", | ||
"# *** Because I can't set the output property in step3 correctly, this step displays nothing\n", | ||
"# * The current display is very ugly and taken directly from Step2, and probably be changed to\n", | ||
"# something nicer\n", | ||
"##############################################################################" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import logging\n", | ||
"\n", | ||
"from uc3.logger import OutputWidgetHandler\n", | ||
"\n", | ||
"logger = logging.getLogger(\"aiidalab_mp_uc3\")\n", | ||
"handler = OutputWidgetHandler()\n", | ||
"handler.setFormatter(logging.Formatter('%(asctime)s - [%(levelname)s] %(message)s'))\n", | ||
"logger.addHandler(handler)\n", | ||
"logger.setLevel(logging.INFO)\n", | ||
"\n", | ||
"# Remove/Add comment of the next line to show/hide logs.\n", | ||
"# handler.show_logs()\n", | ||
"\n", | ||
"handler.clear_logs()\n", | ||
"logger.info('Starting program')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "9f587b5d4ea34a4aad4deba0102f0c2d", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"ename": "NameError", | ||
"evalue": "name 'DisplayAp2FinalOutput' is not defined", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", | ||
"\u001b[0;32m/tmp/ipykernel_26756/2862219995.py\u001b[0m in \u001b[0;36m<cell line: 33>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 31\u001b[0m \u001b[0mconfirm_userinput_step\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mConfirmUserInputStep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mauto_advance\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 32\u001b[0m \u001b[0mmonitorprocess_step\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mMonitorProcessStep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mauto_advance\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 33\u001b[0;31m \u001b[0mdisplayfinaloutput_step\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mDisplayAp2FinalOutput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mauto_advance\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# DisplayFinalOutput(auto_advance=False)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 34\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 35\u001b[0m ipw.dlink(\n", | ||
"\u001b[0;31mNameError\u001b[0m: name 'DisplayAp2FinalOutput' is not defined" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import ipywidgets as ipw\n", | ||
"\n", | ||
"from aiidalab_widgets_base import WizardAppWidget\n", | ||
"\n", | ||
"from uc3.steps import (\n", | ||
" ComputerCodeSetupStep,\n", | ||
" ConfigureUserInputStep,\n", | ||
" ConfirmUserInputStep,\n", | ||
" MonitorProcessStep,\n", | ||
" DisplayAp2FinalOutput,\n", | ||
")\n", | ||
"\n", | ||
"computer_code_setup_step = ComputerCodeSetupStep(auto_advance=True)\n", | ||
"configure_userinput_step = ConfigureUserInputStep(auto_advance=True, description_label_default=[ \n", | ||
" ['gfr', 'gfr', 0],\n", | ||
" ['ch4mf', 'ch4mf', 0],\n", | ||
" ['h2omf', 'h2omf', 0],\n", | ||
" ['surfa', 'surfa', 0],\n", | ||
" ['amf', 'amf', 0],\n", | ||
" ['macropor', 'macropor', 0],\n", | ||
" ['macrotor', 'macrotor', 0],\n", | ||
" ['k1', 'k1', 0],\n", | ||
" ['ea1', 'ea1', 0],\n", | ||
" ['k2', 'k2', 0],\n", | ||
" ['ea2', 'ea2', 0],\n", | ||
" ['koeq', 'koeq', 0],\n", | ||
" ['dhh20', 'dhh20', 0]\n", | ||
"])\n", | ||
"\n", | ||
"\n", | ||
"confirm_userinput_step = ConfirmUserInputStep(auto_advance=True)\n", | ||
"monitorprocess_step = MonitorProcessStep(auto_advance=True)\n", | ||
"displayfinaloutput_step = DisplayAp2FinalOutput(auto_advance=False) # DisplayFinalOutput(auto_advance=False)\n", | ||
"\n", | ||
"ipw.dlink(\n", | ||
" (configure_userinput_step, \"user_inputs\"),\n", | ||
" (confirm_userinput_step, \"user_inputs\"),\n", | ||
")\n", | ||
"ipw.dlink(\n", | ||
" (computer_code_setup_step, \"mpuc3_code\"),\n", | ||
" (confirm_userinput_step, \"mpuc3_code\"),\n", | ||
")\n", | ||
"ipw.dlink(\n", | ||
" (confirm_userinput_step, \"process\"),\n", | ||
" (monitorprocess_step, \"process\"),\n", | ||
" transform=lambda x: x.uuid if x is not None else None\n", | ||
")\n", | ||
"ipw.dlink(\n", | ||
" (monitorprocess_step, \"output\"),\n", | ||
" (displayfinaloutput_step, \"output\"),\n", | ||
")\n", | ||
"\n", | ||
"# Setup the app by adding the various steps in order.\n", | ||
"WizardAppWidget(\n", | ||
" steps=[\n", | ||
" (\"Setup Computer & Code\", computer_code_setup_step),\n", | ||
" (\"Configure User Input\", configure_userinput_step),\n", | ||
" (\"Confirm User Input\", confirm_userinput_step),\n", | ||
" (\"Monitor Process\", monitorprocess_step),\n", | ||
" (\"Display Results\", displayfinaloutput_step),\n", | ||
" ]\n", | ||
")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"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" | ||
}, | ||
"vscode": { | ||
"interpreter": { | ||
"hash": "d4d1e4263499bec80672ea0156c357c1ee493ec2b1c70f0acce89fc37c4a6abe" | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |