Skip to content

refactor(core): unify initialization and testing of explainer and `…#6

Merged
DYung26 merged 1 commit into
mainfrom
test/unit-tests
Nov 4, 2025
Merged

refactor(core): unify initialization and testing of explainer and `…#6
DYung26 merged 1 commit into
mainfrom
test/unit-tests

Conversation

@DYung26
Copy link
Copy Markdown
Owner

@DYung26 DYung26 commented Nov 4, 2025

This pull request refactors initialization and test logic for the PlotExplainer and VisualizationRecommender classes, improves test reliability, and introduces a dedicated response parsing class. The main themes are improved default argument handling, more robust provider/model management, and test suite modernization to match the refactored APIs.

Class Initialization and Provider Management:

  • Added default values for all arguments in the VisualizationRecommender.__init__, and consistently store api_keys as a class attribute for use in provider management. [1] [2] [3]
  • Updated provider manager initialization to always use the internal self.api_keys attribute, ensuring consistent API key handling. [1] [2]

Test Suite Refactoring:

  • Refactored tests to use utility functions (save_plot_to_image, encode_image) directly, instead of methods on the explainer instance, improving modularity and reliability. [1] [2]
  • Updated tests for model/provider detection to check for available providers and models using the new API, with more robust assertions and error messages. [1] [2]
  • Changed plot generator tests to use the _default_plots attribute and its initializer, reflecting internal API changes and improving clarity. [1] [2] [3]

API and Interface Changes:

  • Deprecated or commented out direct access to internal attributes and legacy methods in tests, favoring new interfaces and improved encapsulation. [1] [2] [3] [4]
  • Updated test logic to use new methods like recommend_visualizations and its returned objects for prompt building and dataframe description, replacing direct calls to internal methods. [1] [2]

Response Parsing Refactor:

  • Introduced the ResponseParser class and updated all relevant tests to use it for recommendation parsing, improving separation of concerns and code clarity. [1] [2] [3]

Mocking and Test Reliability:

  • Improved test reliability by updating how mock clients and models are injected into recommender instances, ensuring that tests reflect the new model/provider management logic. [1] [2]

These changes collectively modernize the codebase, improve maintainability, and ensure that tests are robust and aligned with the latest API refactors.

…recommender` modules with consistent `API` handling and helper usage

- Added default argument values to `VisualizationRecommender` and `PlotExplainer` constructors for strategy, models, timeout, and interactivity
- Introduced `self.api_keys` and standardized `ProviderManager` initialization across both components
- Updated `test_explanations` to use shared helper functions `encode_image` and `save_plot_to_image` from `core.utils`
- Revised `test_plotgen` to align with new `_default_plots` naming and initialization logic
- Refactored `test_suggestions` to leverage new `ResponseParser`, updated recommendation pipeline, and aligned prompt/query flow
- Commented deprecated internal tests tied to removed private methods (`_get_all_recommendations`, `_parse_recommendations`, etc.)
- Ensured test assertions verify model availability and provider correctness under new recommender structure
@DYung26 DYung26 merged commit 14a541a into main Nov 4, 2025
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.

1 participant