From 94210258e82ccf841ad842199c99ba74e836a0e6 Mon Sep 17 00:00:00 2001 From: Ian Zhang Date: Mon, 2 Dec 2024 10:41:22 -0600 Subject: [PATCH 1/5] add button to do access auth --- cybergis_compute_client/CyberGISCompute.py | 1 + cybergis_compute_client/UI.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/cybergis_compute_client/CyberGISCompute.py b/cybergis_compute_client/CyberGISCompute.py index 78716c8..4905b05 100644 --- a/cybergis_compute_client/CyberGISCompute.py +++ b/cybergis_compute_client/CyberGISCompute.py @@ -66,6 +66,7 @@ def __init__(self, url="cgjobsup.cigi.illinois.edu", port=443, protocol='HTTPS', """ self.client = Client(url=url, protocol=protocol, port=port, suffix=suffix) + self.url = f"{protocol.lower()}://{url}" self.jupyterhubApiToken = None self.username = None self.isJupyter = isJupyter diff --git a/cybergis_compute_client/UI.py b/cybergis_compute_client/UI.py index 8fd06d3..aee01d3 100644 --- a/cybergis_compute_client/UI.py +++ b/cybergis_compute_client/UI.py @@ -128,6 +128,12 @@ def render(self): user_folders = widgets.Output() with user_folders: display(self.folders['output']) + + # 6. access authentication + access_auth = widgets.Output() + with access_auth: + display("Authenticate with ACCESS with the following link: ") + display(f"[Click here](https://cilogon.org/authorize?response_type=code&client_id=cilogon:/client_id/167328d1519f05439a31b20acd9bab28&redirect_uri={self.compute.url}/v2/auth/cilogon/callback&scope=openid+profile+email+org.cilogon.userinfo&idphint=https://access-ci.org/idp&state={self.compute.jupyterhubApiToken})") # assemble into tabs self.tab = widgets.Tab(children=[ From d5d2a61f86b30e666328022416431f306b47d915 Mon Sep 17 00:00:00 2001 From: Ian Zhang Date: Mon, 2 Dec 2024 10:43:48 -0600 Subject: [PATCH 2/5] amke the new tab actually show --- cybergis_compute_client/UI.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cybergis_compute_client/UI.py b/cybergis_compute_client/UI.py index aee01d3..db1dcf2 100644 --- a/cybergis_compute_client/UI.py +++ b/cybergis_compute_client/UI.py @@ -133,7 +133,7 @@ def render(self): access_auth = widgets.Output() with access_auth: display("Authenticate with ACCESS with the following link: ") - display(f"[Click here](https://cilogon.org/authorize?response_type=code&client_id=cilogon:/client_id/167328d1519f05439a31b20acd9bab28&redirect_uri={self.compute.url}/v2/auth/cilogon/callback&scope=openid+profile+email+org.cilogon.userinfo&idphint=https://access-ci.org/idp&state={self.compute.jupyterhubApiToken})") + display(Markdown(f"[Click here](https://cilogon.org/authorize?response_type=code&client_id=cilogon:/client_id/167328d1519f05439a31b20acd9bab28&redirect_uri={self.compute.url}/v2/auth/cilogon/callback&scope=openid+profile+email+org.cilogon.userinfo&idphint=https://access-ci.org/idp&state={self.compute.jupyterhubApiToken})")) # assemble into tabs self.tab = widgets.Tab(children=[ @@ -141,13 +141,15 @@ def render(self): job_status, download, job_refresh, - user_folders + user_folders, + access_auth ]) self.tab.set_title(0, 'Job Configuration') self.tab.set_title(1, 'Your Job Status') self.tab.set_title(2, 'Download Job Result') self.tab.set_title(3, 'Your Jobs') self.tab.set_title(4, 'Past Results') + self.tab.set_title(5, "ACCESS login") display(self.tab) def renderComponents(self): From 756fef2ddba2d839f158094216d1cfc506914281 Mon Sep 17 00:00:00 2001 From: Ian Zhang Date: Mon, 2 Dec 2024 10:44:33 -0600 Subject: [PATCH 3/5] make the linter happy --- cybergis_compute_client/UI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cybergis_compute_client/UI.py b/cybergis_compute_client/UI.py index db1dcf2..68df82c 100644 --- a/cybergis_compute_client/UI.py +++ b/cybergis_compute_client/UI.py @@ -128,7 +128,7 @@ def render(self): user_folders = widgets.Output() with user_folders: display(self.folders['output']) - + # 6. access authentication access_auth = widgets.Output() with access_auth: From c25cba3582cb0d5ae6173fb6a247dbb5fceb26b9 Mon Sep 17 00:00:00 2001 From: Ian Zhang Date: Tue, 1 Apr 2025 14:38:26 -0500 Subject: [PATCH 4/5] add a button to request access to hpcs --- cybergis_compute_client/UI.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cybergis_compute_client/UI.py b/cybergis_compute_client/UI.py index 68df82c..8968913 100644 --- a/cybergis_compute_client/UI.py +++ b/cybergis_compute_client/UI.py @@ -233,8 +233,18 @@ def renderComputingResource(self): """ Display computing resources in a dropdown for the user to select """ + + def button_callback(change): + try: + self.compute.client.request('POST', '/auth/request/addUser', {'user': self.compute.username, 'hpc': self.hpcName}) + self.computingResource['return_status'] = 'request made successfully' + except Exception: + self.computingResource['return_status'] = 'request failed, try linking your ACCESS account first' + self.renderComputingResource() + if self.computingResource['output'] is None: self.computingResource['output'] = widgets.Output() + # create components self.computingResource['dropdown'] = widgets.Dropdown( options=[i for i in self.job['supported_hpc']], @@ -249,8 +259,19 @@ def renderComputingResource(self): 0, 'Computing Resource') self.computingResource['dropdown'].observe( self.onComputingResourceDropdownChange(), names=['value']) + + self.computingResource['button'] = widgets.Button( + description="Request approval" + ) + self.computingResource['button'].on_click(button_callback) + with self.computingResource['output']: display(self.computingResource['accordion']) + display('Some computing resources may require approval before being able to use it. To request approval for the currently selected resource, click the following button:') + display(self.computingResource['button']) + + if self.computingResource['return_status']: + display(self.computingResource['return_status']) def renderEmail(self): """ @@ -991,7 +1012,7 @@ def init(self): # components self.jobTemplate = {'output': None} self.description = {'output': None} - self.computingResource = {'output': None} + self.computingResource = {'output': None, 'return_status': None} self.slurm = {'output': None} self.email = {'output': None} self.name = {'output': None} From e3ca7f708e5488fd633ad61b4b824db178a8a3e4 Mon Sep 17 00:00:00 2001 From: Ian Zhang Date: Tue, 1 Apr 2025 14:39:43 -0500 Subject: [PATCH 5/5] fix linting --- cybergis_compute_client/UI.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cybergis_compute_client/UI.py b/cybergis_compute_client/UI.py index 8968913..d0db4d0 100644 --- a/cybergis_compute_client/UI.py +++ b/cybergis_compute_client/UI.py @@ -233,7 +233,7 @@ def renderComputingResource(self): """ Display computing resources in a dropdown for the user to select """ - + def button_callback(change): try: self.compute.client.request('POST', '/auth/request/addUser', {'user': self.compute.username, 'hpc': self.hpcName}) @@ -241,10 +241,10 @@ def button_callback(change): except Exception: self.computingResource['return_status'] = 'request failed, try linking your ACCESS account first' self.renderComputingResource() - + if self.computingResource['output'] is None: self.computingResource['output'] = widgets.Output() - + # create components self.computingResource['dropdown'] = widgets.Dropdown( options=[i for i in self.job['supported_hpc']], @@ -259,17 +259,17 @@ def button_callback(change): 0, 'Computing Resource') self.computingResource['dropdown'].observe( self.onComputingResourceDropdownChange(), names=['value']) - + self.computingResource['button'] = widgets.Button( description="Request approval" ) self.computingResource['button'].on_click(button_callback) - + with self.computingResource['output']: display(self.computingResource['accordion']) display('Some computing resources may require approval before being able to use it. To request approval for the currently selected resource, click the following button:') display(self.computingResource['button']) - + if self.computingResource['return_status']: display(self.computingResource['return_status'])