Skip to content

Commit

Permalink
final adjustments before production-ready
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sintef committed Jun 9, 2023
1 parent a62a17a commit 60ea6e1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 183 deletions.
6 changes: 3 additions & 3 deletions openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ info:
- email
- openid
- profile
callback: https://materials-marketplace.aiidalab.net/hub/oauth_callback
x-external-hostname: https://materials-marketplace.aiidalab.net
callback: https://aiidalab.materials-marketplace.eu/hub/oauth_callback
x-external-hostname: https://aiidalab.materials-marketplace.eu
# x-image: https://raw.githubusercontent.com/aiidalab/aiidalab-qe/v20.12.0/miscellaneous/logos/QE.jpg
x-contacts:
- [email protected]
x-products:
- name: AiiDAlab UC3 App
productId: 55305f0c-f1a1-4ee3-8c31-a31c45b61af3
servers:
- url: https://materials-marketplace.aiidalab.net
- url: https://aiidalab.materials-marketplace.eu

paths:
/hub/user-redirect/apps/apps/aiidalab-mp-uc3/uc3.ipynb:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ python_requires = >=3.7
install_requires =
aiida-core~=2.1,<3
aiidalab>=21.09.0
aiidalab-widgets-base==2.0.0b1
aiidalab-widgets-base==2.0.0

