Skip to content

Commit

Permalink
Small readibility improvment
Browse files Browse the repository at this point in the history
  • Loading branch information
maxschulz-COL committed Mar 6, 2025
1 parent 2d9e5ae commit d3fb90d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/pycafe-dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ jobs:
run: |
hatch run pip install playwright
hatch run playwright install --with-deps chromium
# The next step has several benefits:
# - we can verify that the vizro-ai version is compatible with the vizro-core version from the requirements perspective
# - we have access to both versions in the test_pycafe_links.py and create_pycafe_links_comments.py scripts
# Below: only to have access to vizro-ai latest version in the test_pycafe_links.py and create_pycafe_links_comments.py scripts
- name: Install vizro-ai in editable mode to check compatibility with vizro-core and get the version
run: |
hatch run pip install -e ../vizro-ai
Expand Down
9 changes: 7 additions & 2 deletions tools/pycafe/pycafe_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,14 @@ def generate_comparison_links(
}


def create_status_check(commit: Commit, directory: str, url: str, state: str = "success"):
def create_status_check(
commit: Commit,
directory: str,
url: str,
state: str = "success",
description: str = "Test out the app live on PyCafe",
):
"""Create a GitHub status check for a PyCafe link."""
description = "Test out the app live on PyCafe"
context = f"PyCafe Example ({directory})"
commit.create_status(state=state, target_url=url, description=description, context=context)
print(f"Status created for {context} with URL: {url}") # noqa
Expand Down
15 changes: 10 additions & 5 deletions tools/pycafe/test_pycafe_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def test_pycafe_link(url: str, wait_for_text: str):
page = browser.new_page()

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

# Get the app frame and wait for title
frame = page.frame_locator("#app")
Expand All @@ -30,9 +30,8 @@ def test_pycafe_link(url: str, wait_for_text: str):
return True

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

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

# Exit with appropriate status code
sys.exit(0 if success else 1)

0 comments on commit d3fb90d

Please sign in to comment.