Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sdk): update contributing guidelines to use isort #7549

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[settings]
force_single_line = true
single_line_exclusions = typing, typing_extensions
8 changes: 8 additions & 0 deletions sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ From the project root, run the following code to format your code:
yapf --in-place --recursive ./sdk/python
```

#### Formatting imports [Required]
Please organize your imports using [isort](https://pycqa.github.io/isort/index.html) according to the [`.isort.cfg`](https://github.com/kubeflow/pipelines/blob/master/.isort.cfg) file.

From the project root, run the following code to format your code:
```sh
isort sdk/python --sg sdk/python/kfp/deprecated
```

#### Pylint [Encouraged]
We encourage you to lint your code using [pylint](https://pylint.org/) according to the project [`.pylintrc`](https://github.com/kubeflow/pipelines/blob/master/.pylintrc) file.

Expand Down
7 changes: 4 additions & 3 deletions sdk/python/kfp/compiler/pipeline_spec_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
from typing import List, Mapping, Optional, Tuple, Union

from google.protobuf import struct_pb2
from kfp.pipeline_spec import pipeline_spec_pb2
from kfp.components import utils as component_utils
from kfp.components import for_loop
from kfp.components import pipeline_channel
from kfp.components import pipeline_task
from kfp.components import placeholders
from kfp.components import tasks_group
from kfp.components import utils as component_utils
from kfp.components.types import artifact_types
from kfp.components.types import type_utils
from kfp.pipeline_spec import pipeline_spec_pb2

_GroupOrTask = Union[tasks_group.TasksGroup, pipeline_task.PipelineTask]

Expand Down Expand Up @@ -348,7 +348,8 @@ def build_component_spec_for_task(
input_spec.type)
if input_spec.default is not None:
component_spec.input_definitions.parameters[
input_name].default_value.CopyFrom(_to_protobuf_value(input_spec.default))
input_name].default_value.CopyFrom(
_to_protobuf_value(input_spec.default))

else:
component_spec.input_definitions.artifacts[
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/compiler/pipeline_spec_builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

from absl.testing import parameterized
from google.protobuf import struct_pb2
from kfp.pipeline_spec import pipeline_spec_pb2
from kfp.compiler import pipeline_spec_builder
from kfp.components import pipeline_channel
from kfp.pipeline_spec import pipeline_spec_pb2


class PipelineSpecBuilderTest(parameterized.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

from kfp import compiler
from kfp import dsl
from kfp.dsl import component, Input, Dataset, Model, Metrics
from kfp.dsl import Dataset
from kfp.dsl import Input
from kfp.dsl import Metrics
from kfp.dsl import Model
from kfp.dsl import component


@component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler

component_op = components.load_component_from_text("""
name: Print Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import pathlib

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler

test_data_dir = pathlib.Path(__file__).parent / 'component_yaml'
component_op = components.load_component_from_file(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler
from kfp.dsl import component


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler
from kfp.dsl import component


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.
"""Pipeline using ExitHandler."""

from kfp import dsl
from kfp import compiler
from kfp import dsl
from kfp.dsl import component


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp import components
from kfp.dsl import component, Input, Output
from kfp import compiler
from kfp import components
from kfp import dsl
from kfp.dsl import Input
from kfp.dsl import Output
from kfp.dsl import component


class VertexModel(dsl.Artifact):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import pathlib

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler

test_data_dir = pathlib.Path(__file__).parent / 'component_yaml'
component_op = components.load_component_from_file(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
"""Pipeline using dsl.importer."""

from typing import NamedTuple

from kfp import compiler
from kfp import dsl
from kfp.dsl import component, importer, Dataset, Model, Input
from kfp.dsl import Dataset
from kfp.dsl import Input
from kfp.dsl import Model
from kfp.dsl import component
from kfp.dsl import importer


@component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

from typing import Dict, List

from kfp import compiler, dsl
from kfp import compiler
from kfp import dsl
from kfp.dsl import component


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

from typing import Optional

from kfp import compiler, dsl
from kfp import compiler
from kfp import dsl
from kfp.dsl import component


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@

from typing import NamedTuple

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler
from kfp.dsl import component, Dataset, Input, Metrics, Output
from kfp.dsl import Dataset
from kfp.dsl import Input
from kfp.dsl import Metrics
from kfp.dsl import Output
from kfp.dsl import component


@component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler
from kfp.dsl import component


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler


def random_num_op(low, high):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

from typing import Optional

from kfp import compiler, dsl
from kfp import compiler
from kfp import dsl
from kfp.dsl import component


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pathlib

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler
import pathlib

test_data_dir = pathlib.Path(__file__).parent / 'component_yaml'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler
from kfp.dsl import component


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp import compiler, dsl
from kfp import compiler
from kfp import dsl
from kfp.dsl import component


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pathlib

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler
import pathlib

test_data_dir = pathlib.Path(__file__).parent / 'component_yaml'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import pathlib

from kfp import components
from kfp import compiler
from kfp import components
from kfp import dsl

test_data_dir = pathlib.Path(__file__).parent / 'component_yaml'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
# limitations under the License.
"""Pipeline using ExitHandler with PipelineTaskFinalStatus."""

from kfp import dsl
from kfp import compiler
from kfp.dsl import component

from kfp import dsl
from kfp.dsl import PipelineTaskFinalStatus
from kfp.dsl import component


@component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.
"""Pipeline using ExitHandler with PipelineTaskFinalStatus (YAML)."""

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler
from kfp.dsl import component

exit_op = components.load_component_from_text("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import pathlib

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler

component_op_1 = components.load_component_from_text("""
name: upstream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import pathlib

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler

component_op_1 = components.load_component_from_text("""
name: Write to GCS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# limitations under the License.
from typing import Optional

from kfp import compiler, dsl
from kfp import compiler
from kfp import dsl
from kfp.dsl import component


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp import compiler
from kfp import components
from kfp import dsl
from kfp import compiler

chicago_taxi_dataset_op = components.load_component_from_url(
'https://raw.githubusercontent.com/kubeflow/pipelines/60a2612541ec08c6a85c237d2ec7525b12543a43/components/datasets/Chicago_Taxi_Trips/component.yaml'
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp.components.yaml_component import load_component_from_text
from kfp.components.yaml_component import load_component_from_file
from kfp.components.yaml_component import load_component_from_text
from kfp.components.yaml_component import load_component_from_url
2 changes: 1 addition & 1 deletion sdk/python/kfp/components/base_component_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from unittest.mock import patch

from kfp.components import base_component
from kfp.components import structures
from kfp.components import pipeline_task
from kfp.components import structures


class TestComponent(base_component.BaseComponent):
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/components/component_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import functools
from typing import Callable, Optional, List
from typing import Callable, List, Optional

from kfp.components import component_factory

Expand Down
Loading