Skip to content

Commit

Permalink
Fix for k8s dict parsing (#411)
Browse files Browse the repository at this point in the history
* Add support for minio artifacts

* Add new tests for parity

* Fix for sdk env bug

* improved test
  • Loading branch information
vanpelt authored and k8s-ci-robot committed Nov 30, 2018
1 parent 8a13287 commit 26fd724
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions sdk/python/kfp/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def _convert_k8s_obj_to_dic(self, obj):
Returns: The serialized form of data.
"""

from six import text_type, integer_types
from six import text_type, integer_types, iteritems
PRIMITIVE_TYPES = (float, bool, bytes, text_type) + integer_types
from datetime import date, datetime
if obj is None:
Expand All @@ -532,7 +532,6 @@ def _convert_k8s_obj_to_dic(self, obj):
# and attributes which value is not None.
# Convert attribute name to json key in
# model definition for request.
from six import iteritems
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
for attr, _ in iteritems(obj.swagger_types)
if getattr(obj, attr) is not None}
Expand Down
16 changes: 16 additions & 0 deletions sdk/python/tests/compiler/compiler_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import tempfile
import unittest
import yaml
import datetime

class TestCompiler(unittest.TestCase):

Expand Down Expand Up @@ -141,6 +142,21 @@ def test_basic_workflow(self):
shutil.rmtree(tmpdir)
# print(tmpdir)

def test_convert_k8s_obj_to_dic_accepts_dict(self):
now = datetime.datetime.now()
converted = compiler.Compiler()._convert_k8s_obj_to_dic({
"ENV": "test",
"number": 3,
"list": [1,2,3],
"time": now
})
self.assertEqual(converted, {
"ENV": "test",
"number": 3,
"list": [1,2,3],
"time": now.isoformat()
})

def test_composing_workflow(self):
"""Test compiling a simple workflow, and a bigger one composed from the simple one."""

Expand Down

0 comments on commit 26fd724

Please sign in to comment.