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

Enhance Python SDK: Implement Robust Error Handling for add_output Function #687

Merged
merged 10 commits into from
Jan 3, 2024

Conversation

sp6370
Copy link
Contributor

@sp6370 sp6370 commented Jan 1, 2024

Summary:
This pull request addresses a critical flaw in the add_output method within the Python SDK. Currently, the method incorrectly adds None to the output list when the Output parameter is None, which contradicts the intended behavior. The expected functionality is for the method to reject None as an invalid output or, alternatively, raise an exception.

Changes Made:

  • Modified the add_output method to raise an exception when the Output parameter is None.

Context:
This change ensures that the add_output method behaves as expected, providing more robust and predictable behavior when handling output parameters.

Related Issues:
Closes #529

Test Plan:
New test similar to test_add_output_existing_prompt_no_overwrite but with overwrite needs to be added.

Things left to complete:

  • Add test for add_output with overwrite enabled

@sp6370 sp6370 marked this pull request as draft January 1, 2024 02:50
@sp6370 sp6370 changed the title [WIP] Improve error handling for add_ouput [WIP] Add error handling for add_ouput Jan 1, 2024
@sp6370 sp6370 changed the title [WIP] Add error handling for add_ouput [WIP] Add error handling for add_ouput in Python SDK Jan 1, 2024
@sp6370 sp6370 changed the title [WIP] Add error handling for add_ouput in Python SDK Add error handling for add_ouput in Python SDK Jan 2, 2024
@sp6370 sp6370 marked this pull request as ready for review January 2, 2024 02:25
# Case 1: No output, no overwrite
with pytest.raises(
Exception,
match=r"Cannot add output to prompt 'GreetingPrompt'. Output is empty.",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: to make things easier, would make "GreetingPrompt" it's own var like prompt_name and just re-use it here. Not a big deal though

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 would stick to keeping it as it is now. Since isn't being used anymore in the test.

Copy link
Contributor

@rossdanlm rossdanlm 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 doing this, this is great!

Left a bunch of small nit (nit-picking), which aren't blocking, just nice to address, thanks!

@sp6370 sp6370 requested a review from rossdanlm January 2, 2024 18:00
@sp6370
Copy link
Contributor Author

sp6370 commented Jan 2, 2024

Approaching this with curiosity. What's the best approach to managing PR comments?

Should the author address the comment and mark it as resolved, or is it the responsibility of the reviewer to close out the comments after an update or commit?

@rossdanlm
Copy link
Contributor

Approaching this with curiosity. What's the best approach to managing PR comments?

Should the author address the comment and mark it as resolved, or is it the responsibility of the reviewer to close out the comments after an update or commit?

Personally I would say the PR author addresses comments and resolves as they're fixed. Some people prefer that reviewer be more strict and review everything, but I feel that reviewer should just give another final look to confirm everything is cool anyways

@rossdanlm
Copy link
Contributor

This looks great! Thanks for being so diligent with testing and fixes from comments! Looking forward to continue working with you :)

@rossdanlm rossdanlm closed this Jan 3, 2024
@rossdanlm rossdanlm reopened this Jan 3, 2024
@rossdanlm rossdanlm merged commit ed5fb9d into lastmile-ai:main Jan 3, 2024
2 checks passed
@sp6370 sp6370 changed the title Add error handling for add_ouput in Python SDK Enhance Python SDK: Implement Robust Error Handling for add_output Function Jan 6, 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.

Do not overwrite outputs in add_output if value passed is None
2 participants