i don't believe this code
This commit is contained in:
parent
8a1baa6c9d
commit
5203e596c9
@ -501,6 +501,7 @@ def deploy(
|
||||
),
|
||||
):
|
||||
"""Deploy the app to the Reflex hosting service."""
|
||||
from reflex_cli.constants.base import LogLevel as HostingLogLevel
|
||||
from reflex_cli.utils import dependency
|
||||
from reflex_cli.v2 import cli as hosting_cli
|
||||
|
||||
@ -512,6 +513,21 @@ def deploy(
|
||||
# Set the log level.
|
||||
console.set_log_level(loglevel)
|
||||
|
||||
def convert_reflex_loglevel_to_reflex_cli_loglevel(
|
||||
loglevel: constants.LogLevel,
|
||||
) -> HostingLogLevel:
|
||||
if loglevel == constants.LogLevel.DEBUG:
|
||||
return HostingLogLevel.DEBUG
|
||||
if loglevel == constants.LogLevel.INFO:
|
||||
return HostingLogLevel.INFO
|
||||
if loglevel == constants.LogLevel.WARNING:
|
||||
return HostingLogLevel.WARNING
|
||||
if loglevel == constants.LogLevel.ERROR:
|
||||
return HostingLogLevel.ERROR
|
||||
if loglevel == constants.LogLevel.CRITICAL:
|
||||
return HostingLogLevel.CRITICAL
|
||||
return HostingLogLevel.INFO
|
||||
|
||||
# Only check requirements if interactive.
|
||||
# There is user interaction for requirements update.
|
||||
if interactive:
|
||||
@ -522,10 +538,6 @@ def deploy(
|
||||
_init(name=config.app_name, loglevel=loglevel)
|
||||
prerequisites.check_latest_package_version(constants.ReflexHostingCLI.MODULE_NAME)
|
||||
|
||||
extra: dict[str, str] = (
|
||||
{"config_path": config_path} if config_path is not None else {}
|
||||
)
|
||||
|
||||
hosting_cli.deploy(
|
||||
app_name=app_name,
|
||||
app_id=app_id,
|
||||
@ -549,12 +561,11 @@ def deploy(
|
||||
envfile=envfile,
|
||||
hostname=hostname,
|
||||
interactive=interactive,
|
||||
loglevel=type(loglevel).INFO, # type: ignore
|
||||
loglevel=convert_reflex_loglevel_to_reflex_cli_loglevel(loglevel),
|
||||
token=token,
|
||||
project=project,
|
||||
config_path=config_path,
|
||||
project_name=project_name,
|
||||
**extra,
|
||||
**({"config_path": config_path} if config_path is not None else {}),
|
||||
)
|
||||
|
||||
|
||||
|
@ -240,25 +240,28 @@ def run_backend(
|
||||
run_uvicorn_backend(host, port, loglevel)
|
||||
|
||||
|
||||
def get_reload_dirs() -> list[str]:
|
||||
def get_reload_dirs() -> list[Path]:
|
||||
"""Get the reload directories for the backend.
|
||||
|
||||
Returns:
|
||||
The reload directories for the backend.
|
||||
"""
|
||||
config = get_config()
|
||||
reload_dirs = [config.app_name]
|
||||
reload_dirs = [Path(config.app_name)]
|
||||
if config.app_module is not None and config.app_module.__file__:
|
||||
module_path = Path(config.app_module.__file__).resolve().parent
|
||||
|
||||
while module_path.parent.name:
|
||||
for parent_file in module_path.parent.iterdir():
|
||||
if parent_file == "__init__.py":
|
||||
# go up a level to find dir without `__init__.py`
|
||||
module_path = module_path.parent
|
||||
break
|
||||
if any(
|
||||
sibling_file.name == "__init__.py"
|
||||
for sibling_file in module_path.parent.iterdir()
|
||||
):
|
||||
# go up a level to find dir without `__init__.py`
|
||||
module_path = module_path.parent
|
||||
else:
|
||||
break
|
||||
reload_dirs.append(str(module_path))
|
||||
|
||||
reload_dirs = [module_path]
|
||||
return reload_dirs
|
||||
|
||||
|
||||
@ -278,7 +281,7 @@ def run_uvicorn_backend(host, port, loglevel: LogLevel):
|
||||
port=port,
|
||||
log_level=loglevel.value,
|
||||
reload=True,
|
||||
reload_dirs=get_reload_dirs(),
|
||||
reload_dirs=list(map(str, get_reload_dirs())),
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user