Skip to content

Commit

Permalink
fix legacy client
Browse files Browse the repository at this point in the history
  • Loading branch information
chensun committed Feb 9, 2023
1 parent 169f4db commit 2511cea
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions sdk/python/kfp/deprecated/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,7 @@ def create_experiment(
name=name,
description=description,
resource_references=resource_references)
experiment = self._experiment_api.create_experiment_v1(
body=experiment)
experiment = self._experiment_api.create_experiment(body=experiment)

if self._is_ipython():
import IPython
Expand All @@ -498,7 +497,7 @@ def get_pipeline_id(self, name) -> Optional[str]:
"stringValue": name,
}]
})
result = self._pipelines_api.list_pipelines_v1(filter=pipeline_filter)
result = self._pipelines_api.list_pipelines(filter=pipeline_filter)
if result.pipelines is None:
return None
if len(result.pipelines) == 1:
Expand Down Expand Up @@ -545,7 +544,7 @@ def list_experiments(
A response object including a list of experiments and next page token.
"""
namespace = namespace or self.get_user_namespace()
response = self._experiment_api.list_experiments_v1(
response = self._experiment_api.list_experiments()
page_token=page_token,
page_size=page_size,
sort_by=sort_by,
Expand Down Expand Up @@ -581,7 +580,7 @@ def get_experiment(self,
raise ValueError(
'Either experiment_id or experiment_name is required')
if experiment_id is not None:
return self._experiment_api.get_experiment_v1(id=experiment_id)
return self._experiment_api.get_experiment()id=experiment_id)
experiment_filter = json.dumps({
"predicates": [{
"op": _FILTER_OPERATIONS["EQUALS"],
Expand All @@ -590,13 +589,13 @@ def get_experiment(self,
}]
})
if namespace:
result = self._experiment_api.list_experiments_v1(
result = self._experiment_api.list_experiments()
filter=experiment_filter,
resource_reference_key_type=kfp_server_api.models
.api_resource_type.ApiResourceType.NAMESPACE,
resource_reference_key_id=namespace)
else:
result = self._experiment_api.list_experiments_v1(
result = self._experiment_api.list_experiments()
filter=experiment_filter)
if not result.experiments:
raise ValueError(
Expand All @@ -616,7 +615,7 @@ def archive_experiment(self, experiment_id: str):
Raises:
kfp_server_api.ApiException: If experiment is not found.
"""
self._experiment_api.archive_experiment_v1(experiment_id)
self._experiment_api.archive_experiment()experiment_id)

def delete_experiment(self, experiment_id):
"""Delete experiment.
Expand All @@ -630,7 +629,7 @@ def delete_experiment(self, experiment_id):
Raises:
kfp_server_api.ApiException: If experiment is not found.
"""
return self._experiment_api.delete_experiment_v1(id=experiment_id)
return self._experiment_api.delete_experiment()id=experiment_id)

def _extract_pipeline_yaml(self, package_file):

Expand Down Expand Up @@ -711,7 +710,7 @@ def list_pipelines(
Returns:
A response object including a list of pipelines and next page token.
"""
return self._pipelines_api.list_pipelines_v1(
return self._pipelines_api.list_pipelines()
page_token=page_token,
page_size=page_size,
sort_by=sort_by,
Expand Down Expand Up @@ -778,7 +777,7 @@ def run_pipeline(
name=job_name,
service_account=service_account)

response = self._run_api.create_run_v1(body=run_body)
response = self._run_api.create_run()body=run_body)

if self._is_ipython():
import IPython
Expand Down Expand Up @@ -1199,7 +1198,7 @@ def list_runs(
"""
namespace = namespace or self.get_user_namespace()
if experiment_id is not None:
response = self._run_api.list_runs_v1(
response = self._run_api.list_runs()
page_token=page_token,
page_size=page_size,
sort_by=sort_by,
Expand All @@ -1208,7 +1207,7 @@ def list_runs(
resource_reference_key_id=experiment_id,
filter=filter)
elif namespace:
response = self._run_api.list_runs_v1(
response = self._run_api.list_runs()
page_token=page_token,
page_size=page_size,
sort_by=sort_by,
Expand All @@ -1217,7 +1216,7 @@ def list_runs(
resource_reference_key_id=namespace,
filter=filter)
else:
response = self._run_api.list_runs_v1(
response = self._run_api.list_runs()
page_token=page_token,
page_size=page_size,
sort_by=sort_by,
Expand Down Expand Up @@ -1299,7 +1298,7 @@ def get_run(self, run_id: str) -> kfp_server_api.ApiRun:
Raises:
kfp_server_api.ApiException: If run is not found.
"""
return self._run_api.get_run_v1(run_id=run_id)
return self._run_api.get_run()run_id=run_id)

def wait_for_run_completion(self, run_id: str, timeout: int):
"""Waits for a run to complete.
Expand All @@ -1322,7 +1321,7 @@ def wait_for_run_completion(self, run_id: str, timeout: int):
while (status is None or status.lower()
not in ['succeeded', 'failed', 'skipped', 'error']):
try:
get_run_response = self._run_api.get_run_v1(run_id=run_id)
get_run_response = self._run_api.get_run()run_id=run_id)
is_valid_token = True
except ApiException as api_ex:
# if the token is valid but receiving 401 Unauthorized error
Expand Down Expand Up @@ -1351,7 +1350,7 @@ def _get_workflow_json(self, run_id):
Returns:
workflow: Json workflow
"""
get_run_response = self._run_api.get_run_v1(run_id=run_id)
get_run_response = self._run_api.get_run()run_id=run_id)
workflow = get_run_response.pipeline_runtime.workflow_manifest
workflow_json = json.loads(workflow)
return workflow_json
Expand Down Expand Up @@ -1452,7 +1451,7 @@ def get_pipeline(self, pipeline_id: str) -> kfp_server_api.ApiPipeline:
Raises:
kfp_server_api.ApiException: If pipeline is not found.
"""
return self._pipelines_api.get_pipeline_v1(id=pipeline_id)
return self._pipelines_api.get_pipeline()id=pipeline_id)

def delete_pipeline(self, pipeline_id):
"""Delete pipeline.
Expand All @@ -1466,7 +1465,7 @@ def delete_pipeline(self, pipeline_id):
Raises:
kfp_server_api.ApiException: If pipeline is not found.
"""
return self._pipelines_api.delete_pipeline_v1(id=pipeline_id)
return self._pipelines_api.delete_pipeline()id=pipeline_id)

def list_pipeline_versions(
self,
Expand Down Expand Up @@ -1505,7 +1504,7 @@ def list_pipeline_versions(
kfp_server_api.ApiException: If pipeline is not found.
"""

return self._pipelines_api.list_pipeline_versions_v1(
return self._pipelines_api.list_pipeline_versions()
page_token=page_token,
page_size=page_size,
sort_by=sort_by,
Expand All @@ -1526,5 +1525,5 @@ def delete_pipeline_version(self, version_id: str):
Raises:
Exception if pipeline version is not found.
"""
return self._pipelines_api.delete_pipeline_version_v1(
return self._pipelines_api.delete_pipeline_version()
version_id=version_id)

0 comments on commit 2511cea

Please sign in to comment.