Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QA] Score tests improvements #935

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions .github/workflows/test-score-vizro-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ defaults:
working-directory: vizro-ai

on:
schedule:
- cron: "30 10 * * 1" # run every Monday at 10:30 UTC
lingyielia marked this conversation as resolved.
Show resolved Hide resolved
workflow_dispatch:
#temporary for development
pull_request:
branches:
- main
Comment on lines +11 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to remove this before merging.


env:
PYTHONUNBUFFERED: 1
Expand All @@ -20,17 +26,8 @@ jobs:
fail-fast: false
matrix:
config:
- python-version: "3.9"
hatch-env: all.py3.9
- python-version: "3.10"
hatch-env: all.py3.10
- python-version: "3.11"
hatch-env: all.py3.11
- python-version: "3.12"
hatch-env: all.py3.12
- python-version: "3.9"
hatch-env: lower-bounds
label: lower bounds

steps:
- uses: actions/checkout@v4
Expand All @@ -46,17 +43,8 @@ jobs:
fail-fast: false
matrix:
config:
- python-version: "3.9"
hatch-env: all.py3.9
- python-version: "3.10"
hatch-env: all.py3.10
- python-version: "3.11"
hatch-env: all.py3.11
- python-version: "3.12"
hatch-env: all.py3.12
- python-version: "3.9"
hatch-env: lower-bounds
label: lower bounds

steps:
- uses: actions/checkout@v4
Expand All @@ -77,6 +65,8 @@ jobs:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_API_BASE: ${{ secrets.OPENAI_API_BASE }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
VIZRO_TYPE: pypi
BRANCH: ${{ github.head_ref }}
PYTHON_VERSION: ${{ matrix.config.python-version }}
Expand All @@ -88,6 +78,8 @@ jobs:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_API_BASE: ${{ secrets.OPENAI_API_BASE }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
VIZRO_TYPE: local
BRANCH: ${{ github.head_ref }}
PYTHON_VERSION: ${{ matrix.config.python-version }}
Expand Down Expand Up @@ -131,7 +123,8 @@ jobs:
- name: Create one csv report
run: |
cd /home/runner/work/vizro/vizro/
head -n 1 Report-3.11-/report_model_gpt-4o-mini_pypi.csv > report-aggregated-${{ steps.date.outputs.date }}.csv && tail -n+2 -q */*.csv >> report-aggregated-${{ steps.date.outputs.date }}.csv
ls */*.csv | head -n1 | xargs head -n1 > report-aggregated-${{ steps.date.outputs.date }}.csv && tail -n+2 -q */*.csv >> report-aggregated-${{ steps.date.outputs.date }}.csv
# replace all timestamps in aggregated report to current date
gawk -F, -i inplace 'FNR>1 {$1="${{ steps.date.outputs.date }}"} {print}' OFS=, report-aggregated-${{ steps.date.outputs.date }}.csv

- name: Report artifacts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨

- 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))

-->
<!--
### Removed

- A bullet item for the Removed 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))

-->
<!--
### Added

- A bullet item for the Added 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))

-->
<!--
### Changed

- A bullet item for the Changed 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))

-->
<!--
### Deprecated

- A bullet item for the Deprecated 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))

-->
<!--
### Fixed

- A bullet item for the Fixed 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))

-->
<!--
### Security

- A bullet item for the Security 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))

-->
2 changes: 1 addition & 1 deletion vizro-ai/hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ prep-release = [
pypath = "hatch run python -c 'import sys; print(sys.executable)'"
test = "pytest tests {args}"
test-integration = "pytest -vs --reruns 1 tests/integration --headless {args}"
test-score = "pytest -vs --reruns 1 tests/score --headless {args}"
test-score = "pytest -vs tests/score --headless {args}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would make sense to add a comment above on where to enter the API key. When I run the above command, then all tests fail, but only because the API key does not work

test-unit = "pytest tests/unit {args}"
test-unit-coverage = [
"coverage run -m pytest tests/unit {args}",
Expand Down
85 changes: 85 additions & 0 deletions vizro-ai/tests/score/prompts.py
lingyielia marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
easy_prompt = """
I need a page with 1 table, 1 card and 1 chart.
The table shows the tech companies stock data.
The card says 'The Gapminder dataset provides historical data on countries' development indicators.'
The chart is the scatter plot which uses gapminder dataframe and showing life expectancy vs. GDP per capita by country.
Life expectancy on the y axis, GDP per capita on the x axis, and colored by continent.

The layout uses a grid of 2 columns and 3 rows.
The first row contains card
The second row contains chart
The third row contains table

Add a filter to filter the scatter plot by continent.
Add a second filter to filter the table by companies.
"""

medium_prompt = """
<Page 1>
I need a page with 1 table and 1 line chart.
The chart shows the stock price trends of GOOG and AAPL.
The table shows the stock prices data details.

<Page 2>
I need a second page showing 3 cards and 4 charts.
The cards says 'The Gapminder dataset provides historical data on countries' development indicators.'
The charts are the scatter plots showing GDP per capita vs. life expectancy.
GDP per capita on the x axis, life expectancy on the y axis, and colored by continent.
Layout the cards on the left and the chart on the right.
Add a filter to filter the scatter plots by continent.
Add a second filter to filter the charts by year.

<Page 3>
This page displays the tips dataset. use four different charts to show data
distributions. one chart should be a bar chart. the other should be a scatter plot.
next chart should be a line chart. last one should be an area plot.
first and second charts are on the left and the third and fourth charts are on the right.
Add a filter to filter data in every plot by smoker.

<Page 4>
Create 3 cards on this page:
1. The first card on top says "This page combines data from various sources
including tips, stock prices, and global indicators."
2. The second card says "Insights from Gapminder dataset."
3. The third card says "Stock price trends over time."

Layout these 3 cards in this way:
create a grid with 3 columns and 2 rows.
Row 1: The first row has three columns:
- The first column is empty.
- The second and third columns span the area for card 1.

Row 2: The second row also has three columns:
- The first column is empty.
- The second column is occupied by the area for card 2.
- The third column is occupied by the area for card 3.
"""


complex_prompt = """
<Page 1>
Show me 1 table on the first page that shows tips and sorted by day
Using export button I want to export data to csv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that even possible @lingyielia? I am not sure the json schema for the button actually includes possible custom actions?

Add filters by bill and by tip amount using range slider

<Page 2>
Second page should contain kpi cards with population trends and
two popular charts that display population per capita vs. continent.
Filter charts by GDP using dropdown.
Align kpi cards in one row and charts in different.
Both charts should be in tabs.

<Page 3>
petar-qb marked this conversation as resolved.
Show resolved Hide resolved
Third page should contain 6 charts showing stocks.
Each should have separate filter by date.
Filter types should include dropdown, datepicker, slider, checklist and radio items.
Add parameter for any chart.

<Page 4>
petar-qb marked this conversation as resolved.
Show resolved Hide resolved
Fourth page contains chart with wind data.
Table with population data.
Two more charts with stocks and tips representations.
Align table beautifully relative to the charts.
Every chart should have 2 filters.
Table should have 1 filter.
"""
6 changes: 6 additions & 0 deletions vizro-ai/tests/score/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
markers =
easy_dashboard: mark test with easy prompt for dashboard creation.
medium_dashboard: mark test with medium prompt for dashboard creation.
complex_dashboard: mark test with complex prompt for dashboard creation.

filterwarnings =
ignore::UserWarning
# Ignore deprecation warning until this is solved: https://github.com/plotly/dash/issues/2590:
ignore:HTTPResponse.getheader():DeprecationWarning
Loading
Loading