fix: cleanup DOE tools for backend integration#79
Merged
Conversation
pd.Series.append() was removed in pandas 2.0. Column.extend() would crash at runtime on pandas >= 2.0. Switch to pd.concat() which is the recommended replacement. https://claude.ai/code/session_0146zTx37yUE7Les58rSUWL8
The while loop in point_exchange() had no upper bound, risking an infinite loop when the candidate set is inherently singular (e.g. collinear columns). This is especially dangerous in a server context where it would block a worker thread indefinitely. Now retries up to 1000 times and raises ValueError with a clear message if no non-singular starting design is found. https://claude.ai/code/session_0146zTx37yUE7Les58rSUWL8
These methods are stubs returning error dicts. Exposing them in the enum lets an LLM agent select them, producing a confusing pseudo-error. The stub implementations remain in optimization.py for future work, but they are no longer advertised as selectable options. https://claude.ai/code/session_0146zTx37yUE7Les58rSUWL8
Previously, all 9 tool functions swallowed exceptions with bare
return {"error": str(e)}, losing the traceback entirely. Now each
except block logs the full traceback via logger.exception() before
returning the error dict. The return-value contract is unchanged.
This is critical for debugging in a server context where the backend
configures log handlers to route to its observability stack.
https://claude.ai/code/session_0146zTx37yUE7Les58rSUWL8
Remove stale noqa: BLE001 directives (now that logger.exception() means exceptions are no longer swallowed blindly). Remove stale noqa: PERF203 from the refactored loop. Fix en-dash to hyphen in comment. https://claude.ai/code/session_0146zTx37yUE7Les58rSUWL8
Includes fixes for deprecated pandas API, infinite loop guard in optimal design, removal of unimplemented stubs from tool enum, and added logging to all tool wrappers. https://claude.ai/code/session_0146zTx37yUE7Les58rSUWL8
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
Prepares the DOE calculator engine for integration into the agentic backend. Four targeted fixes address issues that would cause problems in a server context.
pd.Series.append()—Column.extend()usedappend()which was removed in pandas 2.0. Replaced withpd.concat().optimal.py—point_exchange()had an unboundedwhile is_singularloop that could hang forever if the candidate set is collinear. Now retries up to 1000 times with a clearValueError.ridge_analysisandpareto_frontwere listed as selectable methods in theoptimize_responsestool spec, but both are stubs. An LLM agent could select them and get a confusing error. Removed from enum; stub functions remain for future implementation.logger.exception()to all 9 tool wrappers — Previously every tool swallowed exceptions withreturn {"error": str(e)}, losing the traceback entirely. Now logs the full traceback before returning the error dict.Test plan
ruff checkpasses on all changed fileshttps://claude.ai/code/session_0146zTx37yUE7Les58rSUWL8