From b40b4a41fa467101698cf47d52a19ca9850e4263 Mon Sep 17 00:00:00 2001 From: AnnaXiong Date: Thu, 6 Jun 2024 15:51:56 -0400 Subject: [PATCH 1/6] delete return_all_text --- vizro-ai/src/vizro_ai/_vizro_ai.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/vizro-ai/src/vizro_ai/_vizro_ai.py b/vizro-ai/src/vizro_ai/_vizro_ai.py index fabc07f12..bca23cf3e 100644 --- a/vizro-ai/src/vizro_ai/_vizro_ai.py +++ b/vizro-ai/src/vizro_ai/_vizro_ai.py @@ -1,5 +1,4 @@ import logging -from dataclasses import asdict from typing import Any, Optional, Union import pandas as pd @@ -25,7 +24,6 @@ class VizroAI: """Vizro-AI main class.""" pipeline_manager: PipelineManager = PipelineManager() - _return_all_text: bool = False # TODO deleted after adding new integration test def __init__(self, model: Optional[Union[ChatOpenAI, str]] = None): """Initialization of VizroAI. @@ -153,10 +151,4 @@ def plot( # pylint: disable=too-many-arguments # noqa: PLR0913 code_explain=vizro_plot.code_explanation, ) - # TODO Tentative for integration test, will be updated/removed for new tests - if self._return_all_text: - output_dict = asdict(vizro_plot) - output_dict["code_string"] = vizro_plot.code - return output_dict - return vizro_plot if return_elements else vizro_plot.figure From 4ad580b1659f7203f03934aa4f650d11eaf641a2 Mon Sep 17 00:00:00 2001 From: AnnaXiong Date: Thu, 6 Jun 2024 15:52:07 -0400 Subject: [PATCH 2/6] update integration test for dataclass --- vizro-ai/tests/integration/test_example.py | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/vizro-ai/tests/integration/test_example.py b/vizro-ai/tests/integration/test_example.py index a81ddb79b..1af308ee1 100644 --- a/vizro-ai/tests/integration/test_example.py +++ b/vizro-ai/tests/integration/test_example.py @@ -7,37 +7,41 @@ def test_chart(): - vizro_ai._return_all_text = True - resp = vizro_ai.plot(df, "describe the composition of scatter chart with gdp in continent") + resp = vizro_ai.plot( + df=df, + user_input="describe the composition of scatter chart with gdp in continent", + explain=False, + return_elements=True, + ) assert_that( - resp["code_string"], + resp.code, all_of(contains_string("px.scatter")), ) assert_that( - resp["code_string"], + resp.code, any_of(contains_string("x='continent'"), contains_string("x='gdpPercap'")), ) assert_that( - resp["code_string"], + resp.code, any_of(contains_string("y='count'"), contains_string("y='gdpPercap'"), contains_string("y='continent'")), ) - assert_that(resp["business_insights"], equal_to(None)) - assert_that(resp["code_explanation"], equal_to(None)) + assert_that(resp.code_explanationo, equal_to(None)) + assert_that(resp.business_insights, equal_to(None)) def test_chart_with_explanation(): vizro_ai._return_all_text = True - resp = vizro_ai.plot(df, "describe the composition of gdp in US", explain=True) + resp = vizro_ai.plot(df, "describe the composition of gdp in US", explain=True, return_elements=True) assert_that( - resp["code_string"], + resp.code, all_of(contains_string("px.bar"), contains_string("x='year'")), ) assert_that( - resp["code_string"], + resp.code, any_of(contains_string("y='gdpPercap'"), contains_string("y='total_gdp'")), ) assert_that( - resp["business_insights"], + resp.business_insights, any_of( contains_string("GDP per capita in the United States"), contains_string("GDP in the United States"), @@ -45,6 +49,6 @@ def test_chart_with_explanation(): ), ) assert_that( - resp["code_explanation"], + resp.code_explanation, all_of(contains_string("https://vizro.readthedocs.io/en/stable/pages/user_guides/custom_charts/")), ) From c4220cbce936900c0cea8ea064545bfae05b7d1e Mon Sep 17 00:00:00 2001 From: AnnaXiong Date: Thu, 6 Jun 2024 15:52:16 -0400 Subject: [PATCH 3/6] changelog --- ..._xiong_update_vizro_ai_integration_test.md | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 vizro-ai/changelog.d/20240606_155107_anna_xiong_update_vizro_ai_integration_test.md diff --git a/vizro-ai/changelog.d/20240606_155107_anna_xiong_update_vizro_ai_integration_test.md b/vizro-ai/changelog.d/20240606_155107_anna_xiong_update_vizro_ai_integration_test.md new file mode 100644 index 000000000..f1f65e73c --- /dev/null +++ b/vizro-ai/changelog.d/20240606_155107_anna_xiong_update_vizro_ai_integration_test.md @@ -0,0 +1,48 @@ + + + + + + + + + From 67c019154b49e76fb69dca729b7c9e506aae9467 Mon Sep 17 00:00:00 2001 From: AnnaXiong Date: Thu, 6 Jun 2024 17:48:47 -0400 Subject: [PATCH 4/6] fix --- vizro-ai/tests/integration/test_example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vizro-ai/tests/integration/test_example.py b/vizro-ai/tests/integration/test_example.py index 1af308ee1..5496d4ee3 100644 --- a/vizro-ai/tests/integration/test_example.py +++ b/vizro-ai/tests/integration/test_example.py @@ -25,7 +25,7 @@ def test_chart(): resp.code, any_of(contains_string("y='count'"), contains_string("y='gdpPercap'"), contains_string("y='continent'")), ) - assert_that(resp.code_explanationo, equal_to(None)) + assert_that(resp.code_explanation, equal_to(None)) assert_that(resp.business_insights, equal_to(None)) From 551609bc38ddd3d525f30c1db50a78adac1e1974 Mon Sep 17 00:00:00 2001 From: AnnaXiong Date: Tue, 18 Jun 2024 00:58:16 +0800 Subject: [PATCH 5/6] changelog --- ...606_155107_anna_xiong_update_vizro_ai_integration_test.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vizro-ai/changelog.d/20240606_155107_anna_xiong_update_vizro_ai_integration_test.md b/vizro-ai/changelog.d/20240606_155107_anna_xiong_update_vizro_ai_integration_test.md index f1f65e73c..e08b2f07c 100644 --- a/vizro-ai/changelog.d/20240606_155107_anna_xiong_update_vizro_ai_integration_test.md +++ b/vizro-ai/changelog.d/20240606_155107_anna_xiong_update_vizro_ai_integration_test.md @@ -10,12 +10,11 @@ Uncomment the section that is right (remove the HTML comment wrapper). - A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1)) --> -