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

Concurrent Renders #1165

Merged
merged 22 commits into from
Dec 9, 2023
Merged
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
108 changes: 54 additions & 54 deletions .github/workflows/.hatch-run.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
name: hatch-run

on:
workflow_call:
inputs:
job-name:
required: true
type: string
hatch-run:
required: true
type: string
runs-on-array:
required: false
type: string
default: '["ubuntu-latest"]'
python-version-array:
required: false
type: string
default: '["3.x"]'
node-registry-url:
required: false
type: string
default: ""
secrets:
node-auth-token:
required: false
pypi-username:
required: false
pypi-password:
required: false
workflow_call:
inputs:
job-name:
required: true
type: string
hatch-run:
required: true
type: string
runs-on-array:
required: false
type: string
default: '["ubuntu-latest"]'
python-version-array:
required: false
type: string
default: '["3.x"]'
node-registry-url:
required: false
type: string
default: ""
secrets:
node-auth-token:
required: false
pypi-username:
required: false
pypi-password:
required: false

jobs:
hatch:
name: ${{ format(inputs.job-name, matrix.python-version, matrix.runs-on) }}
strategy:
matrix:
python-version: ${{ fromJson(inputs.python-version-array) }}
runs-on: ${{ fromJson(inputs.runs-on-array) }}
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14.x"
registry-url: ${{ inputs.node-registry-url }}
- name: Pin NPM Version
run: npm install -g [email protected]
- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: pip install hatch poetry
- name: Run Scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.node-auth-token }}
PYPI_USERNAME: ${{ secrets.pypi-username }}
PYPI_PASSWORD: ${{ secrets.pypi-password }}
run: hatch run ${{ inputs.hatch-run }}
hatch:
name: ${{ format(inputs.job-name, matrix.python-version, matrix.runs-on) }}
strategy:
matrix:
python-version: ${{ fromJson(inputs.python-version-array) }}
runs-on: ${{ fromJson(inputs.runs-on-array) }}
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14.x"
registry-url: ${{ inputs.node-registry-url }}
- name: Pin NPM Version
run: npm install -g [email protected]
- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: pip install hatch poetry
- name: Run Scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.node-auth-token }}
PYPI_USERNAME: ${{ secrets.pypi-username }}
PYPI_PASSWORD: ${{ secrets.pypi-password }}
run: hatch run ${{ inputs.hatch-run }}
83 changes: 43 additions & 40 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
name: check

on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 0 * * 0"
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 0 * * 0"

jobs:
test-py-cov:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "python-{0}"
hatch-run: "test-py"
lint-py:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "python-{0}"
hatch-run: "lint-py"
test-py-matrix:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "python-{0} {1}"
hatch-run: "test-py --no-cov"
runs-on-array: '["ubuntu-latest", "macos-latest", "windows-latest"]'
python-version-array: '["3.9", "3.10", "3.11"]'
test-docs:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "python-{0}"
hatch-run: "test-docs"
test-js:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "{1}"
hatch-run: "test-js"
lint-js:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "{1}"
hatch-run: "lint-js"
test-py-cov:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "python-{0}"
hatch-run: "test-py"
lint-py:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "python-{0}"
hatch-run: "lint-py"
test-py-matrix:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "python-{0} {1}"
hatch-run: "test-py --no-cov"
runs-on-array: '["ubuntu-latest", "macos-latest", "windows-latest"]'
python-version-array: '["3.9", "3.10", "3.11"]'
test-docs:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "python-{0}"
hatch-run: "test-docs"
# as of Dec 2023 lxml does have wheels for 3.12
# https://bugs.launchpad.net/lxml/+bug/2040440
python-version-array: '["3.11"]'
test-js:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "{1}"
hatch-run: "test-js"
lint-js:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "{1}"
hatch-run: "lint-js"
6 changes: 6 additions & 0 deletions docs/source/about/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ Unreleased
- :pull:`1118` - `module_from_template` is broken with a recent release of `requests`
- :pull:`1131` - `module_from_template` did not work when using Flask backend

**Added**

- :pull:`1165` - Allow concurrent renders of discrete component tree - enable this
experimental feature by setting `REACTPY_ASYNC_RENDERING=true`. This should improve
the overall responsiveness of your app, particularly when handling larger renders
that would otherwise block faster renders from being processed.

v1.0.2
------
Expand Down
4 changes: 3 additions & 1 deletion src/py/reactpy/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ starlette = [
sanic = [
"sanic >=21",
"sanic-cors",
"tracerite>=1.1.1",
"setuptools",
"uvicorn[standard] >=0.19.0",
]
fastapi = [
Expand Down Expand Up @@ -80,7 +82,7 @@ pre-install-command = "hatch build --hooks-only"
dependencies = [
"coverage[toml]>=6.5",
"pytest",
"pytest-asyncio>=0.17",
"pytest-asyncio>=0.23",
"pytest-mock",
"pytest-rerunfailures",
"pytest-timeout",
Expand Down
7 changes: 6 additions & 1 deletion src/py/reactpy/reactpy/_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ def current(self) -> _O:
def current(self, new: _O) -> None:
self.set_current(new)

@current.deleter
def current(self) -> None:
self.unset()

def subscribe(self, handler: Callable[[_O], None]) -> Callable[[_O], None]:
"""Register a callback that will be triggered when this option changes"""
if not self.mutable:
Expand Down Expand Up @@ -123,7 +127,8 @@ def unset(self) -> None:
msg = f"{self} cannot be modified after initial load"
raise TypeError(msg)
old = self.current
delattr(self, "_current")
if hasattr(self, "_current"):
delattr(self, "_current")
if self.current != old:
for sub_func in self._subscribers:
sub_func(self.current)
Expand Down
3 changes: 2 additions & 1 deletion src/py/reactpy/reactpy/backend/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from typing import Any

from reactpy.backend.types import Connection, Location
from reactpy.core.hooks import Context, create_context, use_context
from reactpy.core.hooks import create_context, use_context
from reactpy.core.types import Context

# backend implementations should establish this context at the root of an app
ConnectionContext: Context[Connection[Any] | None] = create_context(None)
Expand Down
8 changes: 8 additions & 0 deletions src/py/reactpy/reactpy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,11 @@ def boolean(value: str | bool | int) -> bool:
validator=float,
)
"""A default timeout for testing utilities in ReactPy"""

REACTPY_ASYNC_RENDERING = Option(
"REACTPY_CONCURRENT_RENDERING",
default=False,
mutable=True,
validator=boolean,
)
"""Whether to render components concurrently. This is currently an experimental feature."""
Loading
Loading