Skip to content

Commit

Permalink
WIP: Update Deprecated DSL components to use V2 classes
Browse files Browse the repository at this point in the history
- The files are already deprecated, but are currently breaking the
  v2 samples test.  Updating the classes to use their v2 counterparts
  to get the tests to pass

Signed-off-by: Giulio Frasca <[email protected]>
  • Loading branch information
gmfrasca committed Jul 9, 2024
1 parent 0eae430 commit a348340
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 26 deletions.
4 changes: 4 additions & 0 deletions samples/WIP-REMOVEME
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
REMOVE BEFORE MERGING

Just to trigger the samples-v2 CI Check

32 changes: 16 additions & 16 deletions sdk/python/kfp/deprecated/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def set_user_namespace(self, namespace: str):
with open(Client.LOCAL_KFP_CONTEXT, 'w') as f:
json.dump(self._context_setting, f)

def get_kfp_healthz(self) -> kfp_server_api.ApiGetHealthzResponse:
def get_kfp_healthz(self) -> kfp_server_api.V2beta1GetHealthzResponse:
"""Gets healthz info of KFP deployment.
Returns:
Expand Down Expand Up @@ -431,7 +431,7 @@ def create_experiment(
self,
name: str,
description: str = None,
namespace: str = None) -> kfp_server_api.ApiExperiment:
namespace: str = None) -> kfp_server_api.V2beta1Experiment:
"""Create a new experiment.
Args:
Expand Down Expand Up @@ -515,7 +515,7 @@ def list_experiments(
sort_by: str = '',
namespace: Optional[str] = None,
filter: Optional[str] = None
) -> kfp_server_api.ApiListExperimentsResponse:
) -> kfp_server_api.V2beta1ListExperimentsResponse:
"""List experiments.
Args:
Expand Down Expand Up @@ -557,7 +557,7 @@ def list_experiments(
def get_experiment(self,
experiment_id=None,
experiment_name=None,
namespace=None) -> kfp_server_api.ApiExperiment:
namespace=None) -> kfp_server_api.V2beta1Experiment:
"""Get details of an experiment.
Either experiment_id or experiment_name is required
Expand Down Expand Up @@ -685,7 +685,7 @@ def list_pipelines(
page_size: int = 10,
sort_by: str = '',
filter: Optional[str] = None
) -> kfp_server_api.ApiListPipelinesResponse:
) -> kfp_server_api.V2beta1ListPipelinesResponse:
"""List pipelines.
Args:
Expand Down Expand Up @@ -728,7 +728,7 @@ def run_pipeline(
pipeline_root: Optional[str] = None,
enable_caching: Optional[str] = None,
service_account: Optional[str] = None,
) -> kfp_server_api.ApiRun:
) -> kfp_server_api.V2beta1Run:
"""Run a specified pipeline.
Args:
Expand Down Expand Up @@ -805,7 +805,7 @@ def create_recurring_run(
enabled: bool = True,
enable_caching: Optional[bool] = None,
service_account: Optional[str] = None,
) -> kfp_server_api.ApiJob:
) -> kfp_server_api.V2beta1RecurringRun:
"""Create a recurring run.
Args:
Expand Down Expand Up @@ -935,7 +935,7 @@ def __init__(self, spec, resource_references):

pipeline_json_string = json.dumps(pipeline_obj)
api_params = [
kfp_server_api.ApiParameter(
kfp_server_api.Parameter(
name=sanitize_k8s_name(name=k, allow_capital_underscore=True),
value=str(v) if type(v) not in (list, dict) else json.dumps(v))
for k, v in params.items()
Expand Down Expand Up @@ -1167,7 +1167,7 @@ def list_runs(
sort_by: str = '',
experiment_id: Optional[str] = None,
namespace: Optional[str] = None,
filter: Optional[str] = None) -> kfp_server_api.ApiListRunsResponse:
filter: Optional[str] = None) -> kfp_server_api.V2beta1ListRunsResponse:
"""List runs, optionally can be filtered by experiment or namespace.
Args:
Expand Down Expand Up @@ -1229,7 +1229,7 @@ def list_recurring_runs(
page_size: int = 10,
sort_by: str = '',
experiment_id: Optional[str] = None,
filter: Optional[str] = None) -> kfp_server_api.ApiListJobsResponse:
filter: Optional[str] = None) -> kfp_server_api.V2beta1ListRecurringRunsResponse:
"""List recurring runs.
Args:
Expand Down Expand Up @@ -1272,7 +1272,7 @@ def list_recurring_runs(
filter=filter)
return response

def get_recurring_run(self, job_id: str) -> kfp_server_api.ApiJob:
def get_recurring_run(self, job_id: str) -> kfp_server_api.V2beta1RecurringRun:
"""Get recurring_run details.
Args:
Expand All @@ -1286,7 +1286,7 @@ def get_recurring_run(self, job_id: str) -> kfp_server_api.ApiJob:
"""
return self._job_api.get_job(id=job_id)

def get_run(self, run_id: str) -> kfp_server_api.ApiRun:
def get_run(self, run_id: str) -> kfp_server_api.V2beta1Run:
"""Get run details.
Args:
Expand Down Expand Up @@ -1360,7 +1360,7 @@ def upload_pipeline(
pipeline_package_path: str = None,
pipeline_name: str = None,
description: str = None,
) -> kfp_server_api.ApiPipeline:
) -> kfp_server_api.V2beta1Pipeline:
"""Uploads the pipeline to the Kubeflow Pipelines cluster.
Args:
Expand Down Expand Up @@ -1388,7 +1388,7 @@ def upload_pipeline_version(
pipeline_id: Optional[str] = None,
pipeline_name: Optional[str] = None,
description: Optional[str] = None,
) -> kfp_server_api.ApiPipelineVersion:
) -> kfp_server_api.V2beta1PipelineVersion:
"""Uploads a new version of the pipeline to the Kubeflow Pipelines
cluster.
Expand Down Expand Up @@ -1439,7 +1439,7 @@ def upload_pipeline_version(
IPython.display.display(IPython.display.HTML(html))
return response

def get_pipeline(self, pipeline_id: str) -> kfp_server_api.ApiPipeline:
def get_pipeline(self, pipeline_id: str) -> kfp_server_api.V2beta1Pipeline:
"""Get pipeline details.
Args:
Expand Down Expand Up @@ -1474,7 +1474,7 @@ def list_pipeline_versions(
page_size: int = 10,
sort_by: str = '',
filter: Optional[str] = None
) -> kfp_server_api.ApiListPipelineVersionsResponse:
) -> kfp_server_api.V2beta1ListPipelineVersionsResponse:
"""Lists pipeline versions.
Args:
Expand Down
6 changes: 3 additions & 3 deletions sdk/python/kfp/deprecated/cli/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from kfp.deprecated.cli.output import print_output, OutputFormat
import kfp_server_api
from kfp_server_api.models.api_experiment import ApiExperiment
from kfp_server_api.models.v2beta1_experiment import V2beta1Experiment


@click.group()
Expand Down Expand Up @@ -93,7 +93,7 @@ def delete(ctx: click.Context, experiment_id: str):
click.echo("{} is deleted.".format(experiment_id))


def _display_experiments(experiments: List[ApiExperiment],
def _display_experiments(experiments: List[V2beta1Experiment],
output_format: OutputFormat):
headers = ["Experiment ID", "Name", "Created at"]
data = [
Expand All @@ -102,7 +102,7 @@ def _display_experiments(experiments: List[ApiExperiment],
print_output(data, headers, output_format, table_format="grid")


def _display_experiment(exp: kfp_server_api.ApiExperiment,
def _display_experiment(exp: kfp_server_api.V2beta1Experiment,
output_format: OutputFormat):
table = [
["ID", exp.id],
Expand Down
8 changes: 4 additions & 4 deletions sdk/python/kfp/deprecated/cli/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ def delete(ctx: click.Context, pipeline_id: str):
click.echo(f"{pipeline_id} is deleted")


def _print_pipelines(pipelines: List[kfp_server_api.ApiPipeline],
def _print_pipelines(pipelines: List[kfp_server_api.V2beta1Pipeline],
output_format: OutputFormat):
headers = ["Pipeline ID", "Name", "Uploaded at"]
data = [[pipeline.id, pipeline.name,
pipeline.created_at.isoformat()] for pipeline in pipelines]
print_output(data, headers, output_format, table_format="grid")


def _print_pipeline_versions(versions: List[kfp_server_api.ApiPipelineVersion],
def _print_pipeline_versions(versions: List[kfp_server_api.V2beta1PipelineVersion],
output_format: OutputFormat):
headers = ["Version ID", "Version name", "Uploaded at", "Pipeline ID"]
data = [[
Expand All @@ -219,7 +219,7 @@ def _print_pipeline_versions(versions: List[kfp_server_api.ApiPipelineVersion],
print_output(data, headers, output_format, table_format="grid")


def _display_pipeline(pipeline: kfp_server_api.ApiPipeline,
def _display_pipeline(pipeline: kfp_server_api.V2beta1Pipeline,
output_format: OutputFormat):
# Pipeline information
table = [["Pipeline ID", pipeline.id], ["Name", pipeline.name],
Expand Down Expand Up @@ -247,7 +247,7 @@ def _display_pipeline(pipeline: kfp_server_api.ApiPipeline,
print_output(output, [], output_format)


def _display_pipeline_version(version: kfp_server_api.ApiPipelineVersion,
def _display_pipeline_version(version: kfp_server_api.V2beta1PipelineVersion,
output_format: OutputFormat):
pipeline_id = next(
rr for rr in version.resource_references
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/kfp/deprecated/cli/recurring_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ def delete(ctx: click.Context, job_id: str):
client.delete_job(job_id)


def _display_recurring_runs(recurring_runs: List[kfp_server_api.ApiJob],
def _display_recurring_runs(recurring_runs: List[kfp_server_api.V2beta1RecurringRun],
output_format: OutputFormat):
headers = ["Recurring Run ID", "Name"]
data = [[rr.id, rr.name] for rr in recurring_runs]
print_output(data, headers, output_format, table_format="grid")


def _display_recurring_run(recurring_run: kfp_server_api.ApiJob,
def _display_recurring_run(recurring_run: kfp_server_api.V2beta1RecurringRun,
output_format: OutputFormat):
table = [
["Recurring Run ID", recurring_run.id],
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/deprecated/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def _wait_for_run_completion(client: Client, run_id: str, timeout: int,
_print_runs([run_detail.run], output_format)


def _print_runs(runs: List[kfp_server_api.ApiRun], output_format: OutputFormat):
def _print_runs(runs: List[kfp_server_api.V2beta1Run], output_format: OutputFormat):
headers = ['run id', 'name', 'status', 'created at', 'experiment id']
data = [[
run.id, run.name, run.status,
Expand Down

0 comments on commit a348340

Please sign in to comment.