From 7a6a6c1c0eff82e9590393faa9c6a59cc4ed91f9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 17:05:48 +0000 Subject: [PATCH 1/3] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.6.0...v5.0.0) - [github.com/astral-sh/ruff-pre-commit: v0.5.0 → v0.6.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.0...v0.6.9) - [github.com/sirosen/check-jsonschema: 0.28.6 → 0.29.3](https://github.com/sirosen/check-jsonschema/compare/0.28.6...0.29.3) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cff2a0778..e5d30f0ad 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-json - id: check-yaml @@ -13,7 +13,7 @@ repos: exclude: miscellaneous/structures - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.0 + rev: v0.6.9 hooks: - id: ruff-format exclude: ^docs/.* @@ -27,7 +27,7 @@ repos: args: [--preserve-quotes] - repo: https://github.com/sirosen/check-jsonschema - rev: 0.28.6 + rev: 0.29.3 hooks: - id: check-github-workflows From a5aad2f1b172935835833c9b4f39ae9e93f8d7a5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 17:06:42 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- notebooks/eln_import.ipynb | 17 ++-- notebooks/process.ipynb | 31 ++++-- notebooks/process_list.ipynb | 82 ++++++++-------- notebooks/structures.ipynb | 7 +- notebooks/viewers.ipynb | 182 ++++++++++++++++++++--------------- notebooks/wizard_apps.ipynb | 49 +++++----- 6 files changed, 213 insertions(+), 155 deletions(-) diff --git a/notebooks/eln_import.ipynb b/notebooks/eln_import.ipynb index 51e566821..a640a50ea 100644 --- a/notebooks/eln_import.ipynb +++ b/notebooks/eln_import.ipynb @@ -42,10 +42,15 @@ "metadata": {}, "outputs": [], "source": [ - "from aiidalab_widgets_base import AiidaNodeViewWidget, OpenAiidaNodeInAppWidget, ElnImportWidget\n", "import urllib.parse as urlparse\n", - "from aiidalab_widgets_base import viewer\n", - "from traitlets import dlink" + "\n", + "from traitlets import dlink\n", + "\n", + "from aiidalab_widgets_base import (\n", + " AiidaNodeViewWidget,\n", + " ElnImportWidget,\n", + " OpenAiidaNodeInAppWidget,\n", + ")" ] }, { @@ -57,7 +62,7 @@ "source": [ "url = urlparse.urlsplit(jupyter_notebook_url)\n", "parsed_url = urlparse.parse_qs(url.query)\n", - "params = {key:value[0] for key, value in parsed_url.items()}\n", + "params = {key: value[0] for key, value in parsed_url.items()}\n", "eln_widget = ElnImportWidget(**params)" ] }, @@ -71,8 +76,8 @@ "object_displayed = AiidaNodeViewWidget()\n", "open_in_app = OpenAiidaNodeInAppWidget()\n", "\n", - "_ = dlink((eln_widget, 'node'), (object_displayed, 'node'))\n", - "_ = dlink((eln_widget, 'node'), (open_in_app, 'node'))" + "_ = dlink((eln_widget, \"node\"), (object_displayed, \"node\"))\n", + "_ = dlink((eln_widget, \"node\"), (open_in_app, \"node\"))" ] }, { diff --git a/notebooks/process.ipynb b/notebooks/process.ipynb index 8584e6754..539be56e1 100644 --- a/notebooks/process.ipynb +++ b/notebooks/process.ipynb @@ -37,13 +37,19 @@ "metadata": {}, "outputs": [], "source": [ - "import ipywidgets as ipw\n", - "from IPython.display import clear_output\n", - "from aiida.cmdline.utils.ascii_vis import format_call_graph\n", "import urllib.parse as urlparse\n", + "\n", "from aiida.orm import load_node\n", - "from aiidalab_widgets_base import ProcessFollowerWidget, ProgressBarWidget, ProcessReportWidget\n", - "from aiidalab_widgets_base import ProcessInputsWidget, ProcessOutputsWidget, ProcessCallStackWidget, RunningCalcJobOutputWidget" + "\n", + "from aiidalab_widgets_base import (\n", + " ProcessCallStackWidget,\n", + " ProcessFollowerWidget,\n", + " ProcessInputsWidget,\n", + " ProcessOutputsWidget,\n", + " ProcessReportWidget,\n", + " ProgressBarWidget,\n", + " RunningCalcJobOutputWidget,\n", + ")" ] }, { @@ -54,8 +60,8 @@ "source": [ "url = urlparse.urlsplit(jupyter_notebook_url)\n", "url_dict = urlparse.parse_qs(url.query)\n", - "if 'id' in url_dict:\n", - " pk = int(url_dict['id'][0])\n", + "if \"id\" in url_dict:\n", + " pk = int(url_dict[\"id\"][0])\n", " process = load_node(pk)\n", "else:\n", " process = None" @@ -101,8 +107,15 @@ "source": [ "follower = ProcessFollowerWidget(\n", " process,\n", - " followers=[ProgressBarWidget(), ProcessReportWidget(), ProcessCallStackWidget(), RunningCalcJobOutputWidget()], path_to_root=\"../../\", \n", - " update_interval=2)\n", + " followers=[\n", + " ProgressBarWidget(),\n", + " ProcessReportWidget(),\n", + " ProcessCallStackWidget(),\n", + " RunningCalcJobOutputWidget(),\n", + " ],\n", + " path_to_root=\"../../\",\n", + " update_interval=2,\n", + ")\n", "display(follower)\n", "follower.follow(detach=True)" ] diff --git a/notebooks/process_list.ipynb b/notebooks/process_list.ipynb index 6d2d8fc05..5765ad6ae 100644 --- a/notebooks/process_list.ipynb +++ b/notebooks/process_list.ipynb @@ -38,9 +38,10 @@ "outputs": [], "source": [ "import ipywidgets as ipw\n", - "from aiidalab_widgets_base import ProcessListWidget\n", + "from plumpy import ProcessState\n", "from traitlets import dlink\n", - "from plumpy import ProcessState" + "\n", + "from aiidalab_widgets_base import ProcessListWidget" ] }, { @@ -51,63 +52,68 @@ "source": [ "process_list = ProcessListWidget(path_to_root=\"../../\")\n", "\n", - "past_days_widget = ipw.IntText(value=7, description='Past days:')\n", - "dlink((past_days_widget, 'value'), (process_list, 'past_days'))\n", + "past_days_widget = ipw.IntText(value=7, description=\"Past days:\")\n", + "dlink((past_days_widget, \"value\"), (process_list, \"past_days\"))\n", "\n", "\n", "all_days_checkbox = ipw.Checkbox(description=\"All days\", value=False)\n", - "dlink((all_days_checkbox, 'value'), (past_days_widget, 'disabled'))\n", - "dlink((all_days_checkbox, 'value'), (process_list, 'past_days'), transform=lambda v: -1 if v else past_days_widget.value)\n", + "dlink((all_days_checkbox, \"value\"), (past_days_widget, \"disabled\"))\n", + "dlink(\n", + " (all_days_checkbox, \"value\"),\n", + " (process_list, \"past_days\"),\n", + " transform=lambda v: -1 if v else past_days_widget.value,\n", + ")\n", "\n", "incoming_node_widget = ipw.Text(\n", - " description='Incoming node:',\n", - " style={'description_width': 'initial'}\n", + " description=\"Incoming node:\", style={\"description_width\": \"initial\"}\n", ")\n", - "dlink((incoming_node_widget, 'value'), (process_list, 'incoming_node'))\n", + "dlink((incoming_node_widget, \"value\"), (process_list, \"incoming_node\"))\n", "\n", "\n", "outgoing_node_widget = ipw.Text(\n", - " description='Outgoing node:',\n", - " style={'description_width': 'initial'}\n", + " description=\"Outgoing node:\", style={\"description_width\": \"initial\"}\n", ")\n", - "dlink((outgoing_node_widget, 'value'), (process_list, 'outgoing_node'))\n", + "dlink((outgoing_node_widget, \"value\"), (process_list, \"outgoing_node\"))\n", "\n", "\n", "available_states = [state.value for state in ProcessState]\n", - "process_state_widget = ipw.SelectMultiple(options=available_states,\n", - " value=available_states,\n", - " description='Process State:',\n", - " style={'description_width': 'initial'},\n", - " disabled=False)\n", - "dlink((process_state_widget, 'value'), (process_list, 'process_states'))\n", + "process_state_widget = ipw.SelectMultiple(\n", + " options=available_states,\n", + " value=available_states,\n", + " description=\"Process State:\",\n", + " style={\"description_width\": \"initial\"},\n", + " disabled=False,\n", + ")\n", + "dlink((process_state_widget, \"value\"), (process_list, \"process_states\"))\n", "\n", "process_label_widget = ipw.Text(\n", - " description='Process label:',\n", - " style={'description_width': 'initial'}\n", + " description=\"Process label:\", style={\"description_width\": \"initial\"}\n", ")\n", - "dlink((process_label_widget, 'value'), (process_list, 'process_label'))\n", + "dlink((process_label_widget, \"value\"), (process_list, \"process_label\"))\n", "\n", "description_contains_widget = ipw.Text(\n", - " description='Description contains:',\n", - " style={'description_width': 'initial'}\n", + " description=\"Description contains:\", style={\"description_width\": \"initial\"}\n", ")\n", - "dlink((description_contains_widget, 'value'), (process_list, 'description_contains'))\n", + "dlink((description_contains_widget, \"value\"), (process_list, \"description_contains\"))\n", "\n", "display(\n", - " ipw.HBox([\n", - " ipw.VBox([past_days_widget, process_state_widget]),\n", - " ipw.VBox(\n", - " [\n", - " all_days_checkbox,\n", - " incoming_node_widget,\n", - " outgoing_node_widget,\n", - " process_label_widget,\n", - " description_contains_widget\n", - " ],\n", - " layout={'margin': '0px 0px 0px 40px'}\n", - " )\n", - " ]),\n", - " process_list)" + " ipw.HBox(\n", + " [\n", + " ipw.VBox([past_days_widget, process_state_widget]),\n", + " ipw.VBox(\n", + " [\n", + " all_days_checkbox,\n", + " incoming_node_widget,\n", + " outgoing_node_widget,\n", + " process_label_widget,\n", + " description_contains_widget,\n", + " ],\n", + " layout={\"margin\": \"0px 0px 0px 40px\"},\n", + " ),\n", + " ]\n", + " ),\n", + " process_list,\n", + ")" ] }, { diff --git a/notebooks/structures.ipynb b/notebooks/structures.ipynb index f5974aee6..7720474ee 100644 --- a/notebooks/structures.ipynb +++ b/notebooks/structures.ipynb @@ -57,10 +57,11 @@ " title=\"From Examples\",\n", " examples=[\n", " (\"Silicon oxide\", \"../miscellaneous/structures/SiO2.xyz\"),\n", - " (\"Silicon\", \"../miscellaneous/structures/Si.xyz\")\n", - " ]),\n", + " (\"Silicon\", \"../miscellaneous/structures/Si.xyz\"),\n", + " ],\n", + " ),\n", " ],\n", - " editors = [\n", + " editors=[\n", " awb.BasicStructureEditor(title=\"Basic Editor\"),\n", " awb.BasicCellEditor(title=\"Basic Cell Editor\"),\n", " ],\n", diff --git a/notebooks/viewers.ipynb b/notebooks/viewers.ipynb index 2d93bdb0b..2b1dc9826 100644 --- a/notebooks/viewers.ipynb +++ b/notebooks/viewers.ipynb @@ -7,7 +7,8 @@ "outputs": [], "source": [ "# Load the default AiiDA profile.\n", - "from aiida import orm, load_profile\n", + "from aiida import load_profile, orm\n", + "\n", "load_profile();" ] }, @@ -39,12 +40,14 @@ "source": [ "from aiidalab_widgets_base import viewer\n", "\n", - "p = orm.Dict(dict={\n", - " 'parameter 1' : 'some string',\n", - " 'parameter 2' : 2,\n", - " 'parameter 3' : 3.0,\n", - " 'parameter 4' : [1, 2, 3],\n", - "})\n", + "p = orm.Dict(\n", + " dict={\n", + " \"parameter 1\": \"some string\",\n", + " \"parameter 2\": 2,\n", + " \"parameter 3\": 3.0,\n", + " \"parameter 4\": [1, 2, 3],\n", + " }\n", + ")\n", "vwr = viewer(p.store(), downloadable=True)\n", "display(vwr)" ] @@ -67,14 +70,17 @@ "outputs": [], "source": [ "from aiida import orm\n", + "\n", "from aiidalab_widgets_base import AiidaNodeViewWidget\n", "\n", - "p = orm.Dict(dict={\n", - " 'parameter 1' : 'some string',\n", - " 'parameter 2' : 2,\n", - " 'parameter 3' : 3.0,\n", - " 'parameter 4' : [1, 2, 3],\n", - "})\n", + "p = orm.Dict(\n", + " dict={\n", + " \"parameter 1\": \"some string\",\n", + " \"parameter 2\": 2,\n", + " \"parameter 3\": 3.0,\n", + " \"parameter 4\": [1, 2, 3],\n", + " }\n", + ")\n", "wdgt = AiidaNodeViewWidget(node=p.store())\n", "display(wdgt)" ] @@ -96,10 +102,10 @@ "from aiida import plugins\n", "from ase.build import molecule\n", "\n", - "m = molecule('H2O')\n", + "m = molecule(\"H2O\")\n", "m.center(vacuum=2.0)\n", "\n", - "StructureData = plugins.DataFactory('core.structure')\n", + "StructureData = plugins.DataFactory(\"core.structure\")\n", "s = StructureData(ase=m)\n", "\n", "wdgt.node = s.store()" @@ -158,16 +164,19 @@ "metadata": {}, "outputs": [], "source": [ - "from aiidalab_widgets_base.viewers import DictViewer\n", "from aiida import plugins\n", "\n", - "Dict = plugins.DataFactory('core.dict')\n", - "p = Dict(dict={\n", - " 'Parameter' :'super long string '*4,\n", - " 'parameter 2' :'value 2',\n", - " 'parameter 3' : 1,\n", - " 'parameter 4' : 2,\n", - "})\n", + "from aiidalab_widgets_base.viewers import DictViewer\n", + "\n", + "Dict = plugins.DataFactory(\"core.dict\")\n", + "p = Dict(\n", + " dict={\n", + " \"Parameter\": \"super long string \" * 4,\n", + " \"parameter 2\": \"value 2\",\n", + " \"parameter 3\": 1,\n", + " \"parameter 4\": 2,\n", + " }\n", + ")\n", "vwr = DictViewer(p.store(), downloadable=True)\n", "display(vwr)" ] @@ -188,27 +197,27 @@ "metadata": {}, "outputs": [], "source": [ - "from ase.build import molecule, bulk\n", - "from aiidalab_widgets_base.viewers import StructureDataViewer\n", + "from ase.build import bulk, molecule\n", "\n", + "from aiidalab_widgets_base.viewers import StructureDataViewer\n", "\n", "# create bulk Pt\n", - "pt = bulk('Pt', cubic = True)\n", + "pt = bulk(\"Pt\", cubic=True)\n", "\n", "# Cif data.\n", - "CifData = plugins.DataFactory('core.cif')\n", + "CifData = plugins.DataFactory(\"core.cif\")\n", "s = CifData(ase=pt)\n", "vwr_cif = StructureDataViewer(s.store())\n", "display(vwr_cif)\n", "\n", "# Structure data.\n", - "m = molecule('H2O')\n", + "m = molecule(\"H2O\")\n", "m.center(vacuum=2.0)\n", "\n", - "StructureData = plugins.DataFactory('core.structure')\n", + "StructureData = plugins.DataFactory(\"core.structure\")\n", "s = StructureData(ase=m)\n", "vwr_structure = StructureDataViewer(s.store())\n", - "display(vwr_structure)\n" + "display(vwr_structure)" ] }, { @@ -229,42 +238,59 @@ "source": [ "import numpy as np\n", "from aiida import plugins\n", + "\n", "from aiidalab_widgets_base.viewers import BandsDataViewer\n", "\n", - "BandsData = plugins.DataFactory('core.array.bands')\n", + "BandsData = plugins.DataFactory(\"core.array.bands\")\n", "bs = BandsData()\n", - "kpoints = np.array([[0. , 0. , 0. ], # array shape is 12 * 3\n", - " [0.1 , 0. , 0.1 ],\n", - " [0.2 , 0. , 0.2 ],\n", - " [0.3 , 0. , 0.3 ],\n", - " [0.4 , 0. , 0.4 ],\n", - " [0.5 , 0. , 0.5 ],\n", - " [0.5 , 0. , 0.5 ],\n", - " [0.525 , 0.05 , 0.525 ],\n", - " [0.55 , 0.1 , 0.55 ],\n", - " [0.575 , 0.15 , 0.575 ],\n", - " [0.6 , 0.2 , 0.6 ],\n", - " [0.625 , 0.25 , 0.625 ]])\n", - "\n", - "bands = np.array([\n", - " [-5.64024889, 6.66929678, 6.66929678, 6.66929678, 8.91047649], # array shape is 12 * 5, where 12 is the size of the kpoints mesh\n", - " [-5.46976726, 5.76113772, 5.97844699, 5.97844699, 8.48186734], # and 5 is the number of states\n", - " [-4.93870761, 4.06179965, 4.97235487, 4.97235488, 7.68276008],\n", - " [-4.05318686, 2.21579935, 4.18048674, 4.18048675, 7.04145185],\n", - " [-2.83974972, 0.37738276, 3.69024464, 3.69024465, 6.75053465],\n", - " [-1.34041116, -1.34041115, 3.52500177, 3.52500178, 6.92381041],\n", - " [-1.34041116, -1.34041115, 3.52500177, 3.52500178, 6.92381041],\n", - " [-1.34599146, -1.31663872, 3.34867603, 3.54390139, 6.93928289],\n", - " [-1.36769345, -1.24523403, 2.94149041, 3.6004033 , 6.98809593],\n", - " [-1.42050683, -1.12604118, 2.48497007, 3.69389815, 7.07537154],\n", - " [-1.52788845, -0.95900776, 2.09104321, 3.82330632, 7.20537566],\n", - " [-1.71354964, -0.74425095, 1.82242466, 3.98697455, 7.37979746]])\n", + "kpoints = np.array(\n", + " [\n", + " [0.0, 0.0, 0.0], # array shape is 12 * 3\n", + " [0.1, 0.0, 0.1],\n", + " [0.2, 0.0, 0.2],\n", + " [0.3, 0.0, 0.3],\n", + " [0.4, 0.0, 0.4],\n", + " [0.5, 0.0, 0.5],\n", + " [0.5, 0.0, 0.5],\n", + " [0.525, 0.05, 0.525],\n", + " [0.55, 0.1, 0.55],\n", + " [0.575, 0.15, 0.575],\n", + " [0.6, 0.2, 0.6],\n", + " [0.625, 0.25, 0.625],\n", + " ]\n", + ")\n", + "\n", + "bands = np.array(\n", + " [\n", + " [\n", + " -5.64024889,\n", + " 6.66929678,\n", + " 6.66929678,\n", + " 6.66929678,\n", + " 8.91047649,\n", + " ], # array shape is 12 * 5, where 12 is the size of the kpoints mesh\n", + " [\n", + " -5.46976726,\n", + " 5.76113772,\n", + " 5.97844699,\n", + " 5.97844699,\n", + " 8.48186734,\n", + " ], # and 5 is the number of states\n", + " [-4.93870761, 4.06179965, 4.97235487, 4.97235488, 7.68276008],\n", + " [-4.05318686, 2.21579935, 4.18048674, 4.18048675, 7.04145185],\n", + " [-2.83974972, 0.37738276, 3.69024464, 3.69024465, 6.75053465],\n", + " [-1.34041116, -1.34041115, 3.52500177, 3.52500178, 6.92381041],\n", + " [-1.34041116, -1.34041115, 3.52500177, 3.52500178, 6.92381041],\n", + " [-1.34599146, -1.31663872, 3.34867603, 3.54390139, 6.93928289],\n", + " [-1.36769345, -1.24523403, 2.94149041, 3.6004033, 6.98809593],\n", + " [-1.42050683, -1.12604118, 2.48497007, 3.69389815, 7.07537154],\n", + " [-1.52788845, -0.95900776, 2.09104321, 3.82330632, 7.20537566],\n", + " [-1.71354964, -0.74425095, 1.82242466, 3.98697455, 7.37979746],\n", + " ]\n", + ")\n", "bs.set_kpoints(kpoints)\n", "bs.set_bands(bands)\n", - "labels = [(0, u'GAMMA'),\n", - " (5, u'X'),\n", - " (6, u'Z'),\n", - " (11, u'U')]\n", + "labels = [(0, \"GAMMA\"), (5, \"X\"), (6, \"Z\"), (11, \"U\")]\n", "bs.labels = labels\n", "\n", "\n", @@ -289,17 +315,17 @@ "outputs": [], "source": [ "import io\n", + "\n", "from aiida import plugins\n", - "from aiidalab_widgets_base.viewers import FolderDataViewer\n", "\n", - "FolderData = plugins.DataFactory('core.folder')\n", + "FolderData = plugins.DataFactory(\"core.folder\")\n", "fd = FolderData()\n", - "with io.StringIO('content of test1 file') as fobj:\n", - " fd.put_object_from_filelike(fobj, path='test1.txt')\n", - "with io.StringIO('content of test2 file') as fobj:\n", - " fd.put_object_from_filelike(fobj, path='test2.txt')\n", - "with io.StringIO(u'content of test_long file'*1000) as fobj:\n", - " fd.put_object_from_filelike(fobj, path='test_long.txt')\n", + "with io.StringIO(\"content of test1 file\") as fobj:\n", + " fd.put_object_from_filelike(fobj, path=\"test1.txt\")\n", + "with io.StringIO(\"content of test2 file\") as fobj:\n", + " fd.put_object_from_filelike(fobj, path=\"test2.txt\")\n", + "with io.StringIO(\"content of test_long file\" * 1000) as fobj:\n", + " fd.put_object_from_filelike(fobj, path=\"test_long.txt\")\n", "vwr = viewer(fd.store(), downloadable=True)\n", "display(vwr)" ] @@ -320,10 +346,14 @@ "metadata": {}, "outputs": [], "source": [ - "from aiida.workflows.arithmetic.add_multiply import add, add_multiply\n", "from aiida import engine, orm\n", + "from aiida.workflows.arithmetic.add_multiply import add, add_multiply\n", + "\n", "from aiidalab_widgets_base.viewers import ProcessNodeViewerWidget\n", - "result, workfunction = engine.run_get_node(add_multiply, orm.Int(3), orm.Int(4), orm.Int(5))\n", + "\n", + "result, workfunction = engine.run_get_node(\n", + " add_multiply, orm.Int(3), orm.Int(4), orm.Int(5)\n", + ")\n", "vwr_workfunction = ProcessNodeViewerWidget(workfunction)\n", "display(vwr_workfunction)\n", "\n", @@ -354,15 +384,17 @@ "metadata": {}, "outputs": [], "source": [ - "from aiidalab_widgets_base import register_viewer_widget\n", "import ipywidgets as ipw\n", - "from aiida.orm import Int\n", "\n", - "@register_viewer_widget('data.core.int.Int.')\n", + "from aiidalab_widgets_base import register_viewer_widget\n", + "\n", + "\n", + "@register_viewer_widget(\"data.core.int.Int.\")\n", "class IntViewerWidget(ipw.HTML):\n", " def __init__(self, node, **kwargs):\n", " super().__init__(**kwargs)\n", - " self.value = f'Int object: {node.value}'\n", + " self.value = f\"Int object: {node.value}\"\n", + "\n", "\n", "vwr = viewer(orm.Int(3).store())\n", "display(vwr)" diff --git a/notebooks/wizard_apps.ipynb b/notebooks/wizard_apps.ipynb index 1dcfc4606..2afd03f21 100644 --- a/notebooks/wizard_apps.ipynb +++ b/notebooks/wizard_apps.ipynb @@ -31,21 +31,25 @@ "source": [ "import enum\n", "import json\n", - "import time\n", "import threading\n", + "import time\n", "\n", - "import traitlets\n", "import ipywidgets as ipw\n", + "import traitlets\n", "\n", - "from aiidalab_widgets_base import WizardAppWidget\n", - "from aiidalab_widgets_base import WizardAppWidgetStep\n", - "\n", + "from aiidalab_widgets_base import WizardAppWidget, WizardAppWidgetStep\n", "\n", "OrderStatus = enum.Enum(\n", " \"OrderStatus\",\n", - " {\"init\": 0, \"in_preparation\": 40, \"in_transit\": 65, \"delivered\": 100, \"unavailable\": -1}\n", + " {\n", + " \"init\": 0,\n", + " \"in_preparation\": 40,\n", + " \"in_transit\": 65,\n", + " \"delivered\": 100,\n", + " \"unavailable\": -1,\n", + " },\n", ")\n", - " \n", + "\n", "\n", "class OrderTracker(traitlets.HasTraits):\n", " \"\"\"Helper class to keep track of our pizza order.\"\"\"\n", @@ -70,24 +74,25 @@ " self.status = OrderStatus.delivered\n", "\n", " threading.Thread(target=simulate_order).start()\n", - " \n", - " \n", + "\n", " @traitlets.default(\"status\")\n", " def _default_status(self):\n", " \"\"\"Initialize the initial (default) order status.\"\"\"\n", " return OrderStatus.init\n", - " \n", - " \n", + "\n", + "\n", "class OrderProgressWidget(ipw.HBox):\n", " \"\"\"Widget to nicely represent the order status.\"\"\"\n", - " \n", + "\n", " status = traitlets.Instance(OrderStatus)\n", "\n", " def __init__(self, **kwargs):\n", - " self._progress_bar = ipw.FloatProgress(style={\"description_width\": \"initial\"}, description=\"Delivery progress:\")\n", + " self._progress_bar = ipw.FloatProgress(\n", + " style={\"description_width\": \"initial\"}, description=\"Delivery progress:\"\n", + " )\n", " self._status_text = ipw.HTML()\n", " super().__init__([self._progress_bar, self._status_text], **kwargs)\n", - " \n", + "\n", " @traitlets.observe(\"status\")\n", " def _observe_status(self, change):\n", " with self.hold_trait_notifications():\n", @@ -99,7 +104,7 @@ " OrderStatus.delivered: \"Delivered! :)\",\n", " OrderStatus.unavailable: \"Your order is not available\",\n", " }.get(change[\"new\"], change[\"new\"].name)\n", - " \n", + "\n", " self._progress_bar.value = change[\"new\"].value\n", " self._progress_bar.bar_style = {\n", " OrderStatus.delivered: \"success\",\n", @@ -112,7 +117,6 @@ "\n", "\n", "class ConfigureOrderStep(ipw.HBox, WizardAppWidgetStep):\n", - "\n", " disabled = traitlets.Bool()\n", " configuration = traitlets.Dict(allow_none=True)\n", "\n", @@ -147,13 +151,13 @@ " def _confirm_configuration(self, button):\n", " \"Confirm the pizza configuration and expose as trait.\"\n", " self.configuration = dict(style=self.style.value, toppings=self.toppings.value)\n", - " \n", + "\n", " def reset(self):\n", " with self.hold_trait_notifications():\n", " self.style.value = None\n", " self.toppings.value = []\n", " self.configuration = {}\n", - " \n", + "\n", " @traitlets.default(\"state\")\n", " def _default_state(self):\n", " return self.State.READY\n", @@ -183,7 +187,7 @@ " with self.hold_trait_notifications():\n", " self.disabled = change[\"new\"] == self.State.SUCCESS\n", " self.confirm_button.disabled = change[\"new\"] is not self.State.CONFIGURED\n", - " \n", + "\n", " @traitlets.observe(\"disabled\")\n", " def _observe_disabled(self, change):\n", " with self.hold_trait_notifications():\n", @@ -192,7 +196,6 @@ "\n", "\n", "class ReviewAndSubmitOrderStep(ipw.VBox, WizardAppWidgetStep):\n", - "\n", " # We use traitlets to connect the different steps.\n", " # Note that we can use dlinked transformations, they do not need to be of the same type.\n", " configuration = traitlets.Dict()\n", @@ -212,7 +215,7 @@ " self.observe(self._update_state, [\"configuration\", \"order\"])\n", "\n", " super().__init__([self.configuration_label, self.order_button], **kwargs)\n", - " \n", + "\n", " def reset(self):\n", " self.order = None\n", "\n", @@ -246,7 +249,6 @@ "\n", "\n", "class TrackOrderStep(ipw.VBox, WizardAppWidgetStep):\n", - "\n", " # We receive the order from the previous step and then display information about\n", " # its state in this widget.\n", " order = traitlets.Instance(OrderTracker, allow_none=True)\n", @@ -276,7 +278,6 @@ " else:\n", " self.state = self.State.INIT\n", "\n", - "\n", " def can_reset(self):\n", " \"Do not allow reset during active order processing.\"\n", " return self.state is not self.State.ACTIVE\n", @@ -284,7 +285,7 @@ " def _update_state(self, change=None):\n", " \"Update the step's state based on the order status configuration traits.\"\n", " new_status = change[\"new\"]\n", - " \n", + "\n", " if new_status in (OrderStatus.in_preparation, OrderStatus.in_transit):\n", " self.state = self.State.ACTIVE\n", " elif new_status is OrderStatus.delivered:\n", From 6f1b458ab0ebc4d7ed02a424a74a918262843059 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 9 Oct 2024 22:43:20 +0800 Subject: [PATCH 3/3] Fix lints in notebooks --- notebooks/eln_import.ipynb | 2 +- notebooks/process.ipynb | 2 +- notebooks/wizard_apps.ipynb | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/notebooks/eln_import.ipynb b/notebooks/eln_import.ipynb index a640a50ea..e3863c868 100644 --- a/notebooks/eln_import.ipynb +++ b/notebooks/eln_import.ipynb @@ -60,7 +60,7 @@ "metadata": {}, "outputs": [], "source": [ - "url = urlparse.urlsplit(jupyter_notebook_url)\n", + "url = urlparse.urlsplit(jupyter_notebook_url) # noqa: F821\n", "parsed_url = urlparse.parse_qs(url.query)\n", "params = {key: value[0] for key, value in parsed_url.items()}\n", "eln_widget = ElnImportWidget(**params)" diff --git a/notebooks/process.ipynb b/notebooks/process.ipynb index 539be56e1..1dc8c6a53 100644 --- a/notebooks/process.ipynb +++ b/notebooks/process.ipynb @@ -58,7 +58,7 @@ "metadata": {}, "outputs": [], "source": [ - "url = urlparse.urlsplit(jupyter_notebook_url)\n", + "url = urlparse.urlsplit(jupyter_notebook_url) # noqa: F821\n", "url_dict = urlparse.parse_qs(url.query)\n", "if \"id\" in url_dict:\n", " pk = int(url_dict[\"id\"][0])\n", diff --git a/notebooks/wizard_apps.ipynb b/notebooks/wizard_apps.ipynb index 2afd03f21..c8a5fba9a 100644 --- a/notebooks/wizard_apps.ipynb +++ b/notebooks/wizard_apps.ipynb @@ -150,7 +150,10 @@ "\n", " def _confirm_configuration(self, button):\n", " \"Confirm the pizza configuration and expose as trait.\"\n", - " self.configuration = dict(style=self.style.value, toppings=self.toppings.value)\n", + " self.configuration = {\n", + " \"style\": self.style.value,\n", + " \"toppings\": self.toppings.value,\n", + " }\n", "\n", " def reset(self):\n", " with self.hold_trait_notifications():\n",