Skip to content

Commit ebe19ff

Browse files
masenfclaude
andauthored
Migrate to Reflex plugins and remove deprecated rx.Model usage (#322)
* counter: add RadixThemesPlugin to fix implicit Radix Themes deprecation * json-tree: add RadixThemesPlugin to fix implicit Radix Themes deprecation * linkinbio: add RadixThemesPlugin to fix implicit Radix Themes deprecation * overkey: add RadixThemesPlugin to fix implicit Radix Themes deprecation * reflexle: add RadixThemesPlugin to fix implicit Radix Themes deprecation * snakegame: add RadixThemesPlugin to fix implicit Radix Themes deprecation * todo: add RadixThemesPlugin to fix implicit Radix Themes deprecation * upload: add RadixThemesPlugin to fix implicit Radix Themes deprecation * dalle: move App(theme=...) to RadixThemesPlugin in config * flux-fast: move App(theme=...) to RadixThemesPlugin in config * chat_v2: replace deprecated rx.Model with sqlmodel.SQLModel and add RadixThemesPlugin * clock: add explicit set_zone setter, move theme to RadixThemesPlugin * basic_crud: replace rx.Model with SQLModel, add set_url_query setter, add RadixThemesPlugin * data_visualisation: replace rx.Model with SQLModel, move theme to RadixThemesPlugin * form-designer: replace rx.Model with SQLModel, add set_options_editor_open setter, move theme to RadixThemesPlugin The remaining rx.Model DeprecationWarning originates from reflex_local_auth.LocalUser, which is external to this repo. * github-stats: add explicit set_username setter, add RadixThemesPlugin * local-component: add explicit set_who setter, add RadixThemesPlugin * lorem-stream: replace reflex-chakra circular_progress with rx.progress, add RadixThemesPlugin * quiz: replace reflex-chakra circular_progress with rx.progress, move theme to RadixThemesPlugin * translator: replace rx.Base with rx.PropsBase, add explicit setters, move theme to RadixThemesPlugin * traversal: add explicit set_option setter, add RadixThemesPlugin * twitter: replace rx.Model with SQLModel, add explicit setters, move theme to RadixThemesPlugin * nba: move App(theme=...) to RadixThemesPlugin in config * nba-proxy: add RadixThemesPlugin to config matching nba app * ag_grid_finance: add RadixThemesPlugin to fix potential implicit Radix Themes deprecation * azure_auth: add RadixThemesPlugin to fix implicit Radix Themes deprecation * check_export: replace reflex pin in requirements.txt with REFLEX_DEP Munge requirements.txt in-place so that the existing 'reflex' (or 'reflex[db]') pin is rewritten to use REFLEX_DEP as a direct reference. This preserves extras such as [db] that the app needs to function, instead of installing a stock reflex alongside the requirements file. * basic_crud: require reflex[db] extra and set explicit db_url This app uses rx.session, which depends on the optional [db] extra and the (previously default) sqlite db_url. * chat_v2: require reflex[db] extra and set explicit db_url This app uses rx.session, which depends on the optional [db] extra and the (previously default) sqlite db_url. * data_visualisation: require reflex[db] extra This app uses rx.session, which depends on the optional [db] extra. db_url is already configured via DATABASE_URL env (or sqlite default). * form-designer: require reflex[db] extra This app uses rx.session, which depends on the optional [db] extra. db_url is already configured. * twitter: require reflex[db] extra and set explicit db_url This app uses rx.session, which depends on the optional [db] extra and the (previously default) sqlite db_url. * counter: drop unused db_url from config * snakegame: drop unused db_url from config * todo: drop unused db_url from config * upload: drop unused db_url from config * check_export: install reflex from a local checkout of reflex-dev/reflex The previous approach only pinned the top-level reflex package to the git URL, so pip still resolved the monorepo's subpackages (reflex-base, reflex-components-*, etc.) from PyPI. Check out the reflex repo to a sibling directory and rewrite the requirements pin to a file:// URL of that checkout so pip can pull the subpackages from the same source. The workflow_dispatch input is renamed to reflex_ref since we now drive the install from a git ref rather than a pip spec. * check_export: fetch full history and tags for reflex checkout reflex uses dynamic versioning derived from git tags, so a shallow checkout without tags would fail to compute the package version. * check_export: use uv pip to install requirements uv understands workspace source declarations in reflex's pyproject.toml, which pip ignores. This should resolve reflex's subpackages from the local checkout instead of pulling them from PyPI. * form-designer: suppress upstream rx.Model deprecation from reflex_local_auth reflex_local_auth.LocalUser still subclasses the deprecated rx.Model, which emits a console.deprecate() warning at import time. Until the upstream package migrates to SQLModel, monkey-patch console.deprecate to silence that specific feature name. * Revert "form-designer: suppress upstream rx.Model deprecation from reflex_local_auth" This reverts commit e48df0a. * form-designer: bump reflex-local-auth to >=0.5.0 0.5.0 drops rx.Model in favor of SQLModel, removing the lingering DeprecationWarning that previously came from the upstream LocalUser. * azure_auth: use public consumers tenant and example client id Switches to the shared Microsoft consumers tenant (9188040d-6c67-4c5b-b112-36a304b66dad) and a public example client id so the app's OIDC discovery succeeds without a private tenant. * ag_grid_finance: add explicit set_grid_theme setter The auto-generated set_* setter no longer exists in current Reflex; provide an explicit @rx.event handler. * form-designer: use sqlmodel.select in tests rx.Model.select was removed alongside rx.Model itself; switch to the standard sqlmodel.select(Model).where(...) form. * bump reflex minimum to >=0.9.2 across apps using RadixThemesPlugin RadixThemesPlugin was introduced in 0.9.2; apps whose rxconfig.py references it need the matching minimum version. * counter: drop AppHarness.get_state assertions from tests AppHarness no longer exposes get_state(); the frontend already asserts the same count values via poll_for_content, so the backend-state checks were redundant. * counter: restore session-storage token polling Polling for the session-storage token confirms the frontend has connected to the backend before the test exercises the UI. * form-designer: use sqlmodel.select in app code rx.Model.select was removed alongside rx.Model itself; switch the Form and Response queries to the standard sqlmodel.select(Model).where(...) form to match the tests. * check_export: drop local reflex checkout, use git URL with uv uv pip install understands workspace declarations in a git-fetched reflex source dist, so we no longer need a sibling checkout of reflex-dev/reflex to pull in the monorepo subpackages. * form-designer: use rx.model.migrate() for db setup Replaces the hand-rolled SQLModel.metadata.create_all(get_engine()) with the public helper. Also sets alembic's path_separator=os to silence the unrelated alembic DeprecationWarning that the helper surfaces. * Revert "check_export: drop local reflex checkout, use git URL with uv" This reverts commit e24fa3f. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent b70ea01 commit ebe19ff

85 files changed

Lines changed: 293 additions & 156 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/check_export.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: check-export
22
env:
3-
REFLEX_DEP: 'git+https://github.com/reflex-dev/reflex.git@main'
3+
REFLEX_REPO: 'reflex-dev/reflex'
4+
REFLEX_REF: 'main'
45
REFLEX_TELEMETRY_ENABLED: false
56
on:
67
push:
@@ -9,8 +10,8 @@ on:
910
branches: [main]
1011
workflow_dispatch:
1112
inputs:
12-
reflex_dep:
13-
description: 'Reflex dep (raw pip spec)'
13+
reflex_ref:
14+
description: 'Reflex git ref to check out from reflex-dev/reflex'
1415

1516
jobs:
1617
list-examples:
@@ -35,6 +36,13 @@ jobs:
3536
runs-on: ubuntu-latest
3637
steps:
3738
- uses: actions/checkout@v3
39+
- uses: actions/checkout@v3
40+
with:
41+
repository: ${{ env.REFLEX_REPO }}
42+
ref: ${{ github.event.inputs.reflex_ref || env.REFLEX_REF }}
43+
path: _reflex
44+
fetch-depth: 0
45+
fetch-tags: true
3846
- uses: actions/setup-python@v3
3947
- run: |
4048
f=${{ matrix.example }}
@@ -57,8 +65,25 @@ jobs:
5765
5866
python -m venv venv
5967
source venv/bin/activate
68+
pip install uv
6069
61-
pip install '${{ github.event.inputs.reflex_dep || env.REFLEX_DEP }}' -r requirements.txt
70+
REFLEX_DIR="$GITHUB_WORKSPACE/_reflex" python - <<'PY'
71+
import os, re
72+
reflex_dir = os.environ["REFLEX_DIR"]
73+
with open("requirements.txt") as f:
74+
lines = f.read().splitlines()
75+
out = []
76+
for line in lines:
77+
m = re.match(r"^(reflex(?:\[[^\]]+\])?)\s*(?:[<>=!~].*)?$", line)
78+
if m:
79+
out.append(f"{m.group(1)} @ file://{reflex_dir}")
80+
else:
81+
out.append(line)
82+
with open("requirements.txt", "w") as f:
83+
f.write("\n".join(out) + "\n")
84+
PY
85+
cat requirements.txt
86+
uv pip install -r requirements.txt
6287
6388
export OPENAI_API_KEY="dummy"
6489
reflex init

ag_grid_finance/ag_grid_finance/ag_grid_finance.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class State(rx.State):
2929
# The list of themes for the AG Grid
3030
themes: list[str] = ["quartz", "balham", "alpine", "material"]
3131

32+
@rx.event
33+
def set_grid_theme(self, grid_theme: str) -> None:
34+
self.grid_theme = grid_theme
35+
3236
def fetch_stock_data(self):
3337
self.selected_rows = None
3438
self.datetime_now = datetime.now()

ag_grid_finance/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
reflex>=0.8.0
1+
reflex>=0.9.2
22
reflex-enterprise>=0.0.2
33
yfinance==0.2.54

ag_grid_finance/rxconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
config = rx.Config(
44
app_name="ag_grid_finance",
5-
tailwind=None,
5+
plugins=[rx.plugins.RadixThemesPlugin()],
66
)

azure_auth/azure_auth/auth/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import reflex as rx
33
from typing import Dict, List, Optional
44

5-
client_id: str = "0df2a88e-fddb-4cc2-b3e0-f475f162b373"
5+
client_id: str = "6cb593cc-6a01-455e-ac48-73235a542d16"
66
client_secret: str = ""
7-
tenant_id: str = "f2c9cbbe-006b-46b8-9ad0-d877d8446d6d"
7+
tenant_id: str = "9188040d-6c67-4c5b-b112-36a304b66dad"
88
authority = f"https://login.microsoftonline.com/{tenant_id}"
99
login_redirect = "/"
1010
cache = msal.TokenCache()

azure_auth/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
reflex>=0.8.0
1+
reflex>=0.9.2
22
msal==1.31.0

azure_auth/rxconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
config = rx.Config(
44
app_name="azure_auth",
5-
tailwind=None,
5+
plugins=[rx.plugins.RadixThemesPlugin()],
66
)

basic_crud/basic_crud/basic_crud.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ class QueryState(State):
6868
url_query: str = URL_OPTIONS["GET"]
6969
query_options = list(URL_OPTIONS.keys())
7070

71+
@rx.event
72+
def set_url_query(self, value: str) -> None:
73+
self.url_query = value
74+
75+
@rx.event
76+
def set_body(self, value: str) -> None:
77+
self.body = value
78+
7179
def update_method(self, value):
7280
if self.url_query == "":
7381
self.url_query = URL_OPTIONS[value]

basic_crud/basic_crud/model.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
from datetime import datetime, timezone
44

5-
from sqlmodel import Column, DateTime, Field, func
5+
from sqlmodel import Column, DateTime, Field, SQLModel, func
66

7-
import reflex as rx
87

9-
10-
class Product(rx.Model, table=True):
8+
class Product(SQLModel, table=True):
9+
id: int | None = Field(default=None, primary_key=True)
1110
"""Product model."""
1211

1312
code: str = Field(unique=True)

basic_crud/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
reflex>=0.8.0
1+
reflex[db]>=0.9.2
22
fastapi

0 commit comments

Comments
 (0)