From 1f55895577a0434886f2e4f53175b98c698cd53f Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Thu, 23 Sep 2021 10:53:47 +0200 Subject: [PATCH 1/3] Fix wrong links, update warning messages. (#243) --- aiidalab_widgets_base/codes.py | 12 +++++++----- notebooks/process.ipynb | 4 ++-- notebooks/process_list.ipynb | 4 ++-- notebooks/setup_code.ipynb | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/aiidalab_widgets_base/codes.py b/aiidalab_widgets_base/codes.py index feb487017..7e0905924 100644 --- a/aiidalab_widgets_base/codes.py +++ b/aiidalab_widgets_base/codes.py @@ -165,7 +165,7 @@ class AiiDACodeSetup(ipw.VBox): prepend_text = Unicode() append_text = Unicode() - def __init__(self, **kwargs): + def __init__(self, path_to_root="../", **kwargs): style = {"description_width": "200px"} @@ -178,7 +178,9 @@ def __init__(self, **kwargs): link((inp_label, "value"), (self, "label")) # Computer on which the code is installed. Two dlinks are needed to make sure we get a Computer instance. - inp_computer = ComputerDropdown(layout={"margin": "0px 0px 0px 125px"}) + inp_computer = ComputerDropdown( + path_to_root=path_to_root, layout={"margin": "0px 0px 0px 125px"} + ) dlink((inp_computer, "selected_computer"), (self, "computer")) dlink((self, "computer"), (inp_computer, "selected_computer")) @@ -250,13 +252,13 @@ def _setup_code(self, _=None): with self._setup_code_out: clear_output() if self.label is None: - print("You did not specify code label") + print("You did not specify code label.") return if not self.remote_abs_path: - print("You did not specify absolute path to the executable") + print("You did not specify absolute path to the executable.") return if self.exists(): - print(f"Code {self.label}@{self.computer.label} already exists") + print(f"Code {self.label}@{self.computer.label} already exists.") return code = Code(remote_computer_exec=(self.computer, self.remote_abs_path)) code.label = self.label diff --git a/notebooks/process.ipynb b/notebooks/process.ipynb index 913501a77..5876b5945 100644 --- a/notebooks/process.ipynb +++ b/notebooks/process.ipynb @@ -90,7 +90,7 @@ "source": [ "follower = ProcessFollowerWidget(\n", " process,\n", - " followers=[ProgressBarWidget(), ProcessReportWidget(), ProcessCallStackWidget(), RunningCalcJobOutputWidget()], path_to_root='../', \n", + " followers=[ProgressBarWidget(), ProcessReportWidget(), ProcessCallStackWidget(), RunningCalcJobOutputWidget()], path_to_root=\"../../\", \n", " update_interval=2)\n", "display(follower)\n", "follower.follow(detach=True)" @@ -113,7 +113,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.7" + "version": "3.8.10" } }, "nbformat": 4, diff --git a/notebooks/process_list.ipynb b/notebooks/process_list.ipynb index dddb15029..594c13af2 100644 --- a/notebooks/process_list.ipynb +++ b/notebooks/process_list.ipynb @@ -38,7 +38,7 @@ "metadata": {}, "outputs": [], "source": [ - "process_list = ProcessListWidget()\n", + "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", @@ -125,7 +125,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.7" + "version": "3.8.10" } }, "nbformat": 4, diff --git a/notebooks/setup_code.ipynb b/notebooks/setup_code.ipynb index 46dccf47c..ab437f030 100644 --- a/notebooks/setup_code.ipynb +++ b/notebooks/setup_code.ipynb @@ -65,7 +65,7 @@ "metadata": {}, "outputs": [], "source": [ - "aiidacode = AiiDACodeSetup(**args)\n", + "aiidacode = AiiDACodeSetup(path_to_root=\"../../\", **args)\n", "display(aiidacode)" ] } @@ -86,7 +86,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.7" + "version": "3.8.10" } }, "nbformat": 4, From cc513d462cddbdc8ba2e057be470faa2985c650c Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Thu, 23 Sep 2021 10:56:27 +0200 Subject: [PATCH 2/3] Fix computers management logic and links. (#244) --- aiidalab_widgets_base/computers.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/aiidalab_widgets_base/computers.py b/aiidalab_widgets_base/computers.py index ae6f32a62..ab656c4e4 100644 --- a/aiidalab_widgets_base/computers.py +++ b/aiidalab_widgets_base/computers.py @@ -3,7 +3,7 @@ import os from copy import copy from os import path -from subprocess import call, check_output +from subprocess import CalledProcessError, call, check_output import ipywidgets as ipw import pexpect @@ -41,7 +41,7 @@ class SshComputerSetup(ipw.VBox): def __init__(self, **kwargs): computer_image = ipw.HTML( - '' + '' ) # Username. @@ -204,11 +204,16 @@ def _make_host_known(self, hostname, proxycmd=None): proxycmd = [] if proxycmd is None else proxycmd fname = path.expanduser("~/.ssh/known_hosts") print(f"Adding keys from {hostname} to {fname}") - hashes = check_output( - proxycmd + ["ssh-keyscan", "-p", str(self.port), "-H", hostname] - ) + try: + hashes = check_output( + proxycmd + ["ssh-keyscan", "-p", str(self.port), "-H", hostname] + ) + except CalledProcessError: + print(f"Couldn't add keys from {hostname} to {fname}. Aborting.") + return False with open(fname, "a") as fobj: fobj.write(hashes.decode("utf-8")) + return True def can_login(self, silent=False): """Check if it is possible to login into the remote host.""" @@ -369,13 +374,17 @@ def _configure_proxy(self, password, proxy_password): # Make proxy server known. if not self.is_host_known(self.proxy_hostname): - self._make_host_known(self.proxy_hostname) + success = self._make_host_known(self.proxy_hostname) + if not success: + return False, "" # Finally trying to connect. if self._send_pubkey(self.proxy_hostname, proxy_username, proxy_password): return True, proxy_username + "@" + self.proxy_hostname - print(f"Could not send public key to {self.proxy_hostname} (proxy server).") + print( + f"Could not send public key to {self.proxy_hostname} (proxy server), sorry :-(" + ) return False, "" # If proxy is NOT required. @@ -447,14 +456,16 @@ def _on_setup_ssh( # make host known by ssh on the proxy server if not self.is_host_known(): - self._make_host_known( + success = self._make_host_known( self.hostname, ["ssh"] + [proxycmd] if proxycmd else [] ) + if not success: + return if mode == "password": # sending public key to the main host if not self._send_pubkey(self.hostname, self.username, password, proxycmd): - print("Could not send public key to {self.hostname}") + print("Could not send public key to {self.hostname}, sorry :-(") return # modify the ssh config file if necessary @@ -834,7 +845,6 @@ def __init__(self, description="Select computer:", path_to_root="../", **kwargs) """ self.output = ipw.HTML() - self._dropdown = ipw.Dropdown( options={}, value=None, From aac3b9a58e44a2c554ce4655431e4703451cc76d Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Mon, 27 Sep 2021 22:05:47 +0200 Subject: [PATCH 3/3] Prepare release 1.0.0. --- aiidalab_widgets_base/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiidalab_widgets_base/__init__.py b/aiidalab_widgets_base/__init__.py index 1159f7ab4..7ad646822 100644 --- a/aiidalab_widgets_base/__init__.py +++ b/aiidalab_widgets_base/__init__.py @@ -79,4 +79,4 @@ "viewer", ] -__version__ = "1.0.0rc4" +__version__ = "1.0.0"