Skip to content

Add button to do access auth #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cybergis_compute_client/CyberGISCompute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 31 additions & 2 deletions cybergis_compute_client/UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,27 @@ def render(self):
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(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=[
job_config,
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):
Expand Down Expand Up @@ -225,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']],
Expand All @@ -241,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):
"""
Expand Down Expand Up @@ -983,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}
Expand Down