Skip to content

Commit d33203c

Browse files
authored
Merge branch 'main' into feat/apply_vv_to_vizro_ai
2 parents d7c007e + 77c898b commit d33203c

File tree

89 files changed

+1673
-340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1673
-340
lines changed

.github/workflows/build-vizro-whl.yml

+24-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- main
99
paths:
1010
- "vizro-core/**"
11-
- "vizro-ai/examples/**"
11+
- "vizro-ai/**"
1212

1313
defaults:
1414
run:
@@ -30,25 +30,44 @@ jobs:
3030
run: pip install hatch
3131
- name: Build vizro-core package
3232
run: hatch build -t wheel
33-
- name: Upload artifact
33+
- name: Upload vizro-core artifact
3434
uses: actions/upload-artifact@v4
3535
with:
3636
name: pip
3737
path: vizro-core/dist/*.whl
3838
retention-days: 14
39+
- name: Build vizro-ai package
40+
working-directory: vizro-ai
41+
run: hatch build -t wheel
42+
- name: Upload vizro-ai artifact
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: pip2
46+
path: vizro-ai/dist/*.whl
47+
retention-days: 14
3948
# The below can be commented out in order to dry run the test creation of the PyCafe links
4049
# Once satisfied, comment them again, because the actual links will be created by the pycafe-dashboards.yml workflow
4150
# which is run from the main branch
4251
############### Start of PyCafe links creation ###############
52+
# - name: Install Playwright and browser
53+
# run: |
54+
# hatch run pip install playwright
55+
# hatch run playwright install --with-deps chromium
56+
# - name: Install vizro-ai in editable mode # This makes vizro-ai present in env to get the version
57+
# run: |
58+
# hatch run pip install -e ../vizro-ai
4359
# - name: Print PR Number
4460
# run: |
4561
# echo "Pull Request Number: ${{ github.event.workflow_run.pull_requests[0].number }}"
62+
# - name: Test PyCafe links
63+
# run: |
64+
# hatch run python ../tools/pycafe/test_pycafe_links.py --github-token ${{ github.token }} --repo-name ${{ github.repository }} --run-id ${{ github.run_id }} --commit-sha ${{ github.sha }}
4665
# - name: Create PyCafe links
4766
# run: |
4867
# PR_NUMBER=${{ github.event.workflow_run.pull_requests[0].number || '' }}
4968
# if [ -n "$PR_NUMBER" ]; then
50-
# hatch run python ../tools/pycafe/create_pycafe_links.py --github-token ${{ github.token }} --repo-name ${{ github.repository }} --pr-number $PR_NUMBER --run-id ${{ github.run_id }} --commit-sha ${{ github.sha }}
69+
# hatch run python ../tools/pycafe/create_pycafe_links_comments.py --github-token ${{ github.token }} --repo-name ${{ github.repository }} --pr-number $PR_NUMBER --run-id ${{ github.run_id }} --commit-sha ${{ github.sha }}
5170
# else
52-
# hatch run python ../tools/pycafe/create_pycafe_links.py --github-token ${{ github.token }} --repo-name ${{ github.repository }} --run-id ${{ github.run_id }} --commit-sha ${{ github.sha }}
71+
# hatch run python ../tools/pycafe/create_pycafe_links_comments.py --github-token ${{ github.token }} --repo-name ${{ github.repository }} --run-id ${{ github.run_id }} --commit-sha ${{ github.sha }}
5372
# fi
54-
############### End of PyCafe links creation ###############
73+
############## End of PyCafe links creation ###############

.github/workflows/checks-vizro-ai.yml

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
- name: Show dependency tree
4242
run: hatch run pip tree
4343

44+
- name: Install vizro-core to check compatibility with vizro-ai
45+
run: hatch run pip install ../vizro-core
46+
4447
- name: Find changed files to see if changelog fragment needed
4548
id: changed-files
4649
if: ${{ github.event_name == 'pull_request' }}

.github/workflows/checks-vizro-core.yml

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ jobs:
4747
- name: Check plotly template is up to date
4848
run: hatch run templates-check
4949

50+
- name: Install vizro-ai to check compatibility with vizro-core
51+
run: hatch run pip install ../vizro-ai
52+
5053
- name: Find changed files to see if changelog fragment needed
5154
id: changed-files
5255
if: ${{ github.event_name == 'pull_request' }}

.github/workflows/pycafe-dashboards.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PyCafe Playground Link
1+
name: PyCafe Playground Links
22

33
on:
44
workflow_run:
@@ -27,10 +27,14 @@ jobs:
2727
run: |
2828
hatch run pip install playwright
2929
hatch run playwright install --with-deps chromium
30+
# Below: only to have access to vizro-ai latest version in the test_pycafe_links.py and create_pycafe_links_comments.py scripts
31+
- name: Install vizro-ai in editable mode to check compatibility with vizro-core and get the version
32+
run: |
33+
hatch run pip install ../vizro-ai
3034
- name: Print PR Number
3135
run: |
3236
echo "Pull Request Number: ${{ github.event.workflow_run.pull_requests[0].number }}"
33-
- name: Test PyCafe links # Eventually we should merge this with the create_pycafe_links_comments.py script
37+
- name: Test if PyCafe links work with PR # Eventually we should merge this with the create_pycafe_links_comments.py script
3438
run: |
3539
hatch run python ../tools/pycafe/test_pycafe_links.py --github-token ${{ github.token }} --repo-name ${{ github.repository }} --run-id ${{ github.event.workflow_run.id }} --commit-sha ${{ github.event.workflow_run.head_sha }}
3640
- name: Create PyCafe links

tools/pycafe/pycafe_utils.py

+32-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import requests
1212
import vizro
13+
import vizro_ai
1314
from github import Auth, Github
1415
from github.Commit import Commit
1516
from github.Repository import Repository
@@ -27,6 +28,7 @@ class PyCafeConfig:
2728
pycafe_url: str = "https://py.cafe"
2829
vizro_raw_url: str = "https://raw.githubusercontent.com/mckinsey/vizro"
2930
package_version: str = vizro.__version__
31+
vizro_ai_package_version: str = vizro_ai.__version__
3032

3133

3234
def create_github_client(config: PyCafeConfig) -> tuple[Repository, Commit]:
@@ -48,6 +50,16 @@ def _get_vizro_requirement(config: PyCafeConfig, use_latest_release: bool = Fals
4850
)
4951

5052

53+
def _get_vizro_ai_requirement(config: PyCafeConfig, use_latest_release: bool = False) -> str:
54+
"""Get the Vizro AI requirement string for PyCafe."""
55+
if use_latest_release:
56+
return "vizro-ai"
57+
return (
58+
f"{config.pycafe_url}/gh/artifact/mckinsey/vizro/actions/runs/{config.run_id}/"
59+
f"pip2/vizro_ai-{config.vizro_ai_package_version}-py3-none-any.whl"
60+
)
61+
62+
5163
def _fetch_app_content(base_url: str) -> str:
5264
"""Fetch and process app.py content from the repository."""
5365
response = requests.get(f"{base_url}/app.py", timeout=10)
@@ -80,12 +92,18 @@ def generate_link(
8092
base_url = f"{config.vizro_raw_url}/{config.commit_sha}/{directory_path}"
8193

8294
# Requirements - either use latest release or commit's wheel file
83-
requirements = "\n".join(
84-
[
85-
_get_vizro_requirement(config, use_latest_release),
86-
*(extra_requirements or []),
87-
]
88-
)
95+
requirements = []
96+
if directory_path.startswith("vizro-ai/"):
97+
# An example in this folder may require the latest vizro-ai and vizro-core releases
98+
requirements.extend(
99+
[_get_vizro_ai_requirement(config, use_latest_release), _get_vizro_requirement(config, use_latest_release)]
100+
)
101+
else:
102+
# All other examples do not require vizro-ai, but still the latest vizro-core release
103+
requirements.extend([_get_vizro_requirement(config, use_latest_release)])
104+
105+
if extra_requirements:
106+
requirements.extend(extra_requirements)
89107

90108
# App file - get current commit, and modify to remove if clause
91109
app_content = _fetch_app_content(base_url)
@@ -96,7 +114,7 @@ def generate_link(
96114
# JSON object
97115
json_object = {
98116
"code": app_content,
99-
"requirements": requirements,
117+
"requirements": "\n".join(requirements),
100118
"files": [
101119
{
102120
"name": file["path"].removeprefix(f"{directory_path}"),
@@ -125,9 +143,14 @@ def generate_comparison_links(
125143
}
126144

127145

128-
def create_status_check(commit: Commit, directory: str, url: str, state: str = "success"):
146+
def create_status_check(
147+
commit: Commit,
148+
directory: str,
149+
url: str,
150+
state: str = "success",
151+
description: str = "Test out the app live on PyCafe",
152+
):
129153
"""Create a GitHub status check for a PyCafe link."""
130-
description = "Test out the app live on PyCafe"
131154
context = f"PyCafe Example ({directory})"
132155
commit.create_status(state=state, target_url=url, description=description, context=context)
133156
print(f"Status created for {context} with URL: {url}") # noqa
@@ -146,7 +169,6 @@ def get_example_directories() -> dict[str, Optional[list[str]]]:
146169
],
147170
"vizro-core/examples/tutorial/": None,
148171
"vizro-ai/examples/dashboard_ui/": [
149-
"vizro-ai>=0.3.0",
150172
"black",
151173
"openpyxl",
152174
"langchain_anthropic",

tools/pycafe/test_pycafe_links.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,19 @@ def test_pycafe_link(url: str, wait_for_text: str):
1919
page = browser.new_page()
2020

2121
try:
22-
# Navigate to the page and wait for network to be idle
23-
page.goto(url, wait_until="networkidle")
22+
# Navigate to the page
23+
page.goto(url, timeout=60000)
2424

2525
# Get the app frame and wait for title
2626
frame = page.frame_locator("#app")
27-
frame.get_by_text(wait_for_text).wait_for()
27+
frame.get_by_text(wait_for_text).wait_for(timeout=90000)
2828

2929
print(f"✅ Successfully verified PyCafe link: {url}") # noqa
3030
return True
3131

3232
except Exception as e:
33-
print(f"❌ Failed to verify PyCafe link: {url}") # noqa
33+
print("❌ Failed to verify PyCafe link") # noqa
3434
print(f"Error: {str(e)}") # noqa
35-
page.screenshot(path="pycafe_error.png")
3635
return False
3736

3837
finally:
@@ -71,7 +70,13 @@ def test_pycafe_link(url: str, wait_for_text: str):
7170
# Only create a status check if the test fails. On success, the status check will be created
7271
# by the create_pycafe_links_comments.py script when it posts the comment.
7372
if not success:
74-
create_status_check(commit, dev_directory, url_generated, state="failure")
73+
create_status_check(
74+
commit,
75+
dev_directory,
76+
url_generated,
77+
state="failure",
78+
description="Check if PyCafe links load properly (using vizro-core dev example)",
79+
)
7580

7681
# Exit with appropriate status code
7782
sys.exit(0 if success else 1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!--
2+
A new scriv changelog fragment.
3+
4+
Uncomment the section that is right (remove the HTML comment wrapper).
5+
-->
6+
7+
<!--
8+
### Highlights ✨
9+
10+
- 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))
11+
12+
-->
13+
<!--
14+
### Removed
15+
16+
- 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))
17+
18+
-->
19+
### Added
20+
21+
- `DatePicker` filters update automatically when underlying dynamic data changes. See the [user guide on dynamic filters](https://vizro.readthedocs.io/en/stable/pages/user-guides/data/#filters) for more information. ([#1039](https://github.com/mckinsey/vizro/pull/1039))
22+
23+
<!--
24+
### Changed
25+
26+
- 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))
27+
28+
-->
29+
<!--
30+
### Deprecated
31+
32+
- 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))
33+
34+
-->
35+
<!--
36+
### Fixed
37+
38+
- 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))
39+
40+
-->
41+
<!--
42+
### Security
43+
44+
- 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))
45+
46+
-->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!--
2+
A new scriv changelog fragment.
3+
4+
Uncomment the section that is right (remove the HTML comment wrapper).
5+
-->
6+
7+
<!--
8+
### Highlights ✨
9+
10+
- 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))
11+
12+
-->
13+
<!--
14+
### Removed
15+
16+
- 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))
17+
18+
-->
19+
20+
### Added
21+
22+
- Add `extra` argument to selected models to enable passing arguments directly to the underlying Dash component. ([#1032](https://github.com/mckinsey/vizro/pull/1032))
23+
24+
25+
<!--
26+
### Changed
27+
28+
- 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))
29+
30+
-->
31+
<!--
32+
### Deprecated
33+
34+
- 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))
35+
36+
-->
37+
<!--
38+
### Fixed
39+
40+
- 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))
41+
42+
-->
43+
<!--
44+
### Security
45+
46+
- 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))
47+
48+
-->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!--
2+
A new scriv changelog fragment.
3+
4+
Uncomment the section that is right (remove the HTML comment wrapper).
5+
-->
6+
7+
<!--
8+
### Highlights ✨
9+
10+
- 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))
11+
12+
-->
13+
<!--
14+
### Removed
15+
16+
- 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))
17+
18+
-->
19+
<!--
20+
### Added
21+
22+
- 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))
23+
24+
-->
25+
26+
### Changed
27+
28+
- Turn `AgGrid` background transparent. ([#1047](https://github.com/mckinsey/vizro/pull/1047))
29+
30+
31+
<!--
32+
### Deprecated
33+
34+
- 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))
35+
36+
-->
37+
<!--
38+
### Fixed
39+
40+
- 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))
41+
42+
-->
43+
<!--
44+
### Security
45+
46+
- 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))
47+
48+
-->

0 commit comments

Comments
 (0)