-
Notifications
You must be signed in to change notification settings - Fork 307
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
[WIP][Flytekit] Add variable_map in LiteralResolver for FlyteRemote.get Error on Dataclass/Pydantic Models #3031
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: mao3267 <[email protected]>
Signed-off-by: mao3267 <[email protected]>
…-dataproxy-variable-map
Code Review Agent Run Status
|
…-dataproxy-variable-map
Code Review Agent Run Status
|
Code Review Agent Run #6ace01Actionable Suggestions - 1
Review Details
|
flytekit/remote/remote.py
Outdated
vm = VariableMap.from_flyte_idl(data_response.variable_map) | ||
return LiteralsResolver(lm.literals, vm.variables) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding null check for data_response.variable_map
before accessing it. The variable_map
field might be optional and accessing it without validation could cause issues.
Code suggestion
Check the AI-generated fix before applying
vm = VariableMap.from_flyte_idl(data_response.variable_map) | |
return LiteralsResolver(lm.literals, vm.variables) | |
variables = {} | |
if data_response.HasField("variable_map"): | |
vm = VariableMap.from_flyte_idl(data_response.variable_map) | |
variables = vm.variables | |
return LiteralsResolver(lm.literals, variables) |
Code Review Run #6ace01
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Signed-off-by: mao3267 <[email protected]>
Code Review Agent Run #7c00dbActionable Suggestions - 1
Review Details
|
flytekit/remote/remote.py
Outdated
# 如果 interface.inputs 为空,则只返回 literals | ||
if not interface.inputs: | ||
execution._inputs = input_literal_map.literals | ||
else: | ||
execution._inputs = LiteralsResolver(input_literal_map.literals, interface.inputs, self.context) | ||
|
||
if execution.is_done and not execution.error: | ||
output_literal_map = self._get_output_literal_map(execution_data) | ||
execution._outputs = LiteralsResolver(output_literal_map.literals, interface.outputs, self.context) | ||
# 如果 interface.outputs 为空,则只返回 literals | ||
if not interface.outputs: | ||
execution._outputs = output_literal_map.literals | ||
else: | ||
execution._outputs = LiteralsResolver(output_literal_map.literals, interface.outputs, self.context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider consolidating the input/output handling logic to avoid code duplication. The same pattern is repeated for both inputs and outputs.
Code suggestion
Check the AI-generated fix before applying
- # 如果 interface.inputs 为空,则只返回 literals
- if not interface.inputs:
- execution._inputs = input_literal_map.literals
- else:
- execution._inputs = LiteralsResolver(input_literal_map.literals, interface.inputs, self.context)
-
- if execution.is_done and not execution.error:
- output_literal_map = self._get_output_literal_map(execution_data)
- # 如果 interface.outputs 为空,则只返回 literals
- if not interface.outputs:
- execution._outputs = output_literal_map.literals
- else:
- execution._outputs = LiteralsResolver(output_literal_map.literals, interface.outputs, self.context)
+ def _assign_literals(literal_map, interface_vars, target_attr):
+ if not interface_vars:
+ setattr(execution, target_attr, literal_map.literals)
+ else:
+ setattr(execution, target_attr, LiteralsResolver(literal_map.literals, interface_vars, self.context))
+
+ _assign_literals(input_literal_map, interface.inputs, '_inputs')
+
+ if execution.is_done and not execution.error:
+ output_literal_map = self._get_output_literal_map(execution_data)
+ _assign_literals(output_literal_map, interface.outputs, '_outputs')
Code Review Run #7c00db
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Signed-off-by: mao3267 <[email protected]>
Code Review Agent Run #d1b3c9Actionable Suggestions - 0Review Details
|
Tracking issue
flyteorg/flyte#6081
Why are the changes needed?
While the task input/output is represented as a dataclass or Pydantic model, using the get function to fetch the FlyteRemote execution output will fail due to the absence of the variable_map information. To address this issue, we aim to provide the input/output variable_map in
LiteralResolver
to address this issue.What changes were proposed in this pull request?
How was this patch tested?
TODO
Setup process
Screenshots
TODO
Check all the applicable boxes
Related PRs
flyteorg/flyte#6136
Docs link
Summary by Bito
Enhanced FlyteRemote's LiteralResolver to improve handling of dataclass and Pydantic model inputs/outputs. Implementation includes proper handling of variable map information from data response, with null checks for variable_map field to prevent access issues. The changes standardize the use of LiteralsResolver and remove redundant empty interface checks, resulting in more robust handling of complex data types.Unit tests added: False
Estimated effort to review (1-5, lower is better): 1