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

react implementation of interactive web-ui #246

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
16 changes: 14 additions & 2 deletions .github/workflows/integration_delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,18 @@ jobs:
fi
cat ubo_app/.env

- uses: actions/setup-node@v4
name: Setup Node
with:
node-version: '20'

- name: Build Web Application
run: |
cd ubo_app/services/090-web-ui/web-app
npm install
npm run proto:compile
npm run build

- name: Build
env:
SETUPTOOLS_SCM_PRETEND_VERSION:
Expand Down Expand Up @@ -312,9 +324,9 @@ jobs:
echo "image_url=$IMAGE_URL" >>"$GITHUB_OUTPUT"
echo "image_name=$IMAGE_NAME" >>"$GITHUB_OUTPUT"
echo "image_checksum_url=$CHECKSUM_URL" >>"$GITHUB_OUTPUT"
if $MATRIX_SUFFIX == 'lite'; then
if [ "$MATRIX_SUFFIX" = "lite" ]; then
IMAGE_SIZE_GB=4.5
elif $MATRIX_SUFFIX == ''; then
elif [ "$MATRIX_SUFFIX" = "" ]; then
IMAGE_SIZE_GB=6.75
else
IMAGE_SIZE_GB=13
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ jobs:
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
echo "VERSION=$(uvx hatch version)" >>"$GITHUB_OUTPUT"
echo "VERSION=$(uvx hatch version)"
VERSION=$(uvx hatch version | sed 's/\.dev.*//')
echo "VERSION=$VERSION" >>"$GITHUB_OUTPUT"
echo "VERSION=$VERSION"
- name: Create Release Tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "Ubo Admin"
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

- fix: remove dependencies of `publish` job of `publish_to_pypi` workflow
- fix: vscode binary now needs to be instructed about the location of the binary with `version use` sub-command - closes #217
- fix: image size being too big for the lite version of the raspberry os
- fix: restart avahi-daemon after the hostname is set in `ubo-system`
- feat(web-ui): implement react web application for the web-ui service - closes #224
- refactor(web-ui): use mui dialogs for input demands - closes #224
- chore(web-ui): add linting and formatting to the web application code - closes #224
- refactor(web-ui): use webaudio for audio playback in the web application and add an unmute button - closes #224
- feat(web-ui): add side buttons layout, and handle swipe gestures for the web application - closes #224

## Version 1.2.2

