-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from glue-viz/fully-automated
Add ability to run in fully automated mode
- Loading branch information
Showing
19 changed files
with
556 additions
and
112 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" # See documentation for possible values | ||
directory: ".github/workflows" # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
groups: | ||
actions: | ||
patterns: | ||
- "*" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Automated test | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
|
||
jobs: | ||
test: | ||
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1 | ||
with: | ||
envs: | | ||
- linux: py310-test | ||
- linux: py311-test | ||
- linux: py312-test | ||
- linux: py313-test | ||
- macos: py310-test | ||
- macos: py311-test | ||
- macos: py312-test | ||
- macos: py313-test | ||
- windows: py312-test | ||
- windows: py313-test |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ __pycache__ | |
dist | ||
build | ||
.ipynb_checkpoints | ||
__pycache__ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
ci: | ||
autofix_prs: false | ||
autoupdate_schedule: 'monthly' | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: check-added-large-files | ||
args: ["--enforce-all", "--maxkb=300"] | ||
- id: check-case-conflict | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: check-toml | ||
- id: check-xml | ||
- id: check-yaml | ||
exclude: ".*(.github.*)$" | ||
- id: detect-private-key | ||
- id: end-of-file-fixer | ||
exclude: ".*(data.*|extern.*|licenses.*|_static.*|_parsetab.py)$" | ||
- id: trailing-whitespace | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: "v0.3.4" | ||
hooks: | ||
- id: ruff | ||
args: ["--fix", "--show-fixes"] | ||
- id: ruff-format |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
from ._monitor import monitor | ||
from ._version import __version__ | ||
|
||
__all__ = ["monitor", "__version__"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from ._monitor import monitor | ||
|
||
if __name__ == "__main__": | ||
monitor() |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Experimental command to convert a notebook to a script that tests widget | ||
# output with solara but without launching a Jupyter Lab instance. Not yet | ||
# exposed via the public API. | ||
|
||
import os | ||
from textwrap import indent | ||
|
||
import click | ||
import nbformat | ||
|
||
|
||
def remove_magics(source): | ||
lines = [line for line in source.splitlines() if not line.startswith("%")] | ||
return os.linesep.join(lines) | ||
|
||
|
||
def remove_excludes(source): | ||
lines = [ | ||
line for line in source.splitlines() if not line.strip().endswith("# EXCLUDE") | ||
] | ||
return os.linesep.join(lines) | ||
|
||
|
||
HEADER = """ | ||
import time | ||
import solara | ||
import playwright | ||
import pytest_playwright | ||
from IPython.display import display | ||
def watch_screenshot(widget): | ||
display_start = time.time() | ||
last_change_time = display_start | ||
last_screenshot = None | ||
while time.time() - display_start < 5: | ||
screenshot_bytes = widget.screenshot() | ||
if screenshot_bytes != last_screenshot: | ||
last_screenshot = screenshot_bytes | ||
last_change_time = time.time() | ||
return last_screenshot, last_change_time - display_start | ||
def test_main(page_session, solara_test): | ||
""" | ||
|
||
DISPLAY_CODE = """ | ||
object_to_capture.add_class("test-object") | ||
display(object_to_capture) | ||
captured_object = page_session.locator(".test-object") | ||
captured_object.wait_for() | ||
""" | ||
|
||
PROFILING_CODE = """ | ||
last_screenshot, time_elapsed = watch_screenshot(captured_object) | ||
print(f"Extra time waiting for display to update: {time_elapsed:.2f}s") | ||
""" | ||
|
||
|
||
@click.command() | ||
@click.argument("input_notebook") | ||
@click.argument("output_script") | ||
def convert(input_notebook, output_script): | ||
nb = nbformat.read(input_notebook, as_version=4) | ||
|
||
with open(output_script, "w") as f: | ||
f.write(HEADER) | ||
|
||
captured = False | ||
|
||
for icell, cell in enumerate(nb["cells"]): | ||
if cell.cell_type == "markdown": | ||
f.write(indent(cell.source, " # ") + "\n\n") | ||
elif cell.cell_type == "code": | ||
if cell.source.strip() == "": | ||
continue | ||
|
||
lines = cell.source.splitlines() | ||
|
||
new_lines = [] | ||
|
||
new_lines.append("cell_start = time.time()\n\n") | ||
|
||
for line in lines: | ||
if line.startswith("%") or line.strip().endswith("# EXCLUDE"): | ||
continue | ||
elif line.endswith("# SCREENSHOT"): | ||
new_lines.append("object_to_capture = " + line) | ||
new_lines.extend(DISPLAY_CODE.splitlines()) | ||
captured = True | ||
else: | ||
new_lines.append(line) | ||
|
||
new_lines.append("cell_end = time.time()\n") | ||
new_lines.append( | ||
f'print(f"Cell {icell:2d} Python code executed in {{cell_end - cell_start:.2f}}s")', | ||
) | ||
|
||
if captured: | ||
new_lines.extend(PROFILING_CODE.splitlines()) | ||
|
||
source = os.linesep.join(new_lines) | ||
|
||
f.write(indent(source, " ") + "\n\n") | ||
|
||
|
||
if __name__ == "__main__": | ||
convert() |
Oops, something went wrong.