Skip to content

Commit ecbf634

Browse files
Kastier1simonmasenf
committed
remove v2 commands (#4478)
* remove v2 commands * format * remove v2 * remove v2 * little fixes friend * add cloud * relock poetry deps * bump reflex-hosting-cli dep * test_dynamic_routes: wait for token attempt to avoid test flakiness * relock deps * test_dynamic_routes: increase polling timeout --------- Co-authored-by: simon <simon@reflex.dev> Co-authored-by: Masen Furer <m_github@0x26.net>
1 parent da4599f commit ecbf634

File tree

6 files changed

+30
-197
lines changed

6 files changed

+30
-197
lines changed

poetry.lock

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ wrapt = [
4949
{version = ">=1.11.0,<2.0", python = "<3.11"},
5050
]
5151
packaging = ">=23.1,<25.0"
52-
reflex-hosting-cli = ">=0.1.17,<2.0"
52+
reflex-hosting-cli = ">=0.1.28,<2.0"
5353
charset-normalizer = ">=3.3.2,<4.0"
5454
wheel = ">=0.42.0,<1.0"
5555
build = ">=1.0.3,<2.0"

reflex/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,9 @@ class Config:
652652
frontend_packages: List[str] = []
653653

654654
# The hosting service backend URL.
655-
cp_backend_url: str = Hosting.CP_BACKEND_URL
655+
cp_backend_url: str = Hosting.HOSTING_SERVICE
656656
# The hosting service frontend URL.
657-
cp_web_url: str = Hosting.CP_WEB_URL
657+
cp_web_url: str = Hosting.HOSTING_SERVICE_UI
658658

659659
# The worker class used in production mode
660660
gunicorn_worker_class: str = "uvicorn.workers.UvicornH11Worker"

reflex/custom_components/custom_components.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,11 @@ def _collect_details_for_gallery():
827827
Raises:
828828
Exit: If pyproject.toml file is ill-formed or the request to the backend services fails.
829829
"""
830-
from reflex.reflex import _login
830+
from reflex_cli.utils import hosting
831831

832832
console.rule("[bold]Authentication with Reflex Services")
833833
console.print("First let's log in to Reflex backend services.")
834-
access_token = _login()
834+
access_token, _ = hosting.authenticated_token()
835835

836836
console.rule("[bold]Custom Component Information")
837837
params = {}

reflex/reflex.py

+8-183
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
import typer
1111
import typer.core
12-
from reflex_cli.deployments import deployments_cli
13-
from reflex_cli.utils import dependency
1412
from reflex_cli.v2.deployments import check_version, hosting_cli
1513

1614
from reflex import constants
@@ -330,41 +328,8 @@ def export(
330328
)
331329

332330

333-
def _login() -> str:
334-
"""Helper function to authenticate with Reflex hosting service."""
335-
from reflex_cli.utils import hosting
336-
337-
access_token, invitation_code = hosting.authenticated_token()
338-
if access_token:
339-
console.print("You already logged in.")
340-
return access_token
341-
342-
# If not already logged in, open a browser window/tab to the login page.
343-
access_token = hosting.authenticate_on_browser(invitation_code)
344-
345-
if not access_token:
346-
console.error("Unable to authenticate. Please try again or contact support.")
347-
raise typer.Exit(1)
348-
349-
console.print("Successfully logged in.")
350-
return access_token
351-
352-
353-
@cli.command()
354-
def login(
355-
loglevel: constants.LogLevel = typer.Option(
356-
config.loglevel, help="The log level to use."
357-
),
358-
):
359-
"""Authenticate with Reflex hosting service."""
360-
# Set the log level.
361-
console.set_log_level(loglevel)
362-
363-
_login()
364-
365-
366331
@cli.command()
367-
def loginv2(loglevel: constants.LogLevel = typer.Option(config.loglevel)):
332+
def login(loglevel: constants.LogLevel = typer.Option(config.loglevel)):
368333
"""Authenicate with experimental Reflex hosting service."""
369334
from reflex_cli.v2 import cli as hosting_cli
370335

@@ -382,26 +347,11 @@ def logout(
382347
),
383348
):
384349
"""Log out of access to Reflex hosting service."""
385-
from reflex_cli.utils import hosting
386-
387-
console.set_log_level(loglevel)
388-
389-
hosting.log_out_on_browser()
390-
console.debug("Deleting access token from config locally")
391-
hosting.delete_token_from_config(include_invitation_code=True)
392-
393-
394-
@cli.command()
395-
def logoutv2(
396-
loglevel: constants.LogLevel = typer.Option(
397-
config.loglevel, help="The log level to use."
398-
),
399-
):
400-
"""Log out of access to Reflex hosting service."""
401-
from reflex_cli.v2 import cli
350+
from reflex_cli.v2.cli import logout
402351

403352
check_version()
404-
cli.logout()
353+
354+
logout(loglevel) # type: ignore
405355

406356

407357
db_cli = typer.Typer()
@@ -486,126 +436,6 @@ def makemigrations(
486436

487437
@cli.command()
488438
def deploy(
489-
key: Optional[str] = typer.Option(
490-
None,
491-
"-k",
492-
"--deployment-key",
493-
help="The name of the deployment. Domain name safe characters only.",
494-
),
495-
app_name: str = typer.Option(
496-
config.app_name,
497-
"--app-name",
498-
help="The name of the App to deploy under.",
499-
hidden=True,
500-
),
501-
regions: List[str] = typer.Option(
502-
list(),
503-
"-r",
504-
"--region",
505-
help="The regions to deploy to.",
506-
),
507-
envs: List[str] = typer.Option(
508-
list(),
509-
"--env",
510-
help="The environment variables to set: <key>=<value>. For multiple envs, repeat this option, e.g. --env k1=v2 --env k2=v2.",
511-
),
512-
cpus: Optional[int] = typer.Option(
513-
None, help="The number of CPUs to allocate.", hidden=True
514-
),
515-
memory_mb: Optional[int] = typer.Option(
516-
None, help="The amount of memory to allocate.", hidden=True
517-
),
518-
auto_start: Optional[bool] = typer.Option(
519-
None,
520-
help="Whether to auto start the instance.",
521-
hidden=True,
522-
),
523-
auto_stop: Optional[bool] = typer.Option(
524-
None,
525-
help="Whether to auto stop the instance.",
526-
hidden=True,
527-
),
528-
frontend_hostname: Optional[str] = typer.Option(
529-
None,
530-
"--frontend-hostname",
531-
help="The hostname of the frontend.",
532-
hidden=True,
533-
),
534-
interactive: bool = typer.Option(
535-
True,
536-
help="Whether to list configuration options and ask for confirmation.",
537-
),
538-
with_metrics: Optional[str] = typer.Option(
539-
None,
540-
help="Setting for metrics scraping for the deployment. Setup required in user code.",
541-
hidden=True,
542-
),
543-
with_tracing: Optional[str] = typer.Option(
544-
None,
545-
help="Setting to export tracing for the deployment. Setup required in user code.",
546-
hidden=True,
547-
),
548-
upload_db_file: bool = typer.Option(
549-
False,
550-
help="Whether to include local sqlite db files when uploading to hosting service.",
551-
hidden=True,
552-
),
553-
loglevel: constants.LogLevel = typer.Option(
554-
config.loglevel, help="The log level to use."
555-
),
556-
):
557-
"""Deploy the app to the Reflex hosting service."""
558-
from reflex_cli import cli as hosting_cli
559-
560-
from reflex.utils import export as export_utils
561-
from reflex.utils import prerequisites
562-
563-
# Set the log level.
564-
console.set_log_level(loglevel)
565-
566-
# Only check requirements if interactive. There is user interaction for requirements update.
567-
if interactive:
568-
dependency.check_requirements()
569-
570-
# Check if we are set up.
571-
if prerequisites.needs_reinit(frontend=True):
572-
_init(name=config.app_name, loglevel=loglevel)
573-
prerequisites.check_latest_package_version(constants.ReflexHostingCLI.MODULE_NAME)
574-
575-
hosting_cli.deploy(
576-
app_name=app_name,
577-
export_fn=lambda zip_dest_dir,
578-
api_url,
579-
deploy_url,
580-
frontend,
581-
backend,
582-
zipping: export_utils.export(
583-
zip_dest_dir=zip_dest_dir,
584-
api_url=api_url,
585-
deploy_url=deploy_url,
586-
frontend=frontend,
587-
backend=backend,
588-
zipping=zipping,
589-
loglevel=loglevel.subprocess_level(),
590-
upload_db_file=upload_db_file,
591-
),
592-
key=key,
593-
regions=regions,
594-
envs=envs,
595-
cpus=cpus,
596-
memory_mb=memory_mb,
597-
auto_start=auto_start,
598-
auto_stop=auto_stop,
599-
frontend_hostname=frontend_hostname,
600-
interactive=interactive,
601-
with_metrics=with_metrics,
602-
with_tracing=with_tracing,
603-
loglevel=loglevel.subprocess_level(),
604-
)
605-
606-
607-
@cli.command()
608-
def deployv2(
609439
app_name: str = typer.Option(
610440
config.app_name,
611441
"--app-name",
@@ -657,8 +487,8 @@ def deployv2(
657487
),
658488
):
659489
"""Deploy the app to the Reflex hosting service."""
490+
from reflex_cli.utils import dependency
660491
from reflex_cli.v2 import cli as hosting_cli
661-
from reflex_cli.v2.utils import dependency
662492

663493
from reflex.utils import export as export_utils
664494
from reflex.utils import prerequisites
@@ -702,23 +532,18 @@ def deployv2(
702532
envfile=envfile,
703533
hostname=hostname,
704534
interactive=interactive,
705-
loglevel=loglevel.subprocess_level(),
535+
loglevel=type(loglevel).INFO, # type: ignore
706536
token=token,
707537
project=project,
708538
)
709539

710540

711541
cli.add_typer(db_cli, name="db", help="Subcommands for managing the database schema.")
712542
cli.add_typer(script_cli, name="script", help="Subcommands running helper scripts.")
713-
cli.add_typer(
714-
deployments_cli,
715-
name="deployments",
716-
help="Subcommands for managing the Deployments.",
717-
)
718543
cli.add_typer(
719544
hosting_cli,
720-
name="apps",
721-
help="Subcommands for managing the Deployments.",
545+
name="cloud",
546+
help="Subcommands for managing the reflex cloud.",
722547
)
723548
cli.add_typer(
724549
custom_components_cli,

tests/integration/test_dynamic_routes.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ def cached_arg_str(self) -> str:
8989
@rx.page(route="/arg/[arg_str]")
9090
def arg() -> rx.Component:
9191
return rx.vstack(
92+
rx.input(
93+
value=DynamicState.router.session.client_token,
94+
read_only=True,
95+
id="token",
96+
),
9297
rx.data_list.root(
9398
rx.data_list.item(
9499
rx.data_list.label("rx.State.arg_str (dynamic)"),
@@ -373,12 +378,14 @@ async def test_on_load_navigate_non_dynamic(
373378
async def test_render_dynamic_arg(
374379
dynamic_route: AppHarness,
375380
driver: WebDriver,
381+
token: str,
376382
):
377383
"""Assert that dynamic arg var is rendered correctly in different contexts.
378384
379385
Args:
380386
dynamic_route: harness for DynamicRoute app.
381387
driver: WebDriver instance.
388+
token: The token visible in the driver browser.
382389
"""
383390
assert dynamic_route.app_instance is not None
384391
with poll_for_navigation(driver):
@@ -398,7 +405,8 @@ def assert_content(expected: str, expect_not: str):
398405
el = driver.find_element(By.ID, id)
399406
assert el
400407
assert (
401-
dynamic_route.poll_for_content(el, exp_not_equal=expect_not) == expected
408+
dynamic_route.poll_for_content(el, timeout=30, exp_not_equal=expect_not)
409+
== expected
402410
)
403411

404412
assert_content("0", "")

0 commit comments

Comments
 (0)