Skip to content

Commit

Permalink
feat(sdk/client): add cookie configuration to kfp client (#2679)
Browse files Browse the repository at this point in the history
* Add cookie configuration to kfp client

* Change cookie->cookies and add docs
  • Loading branch information
prcastro authored Jul 15, 2020
1 parent bdb12c1 commit d91ac0f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sdk/python/kfp/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Client(object):
LOCAL_KFP_CONTEXT = os.path.expanduser('~/.config/kfp/context.json')

# TODO: Wrap the configurations for different authentication methods.
def __init__(self, host=None, client_id=None, namespace='kubeflow', other_client_id=None, other_client_secret=None, existing_token=None):
def __init__(self, host=None, client_id=None, namespace='kubeflow', other_client_id=None, other_client_secret=None, existing_token=None, cookies=None):
"""Create a new instance of kfp client.
Args:
Expand All @@ -116,14 +116,15 @@ def __init__(self, host=None, client_id=None, namespace='kubeflow', other_client
other_client_secret: The client secret used to obtain the auth codes and refresh tokens.
existing_token: pass in token directly, it's used for cases better get token outside of SDK, e.x. GCP Cloud Functions
or caller already has a token
cookies: CookieJar object containing cookies that will be passed to the pipelines API.
"""
host = host or os.environ.get(KF_PIPELINES_ENDPOINT_ENV)
self._uihost = os.environ.get(KF_PIPELINES_UI_ENDPOINT_ENV, host)
config = self._load_config(host, client_id, namespace, other_client_id, other_client_secret, existing_token)
# Save the loaded API client configuration, as a reference if update is
# needed.
self._existing_config = config
api_client = kfp_server_api.api_client.ApiClient(config)
api_client = kfp_server_api.api_client.ApiClient(config, cookie=cookies)
_add_generated_apis(self, kfp_server_api, api_client)
self._job_api = kfp_server_api.api.job_service_api.JobServiceApi(api_client)
self._run_api = kfp_server_api.api.run_service_api.RunServiceApi(api_client)
Expand Down

0 comments on commit d91ac0f

Please sign in to comment.