Skip to content

Commit

Permalink
Simplified the change
Browse files Browse the repository at this point in the history
  • Loading branch information
Ark-kun committed Oct 17, 2019
1 parent 59fa34c commit 7742835
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions sdk/python/kfp/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ def camel_case_to_snake_case(name):
import re
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', name).lower()

for api_name in dir(api_module.api):
if not api_name.endswith('ServiceApi'): # E.g. kfp_server_api.api.RunServiceApi
for api_name in dir(api_module):
if not api_name.endswith('ServiceApi'):
continue

api_name = api_name[0:-len('ServiceApi')] # E.g. Job, Run or PipelineUpload
short_api_name = camel_case_to_snake_case(api_name) + 's'
short_api_name = camel_case_to_snake_case(api_name[0:-len('ServiceApi')]) + 's'
api_struct = Struct()
setattr(target_struct, short_api_name, api_struct)
service_api = getattr(api_module.api, api_name)
Expand All @@ -61,8 +60,11 @@ def camel_case_to_snake_case(name):

bound_member = getattr(initialized_service_api, member_name)
setattr(api_struct, member_name, bound_member)

api_struct.models = getattr(api_module.models, 'api_' + api_name.lower()) # E.g. kfp_server_api.models.api_job which contains ApiJob, ApiPipelineSpec etc
models_struct = Struct()
for member_name in dir(api_module.models):
if not member_name[0].islower():
setattr(models_struct, member_name, getattr(api_module.models, member_name))
target_struct.api_models = models_struct


KF_PIPELINES_ENDPOINT_ENV = 'KF_PIPELINES_ENDPOINT'
Expand Down Expand Up @@ -454,4 +456,4 @@ def upload_pipeline(self, pipeline_package_path, pipeline_name=None):
import IPython
html = 'Pipeline link <a href=%s/#/pipelines/details/%s>here</a>' % (self._get_url_prefix(), response.id)
IPython.display.display(IPython.display.HTML(html))
return response
return response

0 comments on commit 7742835

Please sign in to comment.