Skip to content
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

databricks: fix register to display SSO login link prior to timer expiration, fixes: #539 #527

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

DataBoyTX
Copy link
Contributor

…HTML to allow viewing for databricks users

@lmeyerov
Copy link
Contributor

@DataBoyTX see ci fails

Copy link
Contributor

@lmeyerov lmeyerov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

@lmeyerov
Copy link
Contributor

@vaimdev I think this is really 2 different issues:

  1. Ensure in databricks + jupyter that the link immediately appears (vs after 30s) . That includes when used in a databricks dashboard view.

  2. Respect overrides. User should be able to force a display mode, and sniffers should not override that decision if provided. Currently, databricks/python sniffers override any explicit decision.

@DataBoyTX DataBoyTX changed the title change register command to use markdown instead of HTML for databricks users to see login link databricks: fix register to display SSO login link prior to timer expiration, fixes: #539 Jan 16, 2024
@DataBoyTX DataBoyTX marked this pull request as draft January 17, 2024 00:57
@lmeyerov
Copy link
Contributor

is this closing in favor of #543 ?

@DataBoyTX
Copy link
Contributor Author

is this closing in favor of #543 ?

yes

@DataBoyTX DataBoyTX marked this pull request as ready for review March 12, 2024 06:05
@DataBoyTX DataBoyTX requested a review from lmeyerov March 12, 2024 06:05
CHANGELOG.md Outdated
@@ -78,6 +84,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Breaking 🔥

* GFQL `e()` now aliases `e_undirected` instead of the base class `ASTEdge`
>>>>>>> 2506b798ec723e906c1c5279f613fe0c37bdbad2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DataBoyTX bad merge?

PyGraphistry._is_authenticated = True
arrow_uploader.token = None
return PyGraphistry.api_token()
except Exception: # required to log on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we be selective on the Exception for the one we expect to be thrown?

return auth_url

@staticmethod
def databricks_notebook_sso_login(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this for databricks notebooks or databricks dashboards?

Where in dashboards, I think the idea is first cell is a non-blocking print, and second cell is a blocking poll on successful sso

Where in notebooks... ?

@@ -670,6 +727,12 @@ def register(
import graphistry
graphistry.register(api=3, protocol='http', server='nginx', client_protocol_hostname='https://my.site.com', token='abc')

**Example: Databricks notebook and dashboard users need to call the following before register to correctly display the HTML link:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in the dashboard case, it needs to be in 2 different cells, one is a non-blocking url print, and the other the blocking register for whichever cell will plot

I'm not sure what's needed, if anything, for notebooks?

display(HTML(f'<a href="{auth_url}" target="_blank">Login SSO</a>'))
print("Please click the above URL to open browser to login")
print(f"If you cannot see the URL, please open browser, browse to this URL: {auth_url}")
print("Please close browser tab after SSO login to back to notebook")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mixing display() and print() suggests an incomplete case analysis & handling, can we handle more carefully?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can make print() vs display() options, and sniffers pick the right one

except Exception: # required to log on
PyGraphistry.sso_state(arrow_uploader.sso_state)
auth_url = arrow_uploader.sso_auth_url
if auth_url and not PyGraphistry.api_token():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the notebook case (but not needed in dashboard), we risk having an expired token (e.g., been up for an hour)

normally there's an auto-refresh that kicks in for some of the dispatched methods, so this gets auto-handled at plot

BUT when an explicit public call like this one, it makes sense to show the url either way, or to make this an option?

print("After, if you get timeout error, run graphistry.sso_get_token() to complete the authentication")
if not in_databricks():
# elif in_ipython() or sso_opt_into_type == 'display': # If run in notebook, just display the HTML
if in_ipython() or sso_opt_into_type == 'display': # If run in notebook, just display the HTML
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make sure overrides get followed before sniffers, so sniffers don't supercede them

@DataBoyTX DataBoyTX marked this pull request as draft April 3, 2024 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants