Utilities

Server Check

is_server_up(address: str, timeout: int = 10, verify: Union[bool, str] = False) bool

Checks if a Driverless AI server is running.

Parameters:
  • address (str) – full URL of the Driverless AI server to connect to
  • timeout (int) – timeout if the server has not issued a response in this many seconds
  • verify (Union[bool, str]) – when using https on the Driverless AI server, setting this to False will disable SSL certificates verification. A path to cert(s) can also be passed to verify, see: https://requests.readthedocs.io/en/master/user/advanced/#ssl-cert-verification

Examples:

driverlessai.is_server_up(
    address='http://localhost:12345',
)
Return type:bool

Token Providers

OAuth 2.0 Token Provider

class OAuth2TokenProvider

Provides a token and makes sure it’s fresh when required.

Parameters:
  • refresh_token (str) – token from Driverless AI server web UI, used to obtain fresh access token when needed
  • client_id (str) – public ID for the Python client
  • token_endpoint_url (str) – Authorization server URL to get an access or refresh token
  • token_introspection_url (str) – Authorization server URL to get information about a token
  • access_token (Optional[str]) – token authorizing Python client access
  • client_secret (Optional[str]) – private secret for the Python client
Keyword Arguments:
 

refresh_expiry_threshold_band (datetime.timedelta) – within how many seconds before token expires that token should be refreshed

Example:

# setup a token provider with a refresh token from the Driverless AI web UI
token_provider = driverlessai.token_providers.OAuth2TokenProvider(
    refresh_token="eyJhbGciOiJIUzI1N...",
    client_id="python_client",
    token_endpoint_url="https://keycloak-server/auth/realms/driverlessai/protocol/openid-connect/token",
    token_introspection_url="https://keycloak-server/auth/realms/driverlessai/protocol/openid-connect/token/introspect"
)

# use the token provider to get authorization to connect to the
# Driverless AI server
dai = driverlessai.Client(
    address="https://localhost:12345",
    token_provider=token_provider.ensure_fresh_token
)
do_refresh() None
Return type:None
ensure_fresh_token() str
Return type:str
refresh_possible() bool
Return type:bool
refresh_required() bool
Return type:bool