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

use table_widget #1068

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
137 changes: 65 additions & 72 deletions calculation_history.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,11 @@
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as ipw\n",
"\n",
"how_to = ipw.HTML(\n",
" \"\"\"\n",
" <style>\n",
" .page-title {\n",
" font-family: Arial, sans-serif;\n",
" font-size: 28px;\n",
" color: #2c3e50;\n",
" margin-top: 0;\n",
" margin-bottom: 20px;\n",
" }\n",
" .how-to-section {\n",
" font-family: Arial, sans-serif;\n",
" background-color: #f9f9f9;\n",
" border: 1px solid #ddd;\n",
" border-radius: 8px;\n",
" padding: 15px 20px;\n",
" margin-bottom: 20px;\n",
" box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);\n",
" }\n",
" .how-to-section h2 {\n",
" color: #2c3e50;\n",
" font-size: 24px;\n",
" margin-top: 0;\n",
" }\n",
" .how-to-section p {\n",
" font-size: 14px;\n",
" color: #7f8c8d;\n",
" line-height: 1.6;\n",
" }\n",
" .how-to-section ul {\n",
" list-style-type: disc;\n",
" padding-left: 20px;\n",
" }\n",
" .how-to-section ul li {\n",
" font-size: 14px;\n",
" color: #34495e;\n",
" margin-bottom: 8px;\n",
" }\n",
" .how-to-section ul li b {\n",
" color: #2c3e50;\n",
" }\n",
" </style>\n",
" <div class=\"page-title\">Calculation history</div>\n",
" <div class=\"how-to-section\">\n",
" <h2>How to use this page</h2>\n",
" <p>\n",
" This page allows you to view and manage your calculation history. Use the table below to\n",
" see all jobs in the database. You can use the following filters to narrow down your search:\n",
" </p>\n",
" <ul>\n",
" <li><b>Label search field:</b> Enter a job label to find matching jobs.</li>\n",
" <li><b>Job state dropdown:</b> Filter jobs based on their state (e.g., finished, running).</li>\n",
" <li><b>Date range picker:</b> Select a start and end date to view jobs created within that range.</li>\n",
" <li><b>Properties filter:</b> Select specific properties associated with jobs.</li>\n",
" </ul>\n",
" <p>\n",
" Each row in the table provides links to inspect, delete or download a job. To delete a job, click the \"Delete\"\n",
" link in the respective row. To view detailed information about a job, click the \"PK\" link. To download the\n",
" input/output files of a job, click the \"Download\" link.\n",
" </p>\n",
" </div>\n",
" \"\"\"\n",
")\n",
"\n",
"how_to"
"%%javascript\n",
"IPython.OutputArea.prototype._should_scroll = function(lines) {\n",
" return false;\n",
"}\n",
"document.title='AiiDAlab QE app calculation history'"
]
},
{
Expand Down Expand Up @@ -104,11 +42,66 @@
"metadata": {},
"outputs": [],
"source": [
"from aiidalab_qe.app.utils.search_jobs import QueryInterface\n",
"import ipywidgets as ipw\n",
"from importlib_resources import files\n",
"from jinja2 import Environment\n",
"\n",
"from aiidalab_qe.app.static import templates\n",
"from aiidalab_qe.common.infobox import InfoBox\n",
"\n",
"title = ipw.HTML(\n",
" \"<h1> Calculation history</h1>\", layout=ipw.Layout(margin=\"0 0 15px 0\")\n",
")\n",
"env = Environment()\n",
"guide_template = (\n",
" files(templates).joinpath(\"calculation_history_guide.jinja\").read_text()\n",
")\n",
"guide = ipw.HTML(env.from_string(guide_template).render())\n",
"\n",
"\n",
"info_container = InfoBox(layout=ipw.Layout(margin=\"14px 2px 0\"))\n",
"guide_toggle = ipw.ToggleButton(\n",
" layout=ipw.Layout(width=\"150px\"),\n",
" button_style=\"\",\n",
" icon=\"book\",\n",
" value=False,\n",
" description=\"Page guide\",\n",
" tooltip=\"Learn how to use the app\",\n",
" disabled=False,\n",
")\n",
"\n",
"\n",
"def _on_guide_toggle(change: dict):\n",
" \"\"\"Toggle the guide section.\"\"\"\n",
" if change[\"new\"]:\n",
" info_container.children = [\n",
" guide,\n",
" ]\n",
" info_container.layout.display = \"flex\"\n",
" else:\n",
" info_container.children = []\n",
" info_container.layout.display = \"none\"\n",
"\n",
"\n",
"guide_toggle.observe(\n",
" _on_guide_toggle,\n",
" \"value\",\n",
")\n",
"\n",
"controls = ipw.VBox(children=[title, guide_toggle, info_container])\n",
"controls"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from aiidalab_qe.app.utils.search_jobs import CalculationHistory\n",
"\n",
"calculation_history = QueryInterface()\n",
"calculation_history.setup_table()\n",
"calculation_history.filters_layout"
"calculation_history = CalculationHistory()\n",
"calculation_history.main"
]
},
{
Expand All @@ -117,7 +110,7 @@
"metadata": {},
"outputs": [],
"source": [
"calculation_history.table"
"calculation_history.load_table()"
]
}
],
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ install_requires =
aiida-wannier90-workflows==2.3.0
pymatgen==2024.5.1
anywidget==0.9.13
table_widget~=0.0.2

python_requires = >=3.9

[options.packages.find]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<div class="guide">
<h2>How to use this page</h2>
<p>
This page allows you to view, filter, sort, and manage your calculation history.
</p>
<h4>Filters and search</h4>
<ul>
<li><b>Quick search field:</b> Use the search bar above the table to find jobs by any visible field.</li>
<li><b>Column-specific filters:</b> Filter data directly in each column using their respective filter options.</li>
<li><b>Job state dropdown:</b> Filter jobs by their state (e.g., Finished, Running).</li>
<li><b>Date range picker:</b> Select a start and end date to narrow down jobs based on creation date.</li>
<li><b>Properties filter:</b> Select one or more properties to narrow the results. Only calculations that include all the selected properties will be displayed. Leave all checkboxes unselected to include calculations regardless of their properties.</li>
</ul>
<h4>Table actions</h4>
<ul>
<li><b>Editable fields:</b> Edit the <b>label</b> and <b>description</b> of a job directly by clicking on the respective fields.</li>
<li><b>Inspect:</b> Click on a job's ID link to view detailed information.</li>
<li><b>Delete:</b> Remove a job by clicking the "Delete" link in its row. A confirmation page will be opened.</li>
<li><b>Download:</b> Download raw data (i.e. input and output files) and/or the AiiDA archive of a job using the "Download" link.</li>
</ul>
<h4>Display options</h4>
<ul>
<li><b>Sorting:</b> Click any column header to sort the table by that column.</li>
<li><b>Column management:</b> Show, hide columns to customize the table view.</li>
<li><b>Time format:</b> Toggle between "Absolute" (specific dates) and "Relative" (time elapsed).</li>
<li><b>ID format:</b> Switch between "PK" or "UUID" for job identification.</li>
</ul>
</div>
Loading
Loading