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

SDK - Components - Verify the object type when serializing primitive arguments #2272

Conversation

Ark-kun
Copy link
Contributor

@Ark-kun Ark-kun commented Sep 30, 2019

Fixes an issue where if an input had a primitive type (e.g. Integer), you could pass anything to it (e.g. booleans, ContainerOps, functions etc), because it just used str as serializer. Now the serializers chack the value type and raise error if the type is incorrect.


This change is Reviewable

…arguments

Fixes an issue where if an input had a primitive type (e.g. `Integer`), you could pass anything to it (e.g. booleans, `ContainerOp`s, functions etc), because it just used `str` as serializer. Now the serializers chack the value type and raise error if the type is incorrect.
def _serialize_int(int_value: int) -> str:
if isinstance(int_value, str):
return int_value
if not isinstance(int_value, int):

Choose a reason for hiding this comment

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

I think you can combine this two if by saying if not isinstance(int_value, int) and not isinstance(int_value, str)?

Copy link

@numerology numerology Oct 1, 2019

Choose a reason for hiding this comment

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

Similar for float/bool serializer

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 will work in this case, but it might not work for general serializer structure:

def serialize_some_type(value: SomeType):
    if isinstance(value, str):
        return value
    if not isinstance(value, SomeType):
        raise TypeError('Value "{}" has type "{}" instead of SomeType.'.format(str(value), str(type(value))))
    return serialize(value)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I find the existing code structure a little bit more readable with three clear cases.

@numerology
Copy link

Left a comment. Otherwise
/lgtm

@Ark-kun
Copy link
Contributor Author

Ark-kun commented Oct 1, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Ark-kun

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 8f4f7bc into kubeflow:master Oct 1, 2019
magdalenakuhn17 pushed a commit to magdalenakuhn17/pipelines that referenced this pull request Oct 22, 2023
…ubeflow#2272)

* update versions for art-explainer to resolve several critical CVEs

Signed-off-by: MessKon <messiskon@gmail.com>

* update Dockerfile; use python:3.9-slim-bullseye instead

Signed-off-by: MessKon <messiskon@gmail.com>
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.

5 participants