-
Notifications
You must be signed in to change notification settings - Fork 310
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
wrap agent outputs in a literalmap #3143
Conversation
Signed-off-by: Samhita Alla <[email protected]>
Code Review Agent Run Status
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3143 +/- ##
==========================================
+ Coverage 76.85% 76.99% +0.13%
==========================================
Files 206 213 +7
Lines 21851 22348 +497
Branches 2837 2837
==========================================
+ Hits 16794 17207 +413
- Misses 4269 4354 +85
+ Partials 788 787 -1 ☔ View full report in Codecov by Sentry. |
plugins/flytekit-aws-sagemaker/flytekitplugins/awssagemaker_inference/boto3_agent.py
Show resolved
Hide resolved
Signed-off-by: Samhita Alla <[email protected]>
Code Review Agent Run #813c1aActionable Suggestions - 1
Review Details
|
Signed-off-by: Samhita Alla <[email protected]>
Changelist by BitoThis pull request implements the following key changes.
|
@@ -157,6 +156,7 @@ async def test_openai_batch_agent(mock_retrieve, mock_create, mock_context): | |||
mock_retrieve.return_value = batch_retrieve_result | |||
resource = await agent.get(metadata) | |||
assert resource.phase == TaskExecution.SUCCEEDED | |||
assert isinstance(resource.outputs, literals.LiteralMap) |
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 more specific assertions to validate the structure and content of the LiteralMap
outputs. This could help catch potential issues with the output format early.
Code suggestion
Check the AI-generated fix before applying
assert isinstance(resource.outputs, literals.LiteralMap) | |
assert isinstance(resource.outputs, literals.LiteralMap) | |
assert 'result' in resource.outputs.literals | |
assert isinstance(resource.outputs.literals['result'].scalar.primitive.string_value, str) |
Code Review Run #813c1a
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
Code Review Agent Run #0f8cc0Actionable Suggestions - 0Review Details
|
Tracking issue
Why are the changes needed?
This is necessary because although the result is already a literal, it is being converted to a literal again. Since literal isn't a valid Python type, it ends up being pickled. This issue surfaced in Flytekit 1.15.0.
What changes were proposed in this pull request?
Wrapping agent outputs in a
LiteralMap
so they don't get converted to literals again.How was this patch tested?
Tested the OpenAI plugin with the updated code.
Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link
Summary by Bito
Fixed a bug in agent output handling where results were being converted to literals multiple times, affecting Python type validation in Flytekit 1.15.0. Implemented proper LiteralMap wrapping for agent outputs in AWS SageMaker and OpenAI plugins to prevent double literal conversion. Modified AWS SageMaker plugin test cases to enhance output type validation and added conditional checks for LiteralMap instances with improved mock return value handling.Unit tests added: True
Estimated effort to review (1-5, lower is better): 1