fix: replace print() with logger and strengthen error handling#215
Open
crazywriter1 wants to merge 2 commits intoOpenGradient:mainfrom
Open
fix: replace print() with logger and strengthen error handling#215crazywriter1 wants to merge 2 commits intoOpenGradient:mainfrom
crazywriter1 wants to merge 2 commits intoOpenGradient:mainfrom
Conversation
- Replace print() calls in alpha.py with logger.warning() - Standardize exception type: bare Exception -> RuntimeError in new_workflow - Guard choices parsing in llm.py _chat_request with list and dict checks - Log malformed SSE JSON in llm.py and types.py streaming parsers Signed-off-by: crazywriter1 <crazywriter1@users.noreply.github.com>
Collaborator
|
Hey, would you mind merging from main? Thanks! |
…servability # Conflicts: # src/opengradient/client/alpha.py
Author
|
Done. Merged from main and force pushed. Thanks for the review. @adambalogh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
alpha.py— Replace twoprint()calls withlogger.warning()so gas estimation failures and scheduler registration errors are captured by the caller's logging infrastructure instead of going to stdoutalpha.py— Changeraise Exception(...)toraise RuntimeError(...)innew_workflowto match the exception type used consistently everywhere else in the codebase; updated docstring to reflect that gas estimation failure uses a fallback instead of raisingalpha.py— Fixed_register_with_schedulerdocstring: previously claimedRaises: Exceptionbut the method never raises — errors are caught, logged, and swallowed intentionally since the workflow contract is already deployedllm.py— Strengthen thechoices[]guard in_chat_request: addedisinstance(choices, list)andisinstance(choices[0], dict)checks — the previousif not choicesguard passes silently for[None]or non-list types, which then crashes with an unhelpfulAttributeErrorllm.py/types.py— Log malformed SSE JSON chunks withlogger.warning()instead of silentlycontinue-ing, making it visible when the server sends broken data during streamingFiles Changed
src/opengradient/client/alpha.pysrc/opengradient/client/llm.pysrc/opengradient/types.pytests/client_test.pyTest Plan
uv run pytest tests/ -v→ 121 passedTestChoicesGuard— verifieschoices=[]andchoices=[None]both raiseRuntimeErrorTestSSEJsonLogging— verifies malformed SSE JSON emitslogger.warning, valid chunks do notTestAlphaErrorHandling— verifies deployment failure raisesRuntimeError, gas estimation failure and scheduler failure both calllogger.warning