Skip to content

Commit

Permalink
Change "namespace" param to "host" in kfp client so we can use Jupyte…
Browse files Browse the repository at this point in the history
…r outside cluster. (#529)

* Change "namespace" param to "host" in kfp client so we can use Jupyter outside cluster.

* Fix tests.
  • Loading branch information
qimingj authored and k8s-ci-robot committed Dec 13, 2018
1 parent 0f55da1 commit 6b315d4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
12 changes: 8 additions & 4 deletions sdk/python/kfp/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,21 @@

from .compiler import compiler


class Client(object):
""" API Client for KubeFlow Pipeline.
"""

def __init__(self, namespace='kubeflow'):
def __init__(self, host='ml-pipeline.kubeflow.svc.cluster.local:8888'):
"""Create a new instance of kfp client.
Args:
namespace: the namespace where pipelines are deployed. Default is kubeflow
TODO: check if it works outside of the cluster.
host: the host name to use to talk to Kubeflow Pipelines. Default value
"ml-pipeline.kubeflow.svc.cluster.local:8888" is the in-cluster DNS name
of the pipeline service. It only works if the current environment is a pod
in the same cluster (such as a Jupyter instance spawned by Kubeflow's
JupyterHub). If you have a different connection to cluster, such as a kubectl
proxy connection, then set it to something like "127.0.0.1:8080/pipeline".
"""

try:
Expand All @@ -45,7 +50,6 @@ def __init__(self, namespace='kubeflow'):
except ImportError:
raise Exception('This module requires installation of kfp_run')

host='ml-pipeline.' + namespace + '.svc.cluster.local:8888'
config = kfp_run.configuration.Configuration()
config.host = host
api_client = kfp_run.api_client.ApiClient(config)
Expand Down
3 changes: 2 additions & 1 deletion test/sample-test/run_basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def main():
test_name = args.testname + ' Sample Test'

###### Initialization ######
client = Client(namespace=args.namespace)
host = 'ml-pipeline.%s.svc.cluster.local:8888' % args.namespace
client = Client(host=host)

###### Check Input File ######
utils.add_junit_test(test_cases, 'input generated yaml file', os.path.exists(args.input), 'yaml file is not generated')
Expand Down
3 changes: 2 additions & 1 deletion test/sample-test/run_kubeflow_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def main():
test_name = 'Kubeflow Sample Test'

###### Initialization ######
client = Client(namespace=args.namespace)
host = 'ml-pipeline.%s.svc.cluster.local:8888' % args.namespace
client = Client(host=host)

###### Check Input File ######
utils.add_junit_test(test_cases, 'input generated yaml file', os.path.exists(args.input), 'yaml file is not generated')
Expand Down
3 changes: 2 additions & 1 deletion test/sample-test/run_tfx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def main():
test_name = 'TFX Sample Test'

###### Initialization ######
client = Client(namespace=args.namespace)
host = 'ml-pipeline.%s.svc.cluster.local:8888' % args.namespace
client = Client(host=host)

###### Check Input File ######
utils.add_junit_test(test_cases, 'input generated yaml file', os.path.exists(args.input), 'yaml file is not generated')
Expand Down
5 changes: 3 additions & 2 deletions test/sample-test/run_xgboost_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def main():
test_name = 'XGBoost Sample Test'

###### Initialization ######
client = Client(namespace=args.namespace)
host = 'ml-pipeline.%s.svc.cluster.local:8888' % args.namespace
client = Client(host=host)

###### Check Input File ######
utils.add_junit_test(test_cases, 'input generated yaml file', os.path.exists(args.input), 'yaml file is not generated')
Expand Down Expand Up @@ -123,4 +124,4 @@ def main():
utils.write_junit_xml(test_name, args.result, test_cases)

if __name__ == "__main__":
main()
main()

0 comments on commit 6b315d4

Please sign in to comment.