Skip to content

Commit

Permalink
chore: Change python/kfp/compiler and cli folders from relative to ab…
Browse files Browse the repository at this point in the history
…solute path (#5891)

* Update deprecated download_as_string to download_as_bytes

* Add more usage

* chore: Change python/kfp/cli from relative to absolute path

* chore: Change python/kfp/compiler from relative to absolute path
  • Loading branch information
ji-yaqi authored Jun 22, 2021
1 parent a1740b4 commit e7c281b
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 44 deletions.
12 changes: 6 additions & 6 deletions sdk/python/kfp/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import click
import logging
import sys
from .._client import Client
from .run import run
from .pipeline import pipeline
from .diagnose_me_cli import diagnose_me
from .experiment import experiment
from .output import OutputFormat
from kfp._client import Client
from kfp.cli.run import run
from kfp.cli.pipeline import pipeline
from kfp.cli.diagnose_me_cli import diagnose_me
from kfp.cli.experiment import experiment
from kfp.cli.output import OutputFormat

@click.group()
@click.option('--endpoint', help='Endpoint of the KFP API service to connect.')
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/cli/diagnose_me/dev_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Functions for diagnostic data collection from development development."""

import enum
from . import utility
from kfp.cli.diagnose_me import utility


class Commands(enum.Enum):
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/kfp/cli/diagnose_me/dev_env_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from typing import Text
import unittest
from unittest import mock
from . import dev_env
from . import utility
from kfp.cli.diagnose_me import dev_env
from kfp.cli.diagnose_me import utility


class DevEnvTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/cli/diagnose_me/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import enum
from typing import List, Text, Optional
from . import utility
from kfp.cli.diagnose_me import utility


class Commands(enum.Enum):
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/kfp/cli/diagnose_me/gcp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from typing import Text
import unittest
from unittest import mock
from . import gcp
from . import utility
from kfp.cli.diagnose_me import gcp
from kfp.cli.diagnose_me import utility


class GoogleCloudTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/cli/diagnose_me/kubernetes_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import enum
from typing import List, Text
from . import utility
from kfp.cli.diagnose_me import utility


class Commands(enum.Enum):
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/kfp/cli/diagnose_me/kubernetes_cluster_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from typing import Text
import unittest
from unittest import mock
from . import kubernetes_cluster as dkc
from . import utility
from kfp.cli.diagnose_me import kubernetes_cluster as dkc
from kfp.cli.diagnose_me import utility


class KubernetesClusterTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/cli/diagnose_me/utility_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Tests for diagnose_me.utility."""

import unittest
from . import utility
from kfp.cli.diagnose_me import utility


class UtilityTest(unittest.TestCase):
Expand Down
8 changes: 4 additions & 4 deletions sdk/python/kfp/cli/diagnose_me_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import sys
from typing import Dict, Text
import click
from .diagnose_me import dev_env
from .diagnose_me import gcp
from .diagnose_me import kubernetes_cluster as k8
from .diagnose_me import utility
from kfp.cli.diagnose_me import dev_env
from kfp.cli.diagnose_me import gcp
from kfp.cli.diagnose_me import kubernetes_cluster as k8
from kfp.cli.diagnose_me import utility


@click.group()
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/cli/experiment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import click
import json

from .output import print_output, OutputFormat
from kfp.cli.output import print_output, OutputFormat


@click.group()
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/cli/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import click
import json

from .output import print_output, OutputFormat
from kfp.cli.output import print_output, OutputFormat


@click.group()
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import click
import shutil

from .output import print_output, OutputFormat
from kfp.cli.output import print_output, OutputFormat


@click.group()
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/compiler/_default_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import warnings
from kubernetes import client as k8s_client
from typing import Callable, Dict, Optional, Text
from ..dsl._container_op import BaseOp, ContainerOp
from kfp.dsl._container_op import BaseOp, ContainerOp

def add_pod_env(op: BaseOp) -> BaseOp:
"""Adds environment info if the Pod has the label `add-pod-env = true`.
Expand Down
8 changes: 4 additions & 4 deletions sdk/python/kfp/compiler/_k8s_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import re

from .. import dsl
from kfp import dsl


def sanitize_k8s_name(name, allow_capital_underscore=False):
Expand Down Expand Up @@ -67,11 +67,11 @@ def convert_k8s_obj_to_json(k8s_obj):
for sub_obj in k8s_obj)
elif isinstance(k8s_obj, (datetime, date)):
return k8s_obj.isoformat()
elif isinstance(k8s_obj, dsl.PipelineParam):
elif isinstance(k8s_obj, dsl.PipelineParam):
if isinstance(k8s_obj.value, str):
return k8s_obj.value
return '{{inputs.parameters.%s}}' % k8s_obj.full_name

if isinstance(k8s_obj, dict):
obj_dict = k8s_obj
else:
Expand All @@ -85,4 +85,4 @@ def convert_k8s_obj_to_json(k8s_obj):
if getattr(k8s_obj, attr) is not None}

return {key: convert_k8s_obj_to_json(val)
for key, val in iteritems(obj_dict)}
for key, val in iteritems(obj_dict)}
8 changes: 4 additions & 4 deletions sdk/python/kfp/compiler/_op_to_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from collections import OrderedDict
from typing import Union, List, Any, Callable, TypeVar, Dict

from ._k8s_helper import convert_k8s_obj_to_json
from .. import dsl
from ..dsl._container_op import BaseOp
from kfp.compiler._k8s_helper import convert_k8s_obj_to_json
from kfp import dsl
from kfp.dsl._container_op import BaseOp


# generics
Expand Down Expand Up @@ -305,7 +305,7 @@ def _op_to_template(op: BaseOp):
del template['container']['resources'][setting]
if podSpecPatch:
template['podSpecPatch'] = json.dumps(podSpecPatch)

if isinstance(op, dsl.ContainerOp) and op._metadata and not op.is_v2:
template.setdefault('metadata', {}).setdefault('annotations', {})['pipelines.kubeflow.org/component_spec'] = json.dumps(op._metadata.to_dict(), sort_keys=True)

Expand Down
20 changes: 10 additions & 10 deletions sdk/python/kfp/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
from kfp.dsl import _for_loop
from kfp.compiler import _data_passing_rewriter, v2_compat

from .. import dsl
from ._k8s_helper import convert_k8s_obj_to_json, sanitize_k8s_name
from ._op_to_template import _op_to_template, _process_obj
from ._default_transformers import add_pod_env, add_pod_labels

from ..components.structures import InputSpec
from ..components._yaml_utils import dump_yaml
from ..dsl._metadata import _extract_pipeline_metadata
from ..dsl._ops_group import OpsGroup
from ..dsl._pipeline_param import extract_pipelineparams_from_any, PipelineParam
from kfp import dsl
from kfp.compiler._k8s_helper import convert_k8s_obj_to_json, sanitize_k8s_name
from kfp.compiler._op_to_template import _op_to_template, _process_obj
from kfp.compiler._default_transformers import add_pod_env, add_pod_labels

from kfp.components.structures import InputSpec
from kfp.components._yaml_utils import dump_yaml
from kfp.dsl._metadata import _extract_pipeline_metadata
from kfp.dsl._ops_group import OpsGroup
from kfp.dsl._pipeline_param import extract_pipelineparams_from_any, PipelineParam

_SDK_VERSION_LABEL = 'pipelines.kubeflow.org/kfp_sdk_version'
_SDK_ENV_LABEL = 'pipelines.kubeflow.org/pipeline-sdk-type'
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/kfp/compiler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


import argparse
import kfp.dsl as dsl
from kfp import dsl
import kfp.compiler
import os
import shutil
Expand Down Expand Up @@ -77,7 +77,7 @@ def add_pipeline(func):
self.old_handler = dsl._pipeline._pipeline_decorator_handler
dsl._pipeline._pipeline_decorator_handler = add_pipeline
return pipeline_funcs

def __exit__(self, *args):
dsl._pipeline._pipeline_decorator_handler = self.old_handler

Expand Down

0 comments on commit e7c281b

Please sign in to comment.