Skip to content
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

Add job list page #657

Merged
merged 14 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions delete.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# AiiDAlab QauntumESPRESSO App"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import urllib.parse as urlparse\n",
"\n",
"from aiida import load_profile\n",
"from aiida.tools import delete_nodes\n",
"\n",
"url = urlparse.urlsplit(jupyter_notebook_url) # noqa F821\n",
"query = urlparse.parse_qs(url.query)\n",
"pk = int(query['pk'][0])\n",
"\n",
"\n",
"def delete_node(pk):\n",
" load_profile()\n",
" ## delete the group\n",
" _, was_deleted = delete_nodes([pk], dry_run=False)\n",
"\n",
" if was_deleted:\n",
"\n",
" print(f'Node {pk} deleted.')\n",
"\n",
"# Ask for confirmation\n",
"if input(f'Do you really want to delete node {pk}? [y/N] ').strip().lower() == 'y':\n",
Copy link
Member

@AndresOrtegaGuerrero AndresOrtegaGuerrero Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also It might be a good idea to display the number nodes associated, so the person know what nodes or workchains are being deleted

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I display the number of nodes to be deleted.

" delete_node(pk)\n",
"else:\n",
" print('Deletion aborted.')"
]
}
],
"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"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
101 changes: 101 additions & 0 deletions job_list.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# AiiDAlab QauntumESPRESSO App\n",
superstar54 marked this conversation as resolved.
Show resolved Hide resolved
"\n",
"## Job List\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as ipw\n",
"from aiida import load_profile\n",
"from aiida.tools.query.calculation import CalculationQueryBuilder\n",
"\n",
"load_profile()\n",
"\n",
"\n",
"process_label = \"QeAppWorkChain\"\n",
"projections = [\"pk\", \"ctime\", \"state\", \"label\"]\n",
"\n",
"\n",
"def query_data():\n",
" builder = CalculationQueryBuilder()\n",
" filters = builder.get_filters(\n",
" process_label=process_label,\n",
" )\n",
" query_set = builder.get_query_set(\n",
" filters=filters,\n",
" order_by={\"ctime\": \"desc\"},\n",
" )\n",
" projected = builder.get_projected(\n",
" query_set,\n",
" projections=projections,\n",
" )\n",
" return projected\n",
"\n",
"\n",
"table = ipw.HTML()\n",
"\n",
"table.value = \"\"\"\n",
" <style>\n",
" .df { border: none; }\n",
" .df tbody tr:nth-child(odd) { background-color: #e5e7e9; }\n",
" .df tbody tr:nth-child(odd):hover { background-color: #f5b7b1; }\n",
" .df tbody tr:nth-child(even):hover { background-color: #f5b7b1; }\n",
" .df tbody td { min-width: 80px; text-align: center; border: none }\n",
" .df th { text-align: center; border: none; border-bottom: 1px solid black;}\n",
" </style>\n",
" \"\"\"\n",
"\n",
"# use pandas to create a dataframe from the query data\n",
"import pandas as pd\n",
"\n",
"df = pd.DataFrame(query_data()[1:], columns=projections)\n",
"\n",
"# add a column to the dataframe with a button to delete the archive\n",
"for index, row in df.iterrows():\n",
" pk = row['pk']\n",
" df.at[index, \"formula\"] = row['label'].split(\"structure\")[-0]\n",
" df.at[index, \"relaxed\"] = \"is relaxed\" in row['label']\n",
" df.at[index, \"properties\"] = row['label'].split(\"properties on\")[-1]\n",
" df.at[index, 'Delete'] = f\"\"\"<a href=\"./delete.ipynb?pk={pk}\" target=\"_blank\">Delete</a>\"\"\"\n",
" df.at[index, 'Inspect'] = f\"\"\"<a href=\"./qe.ipynb?pk={pk}\" target=\"_blank\">Inspect</a>\"\"\"\n",
"\n",
"# delete the label column\n",
"df = df.drop(columns=['label'])\n",
"\n",
"table.value += df.to_html(classes=\"df\", escape=False, index=False)\n",
"table"
]
}
],
"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"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
10 changes: 10 additions & 0 deletions qe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"except Exception:\n",
" pass\n",
"\n",
"import urllib.parse as urlparse\n",
"\n",
"import ipywidgets as ipw\n",
"from aiidalab_widgets_base.bug_report import (\n",
" install_create_github_issue_exception_handler,\n",
Expand Down Expand Up @@ -65,7 +67,15 @@
" f'<p style=\"text-align:right;\">Copyright (c) 2023 AiiDAlab team (EPFL)&#8195Version: {__version__}</p>'\n",
")\n",
"\n",
"url = urlparse.urlsplit(jupyter_notebook_url) # noqa F821\n",
"query = urlparse.parse_qs(url.query)\n",
"\n",
"\n",
"app_with_work_chain_selector = App(qe_auto_setup=True)\n",
"# if a pk is provided in the query string, set it as the value of the work_chain_selector\n",
"if 'pk' in query:\n",
" pk = int(query['pk'][0])\n",
" app_with_work_chain_selector.work_chain_selector.value = pk\n",
"\n",
"output = ipw.Output()\n",
"install_create_github_issue_exception_handler(\n",
Expand Down
3 changes: 2 additions & 1 deletion start.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ def get_start_widget(appbase, jupbase, notebase):
f"""
<table>
<tr>
<th style="text-align:center">Preferences</th>
<th style="text-align:center">Utils</th>
<tr>
<td valign="top"><ul>
<li><a href="{appbase}/job_list.ipynb" target="_blank">Job List</a></li>
<li><a href="{appbase}/plugin_list.ipynb" target="_blank">Plugins</a></li>
</ul></td>
</tr>
Expand Down
Loading