Skip to content

Commit

Permalink
SDK/Tests - Removed sys.path manipulations. (#151)
Browse files Browse the repository at this point in the history
Also fixed compilation path.
  • Loading branch information
Ark-kun authored and k8s-ci-robot committed Nov 9, 2018
1 parent 49db170 commit 74f2a13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
10 changes: 3 additions & 7 deletions sdk/python/tests/components/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,15 @@
import unittest
from pathlib import Path

_this_file = Path(__file__).resolve()
_this_dir = _this_file.parent
_test_data_dir = _this_dir.joinpath('test_data')
_tests_root_dir = _this_dir.parent
_sdk_root_dir = _tests_root_dir.parent

sys.path.insert(0, _sdk_root_dir)

import kfp.components as comp
from kfp.components._yaml_utils import load_yaml

class LoadComponentTestCase(unittest.TestCase):
def test_load_component_from_file(self):
_this_file = Path(__file__).resolve()
_this_dir = _this_file.parent
_test_data_dir = _this_dir.joinpath('test_data')
component_path_obj = _test_data_dir.joinpath('python_add.component.yaml')
component_text = component_path_obj.read_text()
component_dict = load_yaml(component_text)
Expand Down
9 changes: 1 addition & 8 deletions sdk/python/tests/components/test_python_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
import kfp.components as comp
from kfp.components._yaml_utils import load_yaml

_this_file = Path(__file__).resolve()
_this_dir = _this_file.parent
_test_data_dir = _this_dir.joinpath('test_data')
_tests_root_dir = _this_dir.parent.parent
_sdk_root_dir = _tests_root_dir.parent

sys.path.insert(0, _sdk_root_dir)

def add_two_numbers(a: float, b: float) -> float:
'''Returns sum of two arguments'''
Expand Down Expand Up @@ -243,7 +236,7 @@ def calc_pipeline(
task_3 = subtract_op(task_12.output, task_22.output)

#Compiling the pipleine:
pipeline_filename = Path(temp_dir_name).joinpath(calc_pipeline.__name__ + '.pipeline.tar.gz')
pipeline_filename = str(Path(temp_dir_name).joinpath(calc_pipeline.__name__ + '.pipeline.tar.gz'))
import kfp.compiler as compiler
compiler.Compiler().compile(calc_pipeline, pipeline_filename)

Expand Down

0 comments on commit 74f2a13

Please sign in to comment.