-
Notifications
You must be signed in to change notification settings - Fork 206
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
Dev/sso login ux #608
base: master
Are you sure you want to change the base?
Dev/sso login ux #608
Conversation
Can you share the code sample in the PR? (Trouble accessing link, and discussion should be here) |
@vaimdev @DataBoyTX This looks strange from a dev UX layer, afaict: DemoIf I understand correctly, the below is the intended setup: cell 1: clear_output()
graphistry.databricks_sso_login_init() cell 2: clear_output()
graphistry.databricks_sso_login(server="test-2-40-74-dbt.grph.xyz", org_name="louiedev") cell 3: clear_output()
graphistry.databricks_sso_wait_for_token() cell 4: g.plot() DiscussionI understand wanting new underlying primitives, but how to expose it to users should be minimal, clean, integrated, smart defaults, etc
Examples of a two-cell: |
This PR should also include sample ipynb + docs updates. Sounds like we need to iterate first on interface definitions tho. The current is https://pygraphistry.readthedocs.io/en/latest/demos/demos_databases_apis/databricks_pyspark/graphistry-notebook-dashboard.html Maybe dashboards or auth should split out? |
graphistry/pygraphistry.py
Outdated
class DatabricksHelper(): | ||
|
||
@staticmethod | ||
def sso_repeat_get_token(repeat, wait): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public methods should have .rst-friendly docstrs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, we're trying to make all new code mypy-typed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, noted. I will add them in.
4 cells instead of 2, mainly because each cell will only display the output at the end of running of 1 cell. Previously, there are a few logic written into 1 cell and the output only be displayed after the cell is run which make the messages looks strange,
clear_output() is not necessary, can be removed.
Mainly for databricks dashboard but tested in both databricks notebook and databricks dashboard. |
graphistry/pygraphistry.py
Outdated
try: | ||
PyGraphistry.refresh() | ||
except Exception: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this error case handling may need thinking?
graphistry/pygraphistry.py
Outdated
def databricks_sso_login_init(wait=20): | ||
from IPython.display import display, HTML, clear_output | ||
|
||
def init_login(wait): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
un-nest
suggestion from Leo: Show a message on Graphistry server, when SSO login from pygraphistry |
…ich originally just a refresh()
… will be displayed.
@vaimdev FYI ci lint issues |
Yes, noted, added some debugging code, now it is done and cleaning up code. |
Loom videos to demo the changes Databricks Notebook Log in - https://www.loom.com/share/2313bb86ef454a9f9d55c1535c785457?sid=42f46537-f726-4a89-a98d-96f762e0cf51 Dashboard |
graphistry/pygraphistry.py
Outdated
@staticmethod | ||
def sso_repeat_get_token(repeat: int = 20, wait: int = 5): | ||
""" Function to repeatly call to obtain the jwt token after sso login | ||
Function to obtain the JWT token after SSO login |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sabizmil can you check all public method docstr as these show up in the readthedocs?
Spelling, grammar, docstr types, and examples, following format of the rest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in the latest commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left comments with updated message content.
@@ -271,7 +277,7 @@ def _handle_auth_url(auth_url, sso_timeout, sso_opt_into_type): | |||
if in_ipython() or in_databricks() or sso_opt_into_type == 'display': # If run in notebook, just display the HTML | |||
# from IPython.core.display import HTML | |||
from IPython.display import display, HTML | |||
display(HTML(f'<a href="{auth_url}" target="_blank">Login SSO</a>')) | |||
display(HTML(f'<a href="{auth_url}" target="_blank">Login SSO</a><br /><span>Please click the above URL to open browser to login</span>')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<a href="{auth_url}" target="_blank" style="display: inline-block; margin-top: 10px; padding: 10px 20px; font-size: 16px; font-weight: bold; color: #fff; background-color: #007bff; text-decoration: none; border-radius: 5px;">Login with SSO</a>
<p style="margin-top: 5px; color: #555;">Please click the button above to open the browser and log in.</p>
graphistry/pygraphistry.py
Outdated
if not PyGraphistry.api_token(): | ||
msg_text = '....' | ||
if not PyGraphistry.sso_repeat_get_token(repeat, wait): | ||
msg_text = f'{msg_text}\nFailed to get token after {repeat*wait} seconds ....' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msg_text = f'{msg_text}\nUnable to retrieve token after {repeat*wait} seconds. Please try logging in again.'
graphistry/pygraphistry.py
Outdated
if not PyGraphistry.sso_repeat_get_token(repeat, wait): | ||
msg_text = f'{msg_text}\nFailed to get token after {repeat*wait} seconds ....' | ||
if not fail_silent: | ||
msg = f"Failed to get token after {repeat*wait} seconds. Please re-run the login process" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msg = f"Token retrieval failed after {repeat*wait} seconds. Please try logging in again."
display_message_html(f"<strong>{msg}</strong>") | ||
raise Exception(msg) | ||
else: | ||
msg_text = f'{msg_text}\nGot token' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msg_text = f'{msg_text}\nToken retrieved successfully.'
print(msg_text) | ||
return | ||
|
||
msg_text = f'{msg_text}\nGot token' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msg_text = f'{msg_text}\nToken retrieved successfully.'
graphistry/pygraphistry.py
Outdated
if not PyGraphistry.sso_repeat_get_token(repeat, wait): | ||
msg_html = f'{msg_html}<br /><strong>Failed to get token after {repeat*wait} seconds .... </strong>' | ||
if not fail_silent: | ||
raise Exception(f"Failed to get token after {repeat*wait} seconds. Please re-run the login process") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise Exception(f"Unable to retrieve token after {repeat*wait} seconds. Please try logging in again.")
msg_html = f'{msg_html}<br /><strong>Got token</strong>' | ||
display(HTML(msg_html)) | ||
else: | ||
display(HTML('<br /><strong>Token is valid, no waiting required.</strong>')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
display(HTML('<br /><strong>Token is valid; no further action needed.</strong>'))
if not is_valid: | ||
print("***********token not valid, refresh token*****************") | ||
if display_mode == 'html': | ||
display(HTML('<br /><strong>Refresh token ....</strong>')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
display(HTML('<br /><strong>Refreshing token...</strong>'))
else: | ||
print("Token is still valid") | ||
if display_mode == 'html': | ||
display(HTML('<br /><strong>Token is still valid ....</strong>')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
display(HTML('<br /><strong>Token is still valid; no re-login required.</strong>'))
graphistry/pygraphistry.py
Outdated
|
||
if required_login: | ||
print("***********Prepare to sign in*****************") | ||
msg_html = f'<br /><strong>Prepare to sign in ....</strong><br><strong>Please Login with the link appear later. Waiting for success login for {repeat*wait} seconds, please login within {wait} seconds....</strong><br /><strong>Please close the browser tab and come back to dashboard....</strong>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msg_html = f'<br /><strong>Preparing to sign in...</strong><br><strong>Use the link provided below to log in. Please complete the login within {wait} seconds.</strong><br /><strong>After logging in, you may close the browser tab and return to the dashboard.</strong>'
@vaimdev @sabizmil @DataBoyTX i'm updating |
@lmeyerov , my side I am still updating the code with documentation with lower priority because focus on the entitlement Saas. I'll suggest you landed your cleaned up version first |
An attempt to improve UI/UX to the databricks dashboard with SSO usage
Added a few helper functions, so that the databricks dashboard can keep a simpler flow and UX.
Example databricks notebooks that utilize the new helper functions
https://dbc-ac10efa1-77c5.cloud.databricks.com/editor/notebooks/3715908489050384?o=7408253037638600#command/1247495116400904
3 pre-steps for the SSO login using the helper functions (with different cells), followed by the actual plotting python code