Skip to content

Commit

Permalink
[API] Fix pipelines creation breakage (mlrun#1679)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedingber authored Jan 26, 2022
1 parent 396979b commit 30af717
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions mlrun/api/crud/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 30af717

Please sign in to comment.