diff --git a/services/webapp/code/rosetta/base_app/computing_managers.py b/services/webapp/code/rosetta/base_app/computing_managers.py index 211d846b7161f5519cb0167b73223a2ef9558333..c7409152a6eb9d35422f57ac828063a2e17c0155 100644 --- a/services/webapp/code/rosetta/base_app/computing_managers.py +++ b/services/webapp/code/rosetta/base_app/computing_managers.py @@ -412,7 +412,25 @@ class SlurmComputingManager(ComputingManager): def _get_task_log(self, task, **kwargs): - raise NotImplementedError('Not implemented') + + # Get user keys + if task.computing.require_user_auth_keys: + user_keys = Keys.objects.get(user=task.user, default=True) + else: + raise NotImplementedError('Remote tasks not requiring keys are not yet supported') + + # Get computing host + host = task.computing.get_conf_param('master') + user = task.computing.get_conf_param('user') + + # Stop the task remotely + view_log_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {}@{} \'/bin/bash -c "cat \$HOME/{}.log"\''.format(user_keys.private_key_file, user, host, task.uuid) + + out = os_shell(view_log_command, capture=True) + if out.exit_code != 0: + raise Exception(out.stderr) + else: + return out.stdout diff --git a/services/webapp/code/rosetta/base_app/templates/components/task.html b/services/webapp/code/rosetta/base_app/templates/components/task.html index bbebbdcf863dbe89af9ef5b3700ac4bf334b3575..791f5cd078cdd764b3970406042550a99dbb6bdc 100644 --- a/services/webapp/code/rosetta/base_app/templates/components/task.html +++ b/services/webapp/code/rosetta/base_app/templates/components/task.html @@ -74,11 +74,12 @@ <a href="?uuid={{task.uuid}}&action=delete&details=False">Delete</a> {% if task.status == "running" %} | <a href="?uuid={{task.uuid}}&action=connect">Connect</a> - | <a href="/task_log/?uuid={{task.uuid}}&action=viewlog">View Log</a> {% else %} | <font color="#c0c0c0">Connect</font> - | <font color="#c0c0c0">View Log</font> {% endif%} + + | <a href="/task_log/?uuid={{task.uuid}}&action=viewlog">View Log</a> + </td> </tr>