Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ab7b8569a9 | ||
![]() |
788d9271c1 | ||
![]() |
4ad2ce5e03 | ||
![]() |
1a752901df |
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "reflex"
|
||||
version = "0.4.4"
|
||||
version = "0.4.5"
|
||||
description = "Web apps in pure Python."
|
||||
license = "Apache-2.0"
|
||||
authors = [
|
||||
|
@ -77,7 +77,7 @@ from reflex.state import (
|
||||
code_uses_state_contexts,
|
||||
)
|
||||
from reflex.utils import console, exceptions, format, prerequisites, types
|
||||
from reflex.utils.exec import is_testing_env
|
||||
from reflex.utils.exec import is_testing_env, should_skip_compile
|
||||
from reflex.utils.imports import ImportVar
|
||||
|
||||
# Define custom types.
|
||||
@ -672,7 +672,7 @@ class App(Base):
|
||||
Whether the app should be compiled.
|
||||
"""
|
||||
# Check the environment variable.
|
||||
if os.environ.get(constants.SKIP_COMPILE_ENV_VAR) == "yes":
|
||||
if should_skip_compile():
|
||||
return False
|
||||
|
||||
# Check the nocompile file.
|
||||
|
@ -181,6 +181,9 @@ class HighLevelSelect(SelectRoot):
|
||||
# The radius of the select.
|
||||
radius: Var[LiteralRadius]
|
||||
|
||||
# The width of the select.
|
||||
width: Var[str]
|
||||
|
||||
# The positioning mode to use. Default is "item-aligned".
|
||||
position: Var[Literal["item-aligned", "popper"]]
|
||||
|
||||
@ -203,7 +206,7 @@ class HighLevelSelect(SelectRoot):
|
||||
|
||||
trigger_props = {
|
||||
prop: props.pop(prop)
|
||||
for prop in ["placeholder", "variant", "radius"]
|
||||
for prop in ["placeholder", "variant", "radius", "width", "flex_shrink"]
|
||||
if prop in props
|
||||
}
|
||||
|
||||
|
@ -863,6 +863,7 @@ class HighLevelSelect(SelectRoot):
|
||||
Literal["none", "small", "medium", "large", "full"],
|
||||
]
|
||||
] = None,
|
||||
width: Optional[Union[Var[str], str]] = None,
|
||||
position: Optional[
|
||||
Union[
|
||||
Var[Literal["item-aligned", "popper"]],
|
||||
@ -949,6 +950,7 @@ class HighLevelSelect(SelectRoot):
|
||||
high_contrast: Whether to render the select with higher contrast color against background.
|
||||
variant: The variant of the select.
|
||||
radius: The radius of the select.
|
||||
width: The width of the select.
|
||||
position: The positioning mode to use. Default is "item-aligned".
|
||||
size: The size of the select: "1" | "2" | "3"
|
||||
default_value: The value of the select when initially rendered. Use when you do not need to control the state of the select.
|
||||
@ -1061,6 +1063,7 @@ class Select(ComponentNamespace):
|
||||
Literal["none", "small", "medium", "large", "full"],
|
||||
]
|
||||
] = None,
|
||||
width: Optional[Union[Var[str], str]] = None,
|
||||
position: Optional[
|
||||
Union[
|
||||
Var[Literal["item-aligned", "popper"]],
|
||||
@ -1147,6 +1150,7 @@ class Select(ComponentNamespace):
|
||||
high_contrast: Whether to render the select with higher contrast color against background.
|
||||
variant: The variant of the select.
|
||||
radius: The radius of the select.
|
||||
width: The width of the select.
|
||||
position: The positioning mode to use. Default is "item-aligned".
|
||||
size: The size of the select: "1" | "2" | "3"
|
||||
default_value: The value of the select when initially rendered. Use when you do not need to control the state of the select.
|
||||
|
@ -307,3 +307,12 @@ def is_prod_mode() -> bool:
|
||||
constants.Env.DEV.value,
|
||||
)
|
||||
return current_mode == constants.Env.PROD.value
|
||||
|
||||
|
||||
def should_skip_compile() -> bool:
|
||||
"""Whether the app should skip compile.
|
||||
|
||||
Returns:
|
||||
True if the app should skip compile.
|
||||
"""
|
||||
return os.environ.get(constants.SKIP_COMPILE_ENV_VAR) == "yes"
|
||||
|
@ -448,7 +448,7 @@ def get_project_hash(raise_on_fail: bool = False) -> int | None:
|
||||
# Open and read the file
|
||||
with open(constants.Reflex.JSON, "r") as file:
|
||||
data = json.load(file)
|
||||
return data["project_hash"]
|
||||
return data.get("project_hash")
|
||||
|
||||
|
||||
def initialize_web_directory():
|
||||
|
@ -11,6 +11,7 @@ import psutil
|
||||
|
||||
from reflex import constants
|
||||
from reflex.utils import console
|
||||
from reflex.utils.exec import should_skip_compile
|
||||
from reflex.utils.prerequisites import ensure_reflex_installation_id, get_project_hash
|
||||
|
||||
POSTHOG_API_URL: str = "https://app.posthog.com/capture/"
|
||||
@ -64,6 +65,22 @@ def get_memory() -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def _raise_on_missing_project_hash() -> bool:
|
||||
"""Check if an error should be raised when project hash is missing.
|
||||
|
||||
When running reflex with --backend-only, or doing database migration
|
||||
operations, there is no requirement for a .web directory, so the reflex.json
|
||||
file may not exist, and this should not be considered an error.
|
||||
|
||||
Returns:
|
||||
False when compilation should be skipped (i.e. no .web directory is required).
|
||||
Otherwise return True.
|
||||
"""
|
||||
if should_skip_compile():
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _prepare_event(event: str) -> dict:
|
||||
"""Prepare the event to be sent to the PostHog server.
|
||||
|
||||
@ -74,7 +91,7 @@ def _prepare_event(event: str) -> dict:
|
||||
The event data.
|
||||
"""
|
||||
installation_id = ensure_reflex_installation_id()
|
||||
project_hash = get_project_hash(raise_on_fail=True)
|
||||
project_hash = get_project_hash(raise_on_fail=_raise_on_missing_project_hash())
|
||||
|
||||
if installation_id is None or project_hash is None:
|
||||
console.debug(
|
||||
|
@ -1861,6 +1861,8 @@ class ComputedVar(Var, property):
|
||||
# handle caching
|
||||
if not hasattr(instance, self._cache_attr):
|
||||
setattr(instance, self._cache_attr, super().__get__(instance, owner))
|
||||
# Ensure the computed var gets serialized to redis.
|
||||
instance._was_touched = True
|
||||
return getattr(instance, self._cache_attr)
|
||||
|
||||
def _deps(
|
||||
|
Loading…
Reference in New Issue
Block a user