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

add support for flexible config (via env var) for the pipline service and UI, fix broken links (pointed to API vs UI service) #1293

Merged
merged 9 commits into from
Jul 16, 2019
15 changes: 10 additions & 5 deletions sdk/python/kfp/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def camel_case_to_snake_case(name):
setattr(api_struct, member_name, bound_member)


KF_PIPELINES_ENDPOINT_ENV = 'KF_PIPELINES_ENDPOINT'
KF_PIPELINES_UI_ENDPOINT_ENV = 'KF_PIPELINES_UI_ENDPOINT'

class Client(object):
""" API Client for KubeFlow Pipeline.
"""
Expand All @@ -81,7 +84,8 @@ def __init__(self, host=None, client_id=None, namespace='kubeflow'):
https://<your-deployment>.endpoints.<your-project>.cloud.goog/pipeline".
client_id: The client ID used by Identity-Aware Proxy.
"""
self._host = host

self._uihost = os.environ.get(KF_PIPELINES_UI_ENDPOINT_ENV, host)
config = self._load_config(host, client_id, namespace)
api_client = kfp_server_api.api_client.ApiClient(config)
_add_generated_apis(self, kfp_server_api.api, api_client)
Expand All @@ -92,6 +96,7 @@ def __init__(self, host=None, client_id=None, namespace='kubeflow'):

def _load_config(self, host, client_id, namespace):
config = kfp_server_api.configuration.Configuration()
host = host or os.environ.get(KF_PIPELINES_ENDPOINT_ENV)
if host:
config.host = host

Expand Down Expand Up @@ -144,12 +149,12 @@ def _is_ipython(self):
return True

def _get_url_prefix(self):
if self._host:
if self._uihost:
# User's own connection.
if self._host.startswith('http://') or self._host.startswith('https://'):
return self._host
if self._uihost.startswith('http://') or self._uihost.startswith('https://'):
return self._uihost
else:
return 'http://' + self._host
return 'http://' + self._uihost

# In-cluster pod. We could use relative URL.
return '/pipeline'
Expand Down