Expand Down
104 changes: 50 additions & 54 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,44 @@ readme = "README.md"
requires-python = ">=3.11, <3.12"
keywords = ['ubo', 'ubo-pod', 'raspberry pi', 'rpi', 'home assistance']
dependencies = [
"aiohttp >=3.9.1",
"dill >=0.3.8",
"aiohttp>=3.9.1",
"dill>=0.3.8",
"docker>=7.1.0",
"headless-kivy >=0.12.2",
"headless-kivy>=0.12.2",
"netifaces>=0.11.0",
"platformdirs >=4.2.0",
"psutil >=6.0.0",
"pulsectl >=23.5.2",
"pvorca >=0.2.1",
"platformdirs>=4.2.0",
"psutil>=6.0.0",
"pulsectl>=23.5.2",
"pvorca>=0.2.1",
"pypng>=0.20220715.0",
"python-debouncer >=0.1.5",
"python-dotenv >=1.0.1",
"python-fake >=0.1.3",
"python-redux >=0.18.3",
"python-strtobool >=1.0.0",
"pythonping >=1.1.4",
"pyzbar >=0.1.9",
"quart >=0.19.6",
"rpi_ws281x >=5.0.0 ; platform_machine=='aarch64'",
"sdbus-networkmanager >=2.0.0 ; platform_machine=='aarch64'",
"semver >=3.0.2",
"sentry-sdk >=1.43.0",
"simpleaudio >=1.0.4",
"tenacity >=8.2.3",
"ubo-gui >=0.13.10",
"python-debouncer>=0.1.5",
"python-dotenv>=1.0.1",
"python-fake>=0.1.3",
"python-redux>=0.19.1",
"python-strtobool>=1.0.0",
"pythonping>=1.1.4",
"pyzbar>=0.1.9",
"quart>=0.19.6",
"rpi_ws281x>=5.0.0 ; platform_machine=='aarch64'",
"sdbus-networkmanager>=2.0.0 ; platform_machine=='aarch64'",
"semver>=3.0.2",
"sentry-sdk>=1.43.0",
"simpleaudio>=1.0.4",
"tenacity>=8.2.3",
"ubo-gui>=0.13.10",
# Adafruit dependencies
"adafruit-circuitpython-aw9523 >=1.1.7",
"adafruit-circuitpython-neopixel >=6.3.11",
"adafruit-circuitpython-pct2075 >=1.1.21",
"adafruit-circuitpython-rgb-display >=3.11.0",
"adafruit-circuitpython-veml7700 >=1.1.22",
"adafruit-circuitpython-aw9523>=1.1.7",
"adafruit-circuitpython-neopixel>=6.3.11",
"adafruit-circuitpython-pct2075>=1.1.21",
"adafruit-circuitpython-rgb-display>=3.11.0",
"adafruit-circuitpython-veml7700>=1.1.22",
# RPi dependencies
"fasteners >=0.19",
"piper-tts >=1.2.0 ; sys_platform=='linux'",
"rpi-lgpio >=0.6 ; platform_machine=='aarch64'",
"fasteners>=0.19",
"piper-tts>=1.2.0 ; sys_platform=='linux'",
"rpi-lgpio>=0.6 ; platform_machine=='aarch64'",
# gRPC
"betterproto [compiler] >=2.0.0b7",
"gpiozero >=2.0.1 ; platform_machine != 'aarch64'",
"betterproto [compiler]>=2.0.0b7",
"gpiozero>=2.0.1 ; platform_machine != 'aarch64'",
]

[build-system]
Expand All @@ -64,32 +64,27 @@ local_scheme = "setup_scm_schemes:local_scheme"

[tool.hatch.build]
packages = ["ubo_app"]

[tool.hatch.build.targets.sdist]
packages = ["ubo_app"]
exclude = ["ubo_app/services/090-web-ui/web-app/node_modules"]
artifacts = ["ubo_app/services/090-web-ui/web-app/dist"]

[tool.uv]
dev-dependencies = [
"grpcio-tools >=1.66.1",
"headless-kivy [test] >=0.12.1",
"ipython >=8.23.0",
"poethepoet >=0.24.4",
"pyfakefs >=5.7.4",
"pyright >=1.1.389",
"pytest >=8.0.0",
"pytest-asyncio >=0.23.5.post1",
"pytest-cov >=4.1.0",
"pytest-mock >=3.14.0",
"pytest-timeout >=2.3.1",
"pytest-xdist >=3.5.0",
"ruff >=0.9.6",
"toml >=0.10.2",
"grpcio-tools>=1.66.1",
"headless-kivy [test]>=0.12.1",
"ipython>=8.23.0",
"poethepoet>=0.24.4",
"pyfakefs>=5.7.4",
"pyright>=1.1.395",
"pytest>=8.0.0",
"pytest-asyncio>=0.23.5.post1",
"pytest-cov>=4.1.0",
"pytest-mock>=3.14.0",
"pytest-timeout>=2.3.1",
"pytest-xdist>=3.5.0",
"ruff>=0.9.6",
"toml>=0.10.2",
]


[tool.uv.sources]
pyfakefs = { git = "https://github.com/pytest-dev/pyfakefs.git" }

[project.scripts]
ubo = "ubo_app.main:main"
ubo-bootstrap = "ubo_app.system.bootstrap:main"
Expand All @@ -105,8 +100,9 @@ typecheck = "pyright -p pyproject.toml ."
test = "pytest --cov=ubo_app"
sanity = ["typecheck", "lint", "test"]
build-docker-images = "sh -c 'docker buildx build . -f scripts/Dockerfile.dev -t ubo-app-dev && docker buildx build . -f scripts/Dockerfile.test -t ubo-app-test'"
build-web-app = "sh -c 'cd ubo_app/services/090-web-ui/web-app/ && npm install --include=dev && npm run compile && npm run build'"

