-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Incorrect usage of python assertions #1134
Comments
Hi @Bain-OS , thanks for raising this. These asserts were set up for the open-source development and testing of DSPy. Definitely agree that these should be removed in production environments, and it would be great if you have any ideas on keeping a flag for this within the codebase to make DSPy production ready. Feel free to open a PR on it! |
I think @Bain-OS is worried about the exact opposite. |
The way python assert statements are used here is potentially not correct. These should be raising exceptions instead
See these for example, I have not done an exhaustive search
https://github.com/stanfordnlp/dspy/blob/main/dsp/templates/template_v2.py#L102
https://github.com/stanfordnlp/dspy/blob/main/dsp/templates/template_v2.py#L188
The reason this usage is incorrect: when deploying production python codebase it is good to set the optimize flag which removes asserts. i.e asserts should only be used as a development/debugging tool
see more here https://docs.datadoghq.com/code_analysis/static_analysis_rules/python-best-practices/no-assert/
The text was updated successfully, but these errors were encountered: