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: Correctly handle list values in _python_value_to_proto_value #4608

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TBourtonBumble
Copy link

Currently, _python_value_to_proto_value does not properly handle lists. It will always return a list of values of length one, regardless of the number of input values.

This PR aims to fix this bug, and also adds a check to ensure that the number of returned proto values is the same as the inputted values.

@@ -372,11 +372,15 @@ def _python_value_to_proto_value(
if feast_value_type == ValueType.BYTES_LIST:
raise _type_err(sample, ValueType.BYTES_LIST)

json_value = json.loads(sample)
if isinstance(json_value, list):
json_sample = json.loads(sample)

Choose a reason for hiding this comment

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

Any chance you can add a test here?

Copy link
Author

Choose a reason for hiding this comment

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

Hi, sure thing. Did you have in mind something to check that json.loads(sample) does not error out? E.g. if there's something like a json decode error?

Choose a reason for hiding this comment

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

Actually, it's fine. There's no test there currently so no need to add additional work here. Thank you!

@franciscojavierarceo franciscojavierarceo enabled auto-merge (squash) October 9, 2024 09:58
auto-merge was automatically disabled October 9, 2024 10:55

Head branch was pushed to by a user without write access

@TBourtonBumble
Copy link
Author

Hi sorry, I missed something very dumb with the unit test, i've pushed a fix so they should be ok to re-run

@franciscojavierarceo franciscojavierarceo enabled auto-merge (squash) October 9, 2024 11:05
@TBourtonBumble TBourtonBumble changed the title fix: _python_value_to_proto_value does not handle list values fix: Correctly handle list values in _python_value_to_proto_value Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants