From 30af717c791545eaa2c262b74555c4712f9440d1 Mon Sep 17 00:00:00 2001 From: Hedingber Date: Wed, 26 Jan 2022 04:05:17 +0200 Subject: [PATCH] [API] Fix pipelines creation breakage (#1679) --- mlrun/api/crud/pipelines.py | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/mlrun/api/crud/pipelines.py b/mlrun/api/crud/pipelines.py index 2a8e550cdafd..5372156153ea 100644 --- a/mlrun/api/crud/pipelines.py +++ b/mlrun/api/crud/pipelines.py @@ -23,13 +23,15 @@ def list_pipelines( self, db_session: sqlalchemy.orm.Session, project: str, - namespace: str = mlrun.mlconf.namespace, + namespace: typing.Optional[str] = None, sort_by: str = "", page_token: str = "", filter_: str = "", format_: mlrun.api.schemas.PipelinesFormat = mlrun.api.schemas.PipelinesFormat.metadata_only, page_size: typing.Optional[int] = None, ) -> typing.Tuple[int, typing.Optional[int], typing.List[dict]]: + if namespace is None: + namespace = mlrun.mlconf.namespace if project != "*" and (page_token or page_size or sort_by or filter_): raise mlrun.errors.MLRunInvalidArgumentError( "Filtering by project can not be used together with pagination, sorting, or custom filter" @@ -41,7 +43,12 @@ def list_pipelines( raise mlrun.errors.MLRunInvalidArgumentError( "Summary format is not supported for list pipelines, use get instead" ) - kfp_client = kfp.Client(namespace=namespace) + # When instead of host we provided namespace we tackled this issue + # https://github.com/canonical/bundle-kubeflow/issues/412 + # TODO: When we'll move to kfp 1.4.0 (server side) it should be resolved + kfp_client = kfp.Client( + host=f"http://ml-pipeline.{namespace}.svc.cluster.local:8888" + ) if project != "*": run_dicts = [] while page_token is not None: @@ -79,10 +86,17 @@ def get_pipeline( db_session: sqlalchemy.orm.Session, run_id: str, project: typing.Optional[str] = None, - namespace: str = mlrun.mlconf.namespace, + namespace: typing.Optional[str] = None, format_: mlrun.api.schemas.PipelinesFormat = mlrun.api.schemas.PipelinesFormat.summary, ): - kfp_client = kfp.Client(namespace=namespace) + if namespace is None: + namespace = mlrun.mlconf.namespace + # When instead of host we provided namespace we tackled this issue + # https://github.com/canonical/bundle-kubeflow/issues/412 + # TODO: When we'll move to kfp 1.4.0 (server side) it should be resolved + kfp_client = kfp.Client( + host=f"http://ml-pipeline.{namespace}.svc.cluster.local:8888" + ) run = None try: api_run_detail = kfp_client.get_run(run_id) @@ -112,8 +126,10 @@ def create_pipeline( content_type: str, data: bytes, arguments: dict = None, - namespace: str = mlrun.mlconf.namespace, + namespace: typing.Optional[str] = None, ): + if namespace is None: + namespace = mlrun.mlconf.namespace if arguments is None: arguments = {} if "/yaml" in content_type: @@ -141,7 +157,12 @@ def create_pipeline( ) try: - kfp_client = kfp.Client(namespace=namespace) + # When instead of host we provided namespace we tackled this issue + # https://github.com/canonical/bundle-kubeflow/issues/412 + # TODO: When we'll move to kfp 1.4.0 (server side) it should be resolved + kfp_client = kfp.Client( + host=f"http://ml-pipeline.{namespace}.svc.cluster.local:8888" + ) experiment = kfp_client.create_experiment(name=experiment_name) run = kfp_client.run_pipeline( experiment.id, run_name, pipeline_file.name, params=arguments