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

Fix for k8s dict parsing #411

Merged
merged 5 commits into from Nov 30, 2018
Merged

Fix for k8s dict parsing #411

merged 5 commits into from Nov 30, 2018

Conversation

vanpelt
Copy link
Contributor

@vanpelt vanpelt commented Nov 29, 2018

The current code blows up when attempting to parse a dict.


This change is Reviewable

@k8s-ci-robot
Copy link
Contributor

Hi @vanpelt. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

1 similar comment
@k8s-ci-robot
Copy link
Contributor

Hi @vanpelt. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

"list": [1,2,3],
"time": datetime.datetime.now()
})
assert isinstance(converted["time"], str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we verify the whole converted results? Something like:

expected = {
"ENV": "test",
"number": 3,
"list": [1,2,3],
"time": 'YouNeedToUseAFixedTime'
}
self.assertEqual(expected, converted)

Copy link
Contributor

@qimingj qimingj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching it! One comment.

@@ -141,6 +142,15 @@ def test_basic_workflow(self):
shutil.rmtree(tmpdir)
# print(tmpdir)

def test_convert_k8s_obj_to_dic(self):
converted = compiler.Compiler()._convert_k8s_obj_to_dic({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument given to _convert_k8s_obj_to_dic is not a k8s object. What exactly is this call trying to show?

@@ -141,6 +142,15 @@ def test_basic_workflow(self):
shutil.rmtree(tmpdir)
# print(tmpdir)

def test_convert_k8s_obj_to_dic(self):
converted = compiler.Compiler()._convert_k8s_obj_to_dic({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_convert_k8s_obj_to_dic should not be an instance method. It's not using any compiler data.

@Ark-kun
Copy link
Contributor

Ark-kun commented Nov 29, 2018

How does this PR fix dict parsing?

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a style change? This function is copied directly from the official Kubernetes client library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the bug. I hit this issue because I tried to pass a dict into op.add_env_variable. Line 541 accesses iteritems but it was only defined in a conditional branch so it threw an "object accessed before assignment" error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another fix here may be to throw a ValueError if the env_variable isn't a k8s object, but It would be nice to be able to pass in a dict without having to use the k8s wrapper. Regardless, this is definitely a bug.

@qimingj
Copy link
Contributor

qimingj commented Nov 30, 2018

/ok-to-test

@qimingj
Copy link
Contributor

qimingj commented Nov 30, 2018

Thank you @vanpelt!

@qimingj
Copy link
Contributor

qimingj commented Nov 30, 2018

/lgtm

@qimingj
Copy link
Contributor

qimingj commented Nov 30, 2018

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qimingj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1 similar comment
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qimingj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 26fd724 into kubeflow:master Nov 30, 2018
Linchin pushed a commit to Linchin/pipelines that referenced this pull request Apr 11, 2023
See kubeflow/testing#3523

If we are unable to find a common ancestor just compute the diff against
the head of the master branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants