Skip to content
Open
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
1 change: 1 addition & 0 deletions news/+backend-startup-followup.performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce backend startup time and memory by avoiding unused database and compiler imports in the backend launcher and state mutation tracking.
1 change: 1 addition & 0 deletions news/+dev-mode-imports.performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce development startup and reload memory by deferring unused database and admin integrations and avoiding redundant app preloads in spawned Granian supervisors.
1 change: 1 addition & 0 deletions news/7049.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Preserve relationship serialization and database usage accounting for apps that use SQLModel directly, without loading unused database integrations.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Load pandas, Plotly, and Pillow serializers on demand and avoid importing SQLAlchemy for generic type helpers, reducing startup time and memory when these integrations are unused.
1 change: 1 addition & 0 deletions packages/reflex-base/news/7049.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Preserve SQLModel relationships, ObjectVar field access, and optional serializer overrides on cold startup, including classes without module names and multiple optional-library bases. Avoid import-order failures, fork hangs, and registry corruption during serializer lookup.
39 changes: 39 additions & 0 deletions packages/reflex-base/src/reflex_base/utils/_serializer_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Optional serializer annotations resolved only when introspected at runtime."""

from importlib import import_module
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from pandas import DataFrame as DataFrame
from PIL.Image import Image as Image
from plotly.graph_objects import Figure as Figure
from plotly.graph_objs.layout import Template as Template
from sqlmodel import SQLModel as SQLModel

_TYPE_MODULES = {
"DataFrame": "pandas",
"Image": "PIL.Image",
"Figure": "plotly.graph_objects",
"Template": "plotly.graph_objs.layout",
"SQLModel": "sqlmodel",
}


def __getattr__(name: str) -> type:
"""Resolve an optional type without importing unused serializer dependencies.

Args:
name: The optional type name.

Returns:
The concrete type from its optional dependency.

Raises:
AttributeError: If the name is not an optional serializer type.
"""
if name not in _TYPE_MODULES:
msg = f"module {__name__!r} has no attribute {name!r}"
raise AttributeError(msg)
value = getattr(import_module(_TYPE_MODULES[name]), name)
globals()[name] = value
return value
Loading
Loading