You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We now support text output in test results.
If a test returns a string, it will be used as the test description. In such cases, the automatic generation of the test result description will be skipped, and the test output will be used directly.
@vm.test("my_custom_tests.MyCustomTest")defmy_custom_test(dataset, model):
""" This is a custom test that does nothing. """y_true=dataset.yy_pred=dataset.y_pred(model)
confusion_matrix=metrics.confusion_matrix(y_true, y_pred)
cm_display=metrics.ConfusionMatrixDisplay(
confusion_matrix=confusion_matrix, display_labels=[False, True]
)
cm_display.plot()
plt.close() # close the plot to avoid displaying itreturncm_display.figure_, "Test Description - Confusion Matrix", pd.DataFrame({"Value": [1, 2, 3]}) # return the figure object itself
This pull request introduces enhancements to the custom test framework by allowing users to define custom descriptions for their tests. The changes include:
Notebook Update: A new section titled 'Custom Test: Description' has been added to the implement_custom_tests.ipynb notebook. This section demonstrates how to write a custom test that returns a string description, specifically for a confusion matrix in a binary classification model.
Output Handling: A new StringOutputHandler class has been introduced in validmind/tests/output.py. This handler processes string outputs, converting them to HTML if they are not already in HTML format, and assigns them to the test result's description.
Test Result Description Logic: Modifications in validmind/tests/run.py ensure that a custom description is used if provided. If no custom description is available, the system generates one using existing logic.
Logging Enhancements: The logging logic in validmind/vm_models/result/result.py has been updated to include descriptions in the logging process if they are present, alongside tables and figures.
Test Suggestions
Test the new custom test description feature by creating a test that returns a string description and verify it appears correctly in the UI.
Ensure that the StringOutputHandler correctly processes and converts markdown strings to HTML.
Verify that existing tests without custom descriptions still generate descriptions as expected.
Check that the logging functionality includes descriptions when they are present.
Test the backward compatibility by running existing tests to ensure no breakage occurs due to the new changes.
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
documentationImprovements or additions to documentationenhancementNew feature or requesthighlightFeature to be curated in the release notes
4 participants
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.
External Release Notes
We now support text output in test results.
If a test returns a string, it will be used as the test description. In such cases, the automatic generation of the test result description will be skipped, and the test output will be used directly.
Run test
Output