"proto:generate:raw" = "python ubo_app/rpc/generate_proto.py"
"proto:generate:raw" = "python ubo_app/rpc/generator/generate_proto.py"
"proto:generate" = ["proto:generate:raw", "proto:lint"]
"proto:compile:raw" = "sh -c 'mkdir -p ubo_app/rpc/generated && python -m grpc_tools.protoc -I ubo_app/rpc/proto/ --python_betterproto_opt=typing.310 --python_betterproto_out=ubo_app/rpc/generated/ ubo_app/rpc/proto/store/v1/store.proto'"
"proto:compile" = ["proto:compile:raw", "lint:fix"]
Expand Down
4 changes: 2 additions & 2 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -o nounset

# Signal handler
function cleanup() {
perl -i -pe 's/^exclude = .*-voice\/models.*\n//' pyproject.toml
perl -i -pe 's/^exclude = \["ubo_app\/services\/\*-voice\/models\/\*", (.*)\]$/exclude = [\1]/' pyproject.toml
}
trap cleanup ERR
trap cleanup EXIT
Expand All @@ -17,7 +17,7 @@ kill=${kill:-"False"}
restart=${restart:-"False"}
env=${env:-"False"}

perl -i -pe 's/^(packages = \[.*)$/\1\nexclude = ["ubo_app\/services\/*-voice\/models\/*"]/' pyproject.toml
perl -i -pe 's/^exclude = \[(.*)\]$/exclude = ["ubo_app\/services\/*-voice\/models\/*", \1]/' pyproject.toml
uv build
cleanup
LATEST_VERSION=$(basename $(ls -rt dist/*.whl | tail -n 1))
Expand Down
2 changes: 1 addition & 1 deletion ubo_app/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
GRPC_LISTEN_ADDRESS = os.environ.get('UBO_GRPC_LISTEN_ADDRESS', '127.0.0.1')
GRPC_LISTEN_PORT = int(os.environ.get('UBO_GRPC_LISTEN_PORT', '50051'))

GRPC_ENVOY_LISTEN_ADDRESS = os.environ.get('UBO_GRPC_ENVOY_LISTEN_ADDRESS', '127.0.0.1')
GRPC_ENVOY_LISTEN_ADDRESS = os.environ.get('UBO_GRPC_ENVOY_LISTEN_ADDRESS', '0.0.0.0') # noqa: S104
GRPC_ENVOY_LISTEN_PORT = int(os.environ.get('UBO_GRPC_ENVOY_LISTEN_PORT', '50052'))

# Most of these should be changed in ubo-app and ubo-system-manager simultaneously to
Expand Down
36 changes: 24 additions & 12 deletions ubo_app/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,33 @@ def render_on_display(*, regions: list[Region]) -> None:
),
data_bytes,
)

from kivy.metrics import dp

density = dp(1)

def generate_render_actions(
region: Region,
) -> tuple[DisplayRenderEvent, DisplayCompressedRenderEvent]:
data = region['data'].tobytes()
compressor = zlib.compressobj(wbits=-zlib.MAX_WBITS)
store._dispatch( # noqa: SLF001
[
DisplayRenderEvent(
data=region['data'].tobytes(),
rectangle=rectangle,
),
DisplayCompressedRenderEvent(
compressed_data=compressor.compress(region['data'].tobytes())
+ compressor.flush(),
rectangle=rectangle,
),
],
return (
DisplayRenderEvent(
data=data,
rectangle=region['rectangle'],
density=density,
),
DisplayCompressedRenderEvent(
compressed_data=compressor.compress(data) + compressor.flush(),
rectangle=region['rectangle'],
density=density,
),
)

store._dispatch( # noqa: SLF001
[event for region in regions for event in generate_render_actions(region)],
)


original_block = display._block # noqa: SLF001

Expand Down
Loading
Loading