Skip to content

Commit

Permalink
fix (doc): Add documentations
Browse files Browse the repository at this point in the history
  • Loading branch information
vaimdev committed Nov 25, 2024
1 parent 4b0b129 commit c048ee2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
" protocol='https',\n",
" server='hub.graphistry.com')\n",
"\n",
"# Alternatively, use SSO: \n",
"# graphistry.register_databricks_sso(api=3, server='hub.graphistry.com', org_name='my-org')\n",
"# For more options, see https://github.com/graphistry/pygraphistry#configure\n",
"\n",
"# Alternatively, use username and password: \n",
"# graphistry.register(api=3, username='...', password='...', protocol='https', server='hub.graphistry.com')\n",
"# For more options, see https://github.com/graphistry/pygraphistry#configure"
Expand Down
14 changes: 14 additions & 0 deletions docs/source/server/register.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ Register with Custom Browser Routing
client_protocol_hostname="https://my_ui_server.com"
)
Register with SSO using helper function(only for databricks, organization with Specific IdP)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python
import graphistry
graphistry.databricks_register_sso(
api=3,
org_name="my_org_name",
idp_name="my_idp_name",
sso_opt_into_type="browser"
)
---

Best Practices
Expand Down
30 changes: 16 additions & 14 deletions graphistry/pygraphistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ def set_bolt_driver(driver=None):

@staticmethod
def set_sso_opt_into_type(value: Optional[str]):
"""Set sso_opt_into_type to memory"""
PyGraphistry._config["sso_opt_into_type"] = value


Expand Down Expand Up @@ -2655,6 +2656,19 @@ def sso_verify_token_display(
wait: int = 5,
display_mode: str = 'text'
) -> bool:
"""Verify the JWT token display the corresponding message either in text or HTML.
:param repeat: Number of times to attempt obtaining the token, defaults to 20
:type repeat: int, optional
:param wait: Number of seconds to wait between attempts, defaults to 5
:type wait: int, optional
:param display_mode: Whether to display message in text or HTML, default is 'text'
:type display_mode: str, optional
:return: Whether token is still valid
:rtype: bool
"""
if display_mode == 'html':
from IPython.display import display, HTML, clear_output
clear_output()
Expand All @@ -2663,7 +2677,6 @@ def sso_verify_token_display(
token = PyGraphistry.api_token()
if token:
is_valid = PyGraphistry.verify_token()
print(f"is_valid : {is_valid}")
if not is_valid:
print("***********token not valid, refresh token*****************")
if display_mode == 'html':
Expand Down Expand Up @@ -2692,28 +2705,17 @@ def sso_verify_token_display(

# Databricks Dashboard SSO helper functions
class DatabricksHelper():
"""Helper class for databricks.
**Helper class to improve the sso login flow**
"""
"""Helper class to improve the sso login flow"""
@staticmethod
def register_databricks_sso(
server: Optional[str] = None,
org_name: Optional[str] = None,
idp_name: Optional[str] = None,
**kwargs
):
"""Wrapper function special for databrick run register function"""
if not PyGraphistry.api_token():
PyGraphistry.register(api=3, protocol="https", server=server, is_sso_login=True, org_name=org_name, idp_name=idp_name, sso_timeout=None, sso_opt_into_type="display")


# @staticmethod
# def databricks_sso_login(server="hub.graphistry.com", org_name=None, idp_name=None, retry=5, wait=20):
# from IPython.display import clear_output
# clear_output()
# if not PyGraphistry.api_token():
# PyGraphistry.register(api=3, protocol="https", server=server, is_sso_login=True, org_name=org_name, idp_name=idp_name, sso_timeout=None, sso_opt_into_type="display")


client_protocol_hostname = PyGraphistry.client_protocol_hostname
Expand Down

0 comments on commit c048ee2

Please sign in to comment.