[flake8]
ignore =
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def gitlab_token(source: "Optional[Union[Path, str]]" = None) -> str:
f"aiida-marketusercase3 @ git+https://github.com/daniel-sintef/aiida-marketusercase3.git@master",
"aiida-core~=2.1,<3",
"aiidalab>=21.09.0",
"aiidalab-widgets-base==2.0.0b1",
"aiidalab-widgets-base==2.0.0",
]
)
)
167 changes: 1 addition & 166 deletions uc3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -132,171 +132,6 @@
" ]\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"#display(monitorprocess_step)\n",
"#monitorprocess_step.process = \"8cc8cbe9-81ab-4821-8dad-b25e73de9327\"\n",
"#monitorprocess_step.output\n",
"#monitorprocess_step.state\n",
"#monitorprocess_step.state\n",
"#display(widget)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "39bc69ef0cab47d0824e4081e23a6b6b",
"version_major": 2,
"version_minor": 0
},
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "64ea8cc9144b437a87359bfd027545f3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"AppLayout(children=(DisplayFinalOutput(children=(Output(),), layout=Layout(grid_area='center')),), layout=Layo…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import json\n",
"import uuid\n",
"import logging\n",
"import subprocess\n",
"from copy import copy\n",
"from pathlib import Path\n",
"\n",
"import ipywidgets as ipw\n",
"import shortuuid\n",
"import traitlets\n",
"from aiida.engine import ProcessState, submit\n",
"from aiida.orm import ArrayData, Code, Dict, Str, ProcessNode, load_code, load_node\n",
"from aiida.plugins import CalculationFactory\n",
"from aiidalab_widgets_base import (\n",
" AiidaNodeViewWidget,\n",
" ProcessMonitor,\n",
" ProcessNodesTreeWidget,\n",
" WizardAppWidgetStep,\n",
")\n",
"\n",
"from uc3.base_widgets_mod import ComputationalResourcesWidget\n",
"import matplotlib.pyplot as plt\n",
"from io import BytesIO\n",
"import base64\n",
"\n",
"from ipywidgets import AppLayout, Button, Layout, Label\n",
"import numpy as np\n",
"from numpy import random\n",
"from scipy import ndimage\n",
"from traitlets import HasTraits, Instance, observe\n",
"\n",
"class TestOutput(HasTraits):\n",
" area_flux = ndimage.gaussian_filter(random.normal(50, 5, size=(512, 512)), sigma=10).ravel()\n",
" volume_flux = ndimage.gaussian_filter(random.normal(100, 10, size=(512, 512)), sigma=10).ravel()\n",
" particle_size = ndimage.gaussian_filter(random.normal(10, 2, size=(512, 512)), sigma=10).ravel()\n",
" \n",
" def get_array(self, foo):\n",
" return [1,2,3,4,5]\n",
"\n",
"class DisplayFinalOutput(ipw.VBox, WizardAppWidgetStep):\n",
"\n",
"# output = traitlets.Instance(ArrayData, allow_none=True)\n",
" output = traitlets.Instance(TestOutput, allow_none=True)\n",
"\n",
" def __init__(self, **kwargs):\n",
" self.output_figure = plt.figure()\n",
" self.final_output = ipw.Output()\n",
"\n",
" super().__init__([self.final_output], **kwargs)\n",
"\n",
" @traitlets.observe(\"output\")\n",
" def _call_observe(self, change):\n",
" self._observe_configuration(self, change)\n",
"\n",
" def _observe_configuration(self, _, change):\n",
" \"Format and show the user inputs.\"\n",
" if change[\"new\"]:\n",
" output = self.output\n",
" area_flux = output.get_array(\"area_flux\")\n",
" volume_flux = output.get_array(\"volume_flux\")\n",
" particle_size = output.get_array(\"particle_size\")\n",
" display_dict = {\n",
" \"Area Flux\": area_flux,\n",
" \"Volume Flux\": volume_flux,\n",
" \"Particle Size\": particle_size,\n",
" }\n",
"\n",
" # Create a plot of the data\n",
" x = [1, 2, 3, 4, 5]\n",
" y = [2, 4, 5, 6, 7]\n",
" plt.plot(x, y)\n",
" plt.xlabel('X axis')\n",
" plt.ylabel('Y axis')\n",
"\n",
" # Save the plot to a buffer\n",
" buffer = BytesIO()\n",
" plt.savefig(buffer, format='svg')\n",
" plt.close()\n",
"\n",
" # Convert the buffer to a base64-encoded string and create the SVG image\n",
" svg_data = buffer.getvalue().decode()\n",
" base64_data = base64.b64encode(svg_data.encode()).decode()\n",
" svg_image = f'<img src=\"data:image/svg+xml;base64,{base64_data}\">'\n",
"\n",
" # Show the user inputs and the plot\n",
" self.final_output.clear_output(wait=True)\n",
" with self.final_output:\n",
"# display(ipw.HTML(f\"<h4>Configuration</h4><pre>{json.dumps(display_dict, indent=2)}</pre>\"))\n",
" display(ipw.HTML(svg_image))\n",
"\n",
" self.state = self.State.SUCCESS\n",
" else:\n",
" self.final_output.value = (\n",
" \"<h4>Configuration</h4>[Please configure user inputs]\"\n",
" )\n",
"\n",
"\n",
"output_data = TestOutput()\n",
"\n",
"output_widget = DisplayFinalOutput(output=output_data)\n",
"\n",
"AppLayout(center=output_widget)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -315,7 +150,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.8.10"
},
"vscode": {
"interpreter": {
Expand Down
12 changes: 6 additions & 6 deletions uc3_ap2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@
" ['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",
" ['k1', 'k1', 16676.31155],\n",
" ['ea1', 'ea1', 96636],\n",
" ['k2', 'k2', 6210120111],\n",
" ['ea2', 'ea2', 133788],\n",
" ['koeq', 'koeq', 1593.272279],\n",
" ['dhh20', 'dhh20', -4880]\n",
"])\n",
"\n",
"\n",
Expand Down
13 changes: 7 additions & 6 deletions uc3_ap3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,20 @@
"\n",
"computer_code_setup_step = ComputerCodeSetupStep(auto_advance=True)\n",
"configure_userinput_step = ConfigureUserInputStep(auto_advance=True, description_label_default=[ \n",
" ['dmf', 'dmf', 0],\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",
" ['k1', 'k1', 16676.31155],\n",
" ['ea1', 'ea1', 96636],\n",
" ['k2', 'k2', 6210120111],\n",
" ['ea2', 'ea2', 133788],\n",
" ['koeq', 'koeq', 1593.272279],\n",
" ['dhh20', 'dhh20', -4880]\n",
"])\n",
"\n",
"\n",
Expand Down

0 comments on commit 60ea6e1

Please sign in to comment.