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

Tolerate components w/o description, sanitize parameter names #288

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def _upload_component_yaml(yaml_file_content: AnyStr, name=None, existing_id=Non
component_id = existing_id or generate_id(name=name or yaml_dict["name"])
created_at = datetime.now()
name = name or yaml_dict["name"]
description = (yaml_dict["description"] or "").strip()[:255]
description = (yaml_dict.get("description") or name).strip()[:255]
filter_categories = yaml_dict.get("filter_categories") or dict()

metadata = ApiMetadata(annotations=template_metadata.get("annotations"),
Expand Down
14 changes: 9 additions & 5 deletions api/server/swagger_server/gateways/kubeflow_pipeline_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from datetime import datetime

from kfp import Client as KfpClient
from kfp.components._naming import _sanitize_python_function_name as sanitize

from kfp_server_api import ApiRun
from kfp_server_api import ApiPipeline as KfpPipeline
Expand Down Expand Up @@ -100,13 +101,16 @@ def quote_string_value(value):

def generate_method_arg_from_parameter(parameter):

param_name = sanitize(parameter.name)

if parameter.value or parameter.default:
value = quote_string_value(parameter.value or parameter.default)
arg = f"{parameter.name}={value}"
arg = f"{param_name}={value}"
elif parameter.value == '' or parameter.default == '': # TODO: should empty string != None ?
arg = f"{parameter.name}=''"
arg = f"{param_name}=''"
else:
arg = parameter.name
arg = param_name

return arg


Expand All @@ -128,9 +132,9 @@ def generate_component_run_script(component: ApiComponent, component_template_ur

pipeline_method_args = generate_pipeline_method_args(component.parameters)

parameter_names = ",".join([p.name for p in component.parameters])
parameter_names = ",".join([sanitize(p.name) for p in component.parameters])

parameter_dict = json.dumps({p.name: run_parameters.get(p.name) or p.default or ""
parameter_dict = json.dumps({sanitize(p.name): run_parameters.get(p.name) or p.default or ""
for p in component.parameters},
indent=4).replace('"', "'")

Expand Down