From c97a25ffc13c3400e411e73ebc0600e70a815f2e Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Mon, 8 Jul 2024 20:06:20 +0100 Subject: [PATCH] Various dependency fixes (#621) --- aiidalab_widgets_base/elns.py | 11 ++++++++--- aiidalab_widgets_base/nodes.py | 3 ++- setup.cfg | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/aiidalab_widgets_base/elns.py b/aiidalab_widgets_base/elns.py index fe9555594..d496b5630 100644 --- a/aiidalab_widgets_base/elns.py +++ b/aiidalab_widgets_base/elns.py @@ -2,7 +2,6 @@ from pathlib import Path import ipywidgets as ipw -import requests_cache import traitlets as tl from aiida import orm from IPython.display import clear_output, display @@ -68,6 +67,8 @@ class ElnImportWidget(ipw.VBox): node = tl.Instance(orm.Node, allow_none=True) def __init__(self, path_to_root="../", **kwargs): + import requests_cache + # Used to output additional settings. self._output = ipw.Output() @@ -83,8 +84,9 @@ def __init__(self, path_to_root="../", **kwargs): return tl.dlink((eln, "node"), (self, "node")) + # Since the requests cache is enabled globally in aiidalab package, we disable it here to get correct results. + # This can be removed once https://github.com/aiidalab/aiidalab/issues/196 is fixed. with requests_cache.disabled(): - # Since the cache is enabled in AiiDAlab, we disable it here to get correct results. eln.import_data() @@ -151,10 +153,13 @@ def _observe_node(self, _=None): self.eln.set_sample_config(**info) def send_to_eln(self, _=None): + import requests_cache + if self.eln and self.eln.is_connected: self.message.value = f"\u29d7 Sending data to {self.eln.eln_instance}..." + # Since the requests cache is enabled globally in aiidalab package, we disable it here to get correct results. + # This can be removed once https://github.com/aiidalab/aiidalab/issues/196 is fixed. with requests_cache.disabled(): - # Since the cache is enabled in AiiDAlab, we disable it here to get correct results. self.eln.export_data() self.message.value = ( f"\u2705 The data were successfully sent to {self.eln.eln_instance}." diff --git a/aiidalab_widgets_base/nodes.py b/aiidalab_widgets_base/nodes.py index 9f4bf766a..f08b9af84 100644 --- a/aiidalab_widgets_base/nodes.py +++ b/aiidalab_widgets_base/nodes.py @@ -7,7 +7,6 @@ import traitlets as tl from aiida import common, engine, orm from aiida.cmdline.utils.ascii_vis import calc_info -from aiidalab.app import _AiidaLabApp from IPython.display import clear_output, display CALCULATION_TYPES = [ @@ -319,6 +318,8 @@ def find_node(self, pk, namespaces=None): class _AppIcon: def __init__(self, app, path_to_root, node): + from aiidalab.app import _AiidaLabApp + name = app["name"] app_object = _AiidaLabApp.from_id(name) self.logo = app_object.metadata["logo"] diff --git a/setup.cfg b/setup.cfg index 33097da82..77b052cdf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -27,7 +27,7 @@ install_requires = bokeh~=2.0 humanfriendly~=10.0 ipytree~=0.2 - traitlets~=5.9.0 + traitlets~=5.9 ipywidgets~=7.7 widgetsnbextension<3.6.3 pymysql~=0.9 @@ -54,6 +54,7 @@ optimade = ipyoptimade~=0.1 eln = aiidalab-eln>=0.1.2,~=0.1 + requests-cache~=1.0 smiles = rdkit>=2021.09.2 scikit-learn~=1.1