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 16 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.11"]'
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 npm@8.19.3
- 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 npm@8.19.3
- 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 }}
7 changes: 7 additions & 0 deletions docs/source/about/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ 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 distinct components - enable this
rmorshea marked this conversation as resolved.
Show resolved Hide resolved
experimental feature by setting `REACTPY_FEATURE_CONCURRENT_RENDERING=true`.
rmorshea marked this conversation as resolved.
Show resolved Hide resolved
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
2 changes: 1 addition & 1 deletion src/py/reactpy/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,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_FEATURE_CONCURRENT_RENDERING = Option(
"REACTPY_CONCURRENT_RENDERING",
default=False,
mutable=True,
validator=boolean,
)
"""Whether to render components concurrently. This is currently an experimental feature."""
Loading