Skip to content

Commit

Permalink
Release/1.0.0 (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha authored Sep 27, 2021
2 parents 3c509a5 + aac3b9a commit f25b855
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 22 deletions.
2 changes: 1 addition & 1 deletion aiidalab_widgets_base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@
"viewer",
]

__version__ = "1.0.0rc4"
__version__ = "1.0.0"
12 changes: 7 additions & 5 deletions aiidalab_widgets_base/codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

Expand All @@ -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"))

Expand Down Expand Up @@ -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
Expand Down
30 changes: 20 additions & 10 deletions aiidalab_widgets_base/computers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -41,7 +41,7 @@ class SshComputerSetup(ipw.VBox):

def __init__(self, **kwargs):
computer_image = ipw.HTML(
'<img width="200px" src="./miscellaneous/images/computer.png">'
'<img width="200px" src="../miscellaneous/images/computer.png">'
)

# Username.
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions notebooks/process.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -113,7 +113,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.8.10"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions notebooks/process_list.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -125,7 +125,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.8.10"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions notebooks/setup_code.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"metadata": {},
"outputs": [],
"source": [
"aiidacode = AiiDACodeSetup(**args)\n",
"aiidacode = AiiDACodeSetup(path_to_root=\"../../\", **args)\n",
"display(aiidacode)"
]
}
Expand All @@ -86,7 +86,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.8.10"
}
},
"nbformat": 4,
Expand Down

0 comments on commit f25b855

Please sign in to comment.