Skip to content

Commit

Permalink
SDK - Relative imports (#156)
Browse files Browse the repository at this point in the history
Made all SDK import relative so that they files always refer to the sibling files instead of the installed package. This makes debugging and development easier since you can be sure the correct files are used.
  • Loading branch information
Ark-kun authored and k8s-ci-robot committed Nov 10, 2018
1 parent 43b2381 commit 199a962
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions sdk/python/kfp/compiler/_component_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import logging
from google.cloud import storage
from pathlib import PurePath, Path
from kfp import dsl
from kfp.components._components import _create_task_factory_from_component_dict
from .. import dsl
from ..components._components import _create_task_factory_from_component_dict
from ._k8s_helper import K8sHelper

class GCSHelper(object):
Expand Down
3 changes: 2 additions & 1 deletion sdk/python/kfp/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
from collections import defaultdict
import copy
import inspect
import kfp.dsl as dsl
import re
import string
import tarfile
import tempfile
import yaml

from .. import dsl


class Compiler(object):
"""DSL Compiler.
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/components/_dsl_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
_dummy_pipeline=None

def _create_task_object(name:str, container_image:str, command=None, arguments=None, file_inputs=None, file_outputs=None):
import kfp.dsl as dsl
from .. import dsl
global _dummy_pipeline
need_dummy = dsl.Pipeline._default_pipeline is None
if need_dummy:
Expand Down
7 changes: 3 additions & 4 deletions sdk/python/kfp/dsl/_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp import dsl
def python_component(name, description, base_image):
"""Decorator of component functions.
Expand All @@ -28,7 +27,7 @@ def my_component(a: str, b: int) -> str:
```
"""
def _python_component(func):
dsl.PythonComponent.add_python_component(name, description, base_image, func)
PythonComponent.add_python_component(name, description, base_image, func)
return func

return _python_component
Expand All @@ -50,7 +49,7 @@ class PythonComponent():
@staticmethod
def add_python_component(name, description, base_image, func):
""" Add a python component """
dsl.PythonComponent._component_functions[func] = {
PythonComponent._component_functions[func] = {
'name': name,
'description': description,
'base_image': base_image
Expand All @@ -59,4 +58,4 @@ def add_python_component(name, description, base_image, func):
@staticmethod
def get_python_component(func):
""" Get a python component """
return dsl.PythonComponent._component_functions.get(func, None)
return PythonComponent._component_functions.get(func, None)
2 changes: 1 addition & 1 deletion sdk/python/kfp/notebook/_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
raise Exception('This module can only be loaded in Jupyter.')


from kfp.compiler import build_docker_image
import os
import tempfile
from ..compiler import build_docker_image


@IPython.core.magic.register_cell_magic
Expand Down

0 comments on commit 199a962

Please sign in to comment.