[ENG-4444] move states out of .web (#4689)
* move states out of .web * create file parents if they don't exist
This commit is contained in:
parent
abc9038580
commit
709c6dedf2
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,6 +4,7 @@ assets/external/*
|
|||||||
dist/*
|
dist/*
|
||||||
examples/
|
examples/
|
||||||
.web
|
.web
|
||||||
|
.states
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
.coverage
|
.coverage
|
||||||
|
@ -490,6 +490,9 @@ class EnvironmentVariables:
|
|||||||
# The working directory for the next.js commands.
|
# The working directory for the next.js commands.
|
||||||
REFLEX_WEB_WORKDIR: EnvVar[Path] = env_var(Path(constants.Dirs.WEB))
|
REFLEX_WEB_WORKDIR: EnvVar[Path] = env_var(Path(constants.Dirs.WEB))
|
||||||
|
|
||||||
|
# The working directory for the states directory.
|
||||||
|
REFLEX_STATES_WORKDIR: EnvVar[Path] = env_var(Path(constants.Dirs.STATES))
|
||||||
|
|
||||||
# Path to the alembic config file
|
# Path to the alembic config file
|
||||||
ALEMBIC_CONFIG: EnvVar[ExistingPath] = env_var(Path(constants.ALEMBIC_CONFIG))
|
ALEMBIC_CONFIG: EnvVar[ExistingPath] = env_var(Path(constants.ALEMBIC_CONFIG))
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class Dirs(SimpleNamespace):
|
|||||||
# The name of the postcss config file.
|
# The name of the postcss config file.
|
||||||
POSTCSS_JS = "postcss.config.js"
|
POSTCSS_JS = "postcss.config.js"
|
||||||
# The name of the states directory.
|
# The name of the states directory.
|
||||||
STATES = "states"
|
STATES = ".states"
|
||||||
|
|
||||||
|
|
||||||
class Reflex(SimpleNamespace):
|
class Reflex(SimpleNamespace):
|
||||||
|
@ -39,7 +39,14 @@ class GitIgnore(SimpleNamespace):
|
|||||||
# The gitignore file.
|
# The gitignore file.
|
||||||
FILE = Path(".gitignore")
|
FILE = Path(".gitignore")
|
||||||
# Files to gitignore.
|
# Files to gitignore.
|
||||||
DEFAULTS = {Dirs.WEB, "*.db", "__pycache__/", "*.py[cod]", "assets/external/"}
|
DEFAULTS = {
|
||||||
|
Dirs.WEB,
|
||||||
|
Dirs.STATES,
|
||||||
|
"*.db",
|
||||||
|
"__pycache__/",
|
||||||
|
"*.py[cod]",
|
||||||
|
"assets/external/",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class RequirementsTxt(SimpleNamespace):
|
class RequirementsTxt(SimpleNamespace):
|
||||||
|
@ -3046,7 +3046,7 @@ def is_serializable(value: Any) -> bool:
|
|||||||
|
|
||||||
def reset_disk_state_manager():
|
def reset_disk_state_manager():
|
||||||
"""Reset the disk state manager."""
|
"""Reset the disk state manager."""
|
||||||
states_directory = prerequisites.get_web_dir() / constants.Dirs.STATES
|
states_directory = prerequisites.get_states_dir()
|
||||||
if states_directory.exists():
|
if states_directory.exists():
|
||||||
for path in states_directory.iterdir():
|
for path in states_directory.iterdir():
|
||||||
path.unlink()
|
path.unlink()
|
||||||
@ -3094,7 +3094,7 @@ class StateManagerDisk(StateManager):
|
|||||||
Returns:
|
Returns:
|
||||||
The states directory.
|
The states directory.
|
||||||
"""
|
"""
|
||||||
return prerequisites.get_web_dir() / constants.Dirs.STATES
|
return prerequisites.get_states_dir()
|
||||||
|
|
||||||
def _purge_expired_states(self):
|
def _purge_expired_states(self):
|
||||||
"""Purge expired states from the disk."""
|
"""Purge expired states from the disk."""
|
||||||
|
@ -307,7 +307,7 @@ def run_granian_backend(host, port, loglevel: LogLevel):
|
|||||||
log_level=LogLevels(loglevel.value),
|
log_level=LogLevels(loglevel.value),
|
||||||
reload=True,
|
reload=True,
|
||||||
reload_paths=get_reload_dirs(),
|
reload_paths=get_reload_dirs(),
|
||||||
reload_ignore_dirs=[".web"],
|
reload_ignore_dirs=[".web", ".states"],
|
||||||
).serve()
|
).serve()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
console.error(
|
console.error(
|
||||||
|
@ -196,6 +196,9 @@ def update_json_file(file_path: str | Path, update_dict: dict[str, int | str]):
|
|||||||
"""
|
"""
|
||||||
fp = Path(file_path)
|
fp = Path(file_path)
|
||||||
|
|
||||||
|
# Create the parent directory if it doesn't exist.
|
||||||
|
fp.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
# Create the file if it doesn't exist.
|
# Create the file if it doesn't exist.
|
||||||
fp.touch(exist_ok=True)
|
fp.touch(exist_ok=True)
|
||||||
|
|
||||||
|
@ -87,6 +87,17 @@ def get_web_dir() -> Path:
|
|||||||
return environment.REFLEX_WEB_WORKDIR.get()
|
return environment.REFLEX_WEB_WORKDIR.get()
|
||||||
|
|
||||||
|
|
||||||
|
def get_states_dir() -> Path:
|
||||||
|
"""Get the working directory for the states.
|
||||||
|
|
||||||
|
Can be overridden with REFLEX_STATES_WORKDIR.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The working directory.
|
||||||
|
"""
|
||||||
|
return environment.REFLEX_STATES_WORKDIR.get()
|
||||||
|
|
||||||
|
|
||||||
def check_latest_package_version(package_name: str):
|
def check_latest_package_version(package_name: str):
|
||||||
"""Check if the latest version of the package is installed.
|
"""Check if the latest version of the package is installed.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user