From e9cf8224601032d0f1ef8c783bcf56c8020b6914 Mon Sep 17 00:00:00 2001 From: Martin Xu <15661672+martinxu9@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:47:22 -0700 Subject: [PATCH] CLI will not set auto/stop setting for deployment (#2040) * do not set autostart/autostop as default on CLI * cli feedback * fix test * clean up last few messages * catch general exception for export and exit --- reflex/constants/hosting.py | 2 +- reflex/reflex.py | 22 ++++++++++++---------- reflex/utils/hosting.py | 3 ++- tests/test_reflex.py | 8 ++++---- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/reflex/constants/hosting.py b/reflex/constants/hosting.py index d4080fb3f..349f696fb 100644 --- a/reflex/constants/hosting.py +++ b/reflex/constants/hosting.py @@ -19,6 +19,6 @@ class Hosting: # The time to sleep between requests to check if for authentication completion. In seconds. WEB_AUTH_SLEEP_DURATION = 5 # The time to wait for the backend to come up after user initiates deployment. In seconds. - BACKEND_POLL_RETRIES = 30 + BACKEND_POLL_RETRIES = 45 # The time to wait for the frontend to come up after user initiates deployment. In seconds. FRONTEND_POLL_RETRIES = 30 diff --git a/reflex/reflex.py b/reflex/reflex.py index 0a8192c2f..98bc4745f 100644 --- a/reflex/reflex.py +++ b/reflex/reflex.py @@ -452,12 +452,12 @@ def deploy( None, help="The amount of memory to allocate.", hidden=True ), auto_start: Optional[bool] = typer.Option( - True, + None, help="Whether to auto start the instance.", hidden=True, ), auto_stop: Optional[bool] = typer.Option( - True, + None, help="Whether to auto stop the instance.", hidden=True, ), @@ -550,7 +550,8 @@ def deploy( console.debug(f"{enabled_regions=}") while True: region_input = console.ask( - "Region to deploy to", default=regions[0] if regions else "sjc" + "Region to deploy to. Enter to use default.", + default=regions[0] if regions else "sjc", ) if enabled_regions is None or region_input in enabled_regions: @@ -595,6 +596,11 @@ def deploy( if os.path.exists(tmp_dir): shutil.rmtree(tmp_dir) raise typer.Exit(1) from ie + except Exception as ex: + console.error(f"Unable to export due to: {ex}") + if os.path.exists(tmp_dir): + shutil.rmtree(tmp_dir) + raise typer.Exit(1) from ex frontend_file_name = constants.ComponentName.FRONTEND.zip() backend_file_name = constants.ComponentName.BACKEND.zip() @@ -652,8 +658,6 @@ def deploy( time.sleep(1) if not backend_up: console.print("Backend unreachable") - else: - console.print("Backend is up") with console.status("Checking frontend ..."): for _ in range(constants.Hosting.FRONTEND_POLL_RETRIES): @@ -662,17 +666,15 @@ def deploy( time.sleep(1) if not frontend_up: console.print("frontend is unreachable") - else: - console.print("frontend is up") if frontend_up and backend_up: console.print( f"Your site [ {key} ] at {regions} is up: {deploy_response.frontend_url}" ) return - console.warn( - f"Your deployment is taking unusually long. Check back later on its status: `reflex deployments status {key}`" - ) + console.warn(f"Your deployment is taking time.") + console.warn(f"Check back later on its status: `reflex deployments status {key}`") + console.warn(f"For logs: `reflex deployments logs {key}`") deployments_cli = typer.Typer() diff --git a/reflex/utils/hosting.py b/reflex/utils/hosting.py index 271e6def2..6102b9d27 100644 --- a/reflex/utils/hosting.py +++ b/reflex/utils/hosting.py @@ -972,7 +972,8 @@ def interactive_get_deployment_key_from_user_input( # If user takes the suggestion, we will use the suggested key and proceed while key_input := console.ask( - f"Choose a name for your deployed app", default=key_candidate + f"Choose a name for your deployed app. Enter to use default.", + default=key_candidate, ): try: pre_deploy_response = prepare_deploy( diff --git a/tests/test_reflex.py b/tests/test_reflex.py index 3c466e307..44d3980d3 100644 --- a/tests/test_reflex.py +++ b/tests/test_reflex.py @@ -150,8 +150,8 @@ def test_deploy_non_interactive_success( app_prefix=app_prefix, cpus=None, memory_mb=None, - auto_start=True, - auto_stop=True, + auto_start=None, + auto_stop=None, frontend_hostname=None, envs=None, with_metrics=None, @@ -374,8 +374,8 @@ def test_deploy_interactive( app_prefix=app_prefix, cpus=None, memory_mb=None, - auto_start=True, - auto_stop=True, + auto_start=None, + auto_stop=None, frontend_hostname=None, envs=None, with_metrics=None,