Skip to content

Commit

Permalink
chore(test): revert api changes to deprecated client (#8841)
Browse files Browse the repository at this point in the history
* revert api changes to deprecated client

* list experiments

* fix

* fix sample v2 test
  • Loading branch information
chensun authored Feb 14, 2023
1 parent 3c3ba25 commit 8552226
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 32 deletions.
2 changes: 1 addition & 1 deletion backend/api/v1beta1/python_http_client/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from setuptools import setup, find_packages # noqa: H301

NAME = "kfp-server-api"
VERSION = "2.0.0-alpha.6"
VERSION = "unreleased"
# To install the library, run the following
#
# python setup.py install
Expand Down
4 changes: 0 additions & 4 deletions backend/src/v2/test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,5 @@ COPY samples/test/utils samples/test/utils
# cd to that folder first
RUN cd backend/src/v2/test && pip3 install --no-cache-dir -r requirements.txt

# Install KFP server API from commit.
COPY $source_root/backend/api/v1beta1/python_http_client /python_http_client
RUN python3 -m pip install /python_http_client

# copy all other code
COPY . .
3 changes: 0 additions & 3 deletions backend/src/v2/test/sample-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,5 @@ python3 -m pip install --upgrade pip
python3 -m pip install -r $source_root/sdk/python/requirements-deprecated.txt
python3 -m pip install $source_root/sdk/python

# Install KFP server API from commit.
cp -r $source_root/backend/api/v1beta1/python_http_client /python_http_client
python3 -m pip install /python_http_client
# Run sample test
ENV_PATH=kfp-ci.env make
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_experiment(
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_experiment(
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_experiment(
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)
4 changes: 1 addition & 3 deletions test/sample-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ RUN pip3 install -r /python/src/github.com/kubeflow/pipelines/test/sample-test/r
# TODO: remove deprecated dependency
COPY ./sdk/python/requirements-deprecated.txt /python/src/github.com/kubeflow/pipelines/sdk/python/requirements-deprecated.txt
RUN pip3 install -r /python/src/github.com/kubeflow/pipelines/sdk/python/requirements-deprecated.txt
# TODO(chensun): Remove install KFP server API from commit once we migrate tests away from using legacy client.
COPY ./backend/api/v1beta1/python_http_client /python_http_client
# Install python client, including DSL compiler.
COPY ./sdk/python /sdk/python
RUN pip3 install /python_http_client /sdk/python
RUN pip3 install /sdk/python

# Copy sample test and samples source code.
COPY ./test/sample-test /python/src/github.com/kubeflow/pipelines/test/sample-test
Expand Down

0 comments on commit 8552226

Please sign in to comment.