reflex 0.7.14a2__py3-none-any.whl → 0.7.14a4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of reflex might be problematic. Click here for more details.

reflex/environment.py ADDED
@@ -0,0 +1,606 @@
1
+ """Environment variable management."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import concurrent.futures
6
+ import dataclasses
7
+ import enum
8
+ import inspect
9
+ import multiprocessing
10
+ import os
11
+ import platform
12
+ from collections.abc import Callable
13
+ from functools import lru_cache
14
+ from pathlib import Path
15
+ from typing import (
16
+ TYPE_CHECKING,
17
+ Annotated,
18
+ Any,
19
+ Generic,
20
+ TypeVar,
21
+ get_args,
22
+ get_origin,
23
+ get_type_hints,
24
+ )
25
+
26
+ from reflex import constants
27
+ from reflex.utils.exceptions import EnvironmentVarValueError
28
+ from reflex.utils.types import GenericType, is_union, value_inside_optional
29
+
30
+
31
+ def get_default_value_for_field(field: dataclasses.Field) -> Any:
32
+ """Get the default value for a field.
33
+
34
+ Args:
35
+ field: The field.
36
+
37
+ Returns:
38
+ The default value.
39
+
40
+ Raises:
41
+ ValueError: If no default value is found.
42
+ """
43
+ if field.default != dataclasses.MISSING:
44
+ return field.default
45
+ if field.default_factory != dataclasses.MISSING:
46
+ return field.default_factory()
47
+ msg = f"Missing value for environment variable {field.name} and no default value found"
48
+ raise ValueError(msg)
49
+
50
+
51
+ # TODO: Change all interpret_.* signatures to value: str, field: dataclasses.Field once we migrate rx.Config to dataclasses
52
+ def interpret_boolean_env(value: str, field_name: str) -> bool:
53
+ """Interpret a boolean environment variable value.
54
+
55
+ Args:
56
+ value: The environment variable value.
57
+ field_name: The field name.
58
+
59
+ Returns:
60
+ The interpreted value.
61
+
62
+ Raises:
63
+ EnvironmentVarValueError: If the value is invalid.
64
+ """
65
+ true_values = ["true", "1", "yes", "y"]
66
+ false_values = ["false", "0", "no", "n"]
67
+
68
+ if value.lower() in true_values:
69
+ return True
70
+ if value.lower() in false_values:
71
+ return False
72
+ msg = f"Invalid boolean value: {value} for {field_name}"
73
+ raise EnvironmentVarValueError(msg)
74
+
75
+
76
+ def interpret_int_env(value: str, field_name: str) -> int:
77
+ """Interpret an integer environment variable value.
78
+
79
+ Args:
80
+ value: The environment variable value.
81
+ field_name: The field name.
82
+
83
+ Returns:
84
+ The interpreted value.
85
+
86
+ Raises:
87
+ EnvironmentVarValueError: If the value is invalid.
88
+ """
89
+ try:
90
+ return int(value)
91
+ except ValueError as ve:
92
+ msg = f"Invalid integer value: {value} for {field_name}"
93
+ raise EnvironmentVarValueError(msg) from ve
94
+
95
+
96
+ def interpret_existing_path_env(value: str, field_name: str) -> ExistingPath:
97
+ """Interpret a path environment variable value as an existing path.
98
+
99
+ Args:
100
+ value: The environment variable value.
101
+ field_name: The field name.
102
+
103
+ Returns:
104
+ The interpreted value.
105
+
106
+ Raises:
107
+ EnvironmentVarValueError: If the path does not exist.
108
+ """
109
+ path = Path(value)
110
+ if not path.exists():
111
+ msg = f"Path does not exist: {path} for {field_name}"
112
+ raise EnvironmentVarValueError(msg)
113
+ return path
114
+
115
+
116
+ def interpret_path_env(value: str, field_name: str) -> Path:
117
+ """Interpret a path environment variable value.
118
+
119
+ Args:
120
+ value: The environment variable value.
121
+ field_name: The field name.
122
+
123
+ Returns:
124
+ The interpreted value.
125
+ """
126
+ return Path(value)
127
+
128
+
129
+ def interpret_enum_env(value: str, field_type: GenericType, field_name: str) -> Any:
130
+ """Interpret an enum environment variable value.
131
+
132
+ Args:
133
+ value: The environment variable value.
134
+ field_type: The field type.
135
+ field_name: The field name.
136
+
137
+ Returns:
138
+ The interpreted value.
139
+
140
+ Raises:
141
+ EnvironmentVarValueError: If the value is invalid.
142
+ """
143
+ try:
144
+ return field_type(value)
145
+ except ValueError as ve:
146
+ msg = f"Invalid enum value: {value} for {field_name}"
147
+ raise EnvironmentVarValueError(msg) from ve
148
+
149
+
150
+ def interpret_env_var_value(
151
+ value: str, field_type: GenericType, field_name: str
152
+ ) -> Any:
153
+ """Interpret an environment variable value based on the field type.
154
+
155
+ Args:
156
+ value: The environment variable value.
157
+ field_type: The field type.
158
+ field_name: The field name.
159
+
160
+ Returns:
161
+ The interpreted value.
162
+
163
+ Raises:
164
+ ValueError: If the value is invalid.
165
+ """
166
+ field_type = value_inside_optional(field_type)
167
+
168
+ if is_union(field_type):
169
+ msg = f"Union types are not supported for environment variables: {field_name}."
170
+ raise ValueError(msg)
171
+
172
+ if field_type is bool:
173
+ return interpret_boolean_env(value, field_name)
174
+ if field_type is str:
175
+ return value
176
+ if field_type is int:
177
+ return interpret_int_env(value, field_name)
178
+ if field_type is Path:
179
+ return interpret_path_env(value, field_name)
180
+ if field_type is ExistingPath:
181
+ return interpret_existing_path_env(value, field_name)
182
+ if get_origin(field_type) is list:
183
+ return [
184
+ interpret_env_var_value(
185
+ v,
186
+ get_args(field_type)[0],
187
+ f"{field_name}[{i}]",
188
+ )
189
+ for i, v in enumerate(value.split(":"))
190
+ ]
191
+ if inspect.isclass(field_type) and issubclass(field_type, enum.Enum):
192
+ return interpret_enum_env(value, field_type, field_name)
193
+
194
+ msg = f"Invalid type for environment variable {field_name}: {field_type}. This is probably an issue in Reflex."
195
+ raise ValueError(msg)
196
+
197
+
198
+ T = TypeVar("T")
199
+
200
+
201
+ class EnvVar(Generic[T]):
202
+ """Environment variable."""
203
+
204
+ name: str
205
+ default: Any
206
+ type_: T
207
+
208
+ def __init__(self, name: str, default: Any, type_: T) -> None:
209
+ """Initialize the environment variable.
210
+
211
+ Args:
212
+ name: The environment variable name.
213
+ default: The default value.
214
+ type_: The type of the value.
215
+ """
216
+ self.name = name
217
+ self.default = default
218
+ self.type_ = type_
219
+
220
+ def interpret(self, value: str) -> T:
221
+ """Interpret the environment variable value.
222
+
223
+ Args:
224
+ value: The environment variable value.
225
+
226
+ Returns:
227
+ The interpreted value.
228
+ """
229
+ return interpret_env_var_value(value, self.type_, self.name)
230
+
231
+ def getenv(self) -> T | None:
232
+ """Get the interpreted environment variable value.
233
+
234
+ Returns:
235
+ The environment variable value.
236
+ """
237
+ env_value = os.getenv(self.name, None)
238
+ if env_value and env_value.strip():
239
+ return self.interpret(env_value)
240
+ return None
241
+
242
+ def is_set(self) -> bool:
243
+ """Check if the environment variable is set.
244
+
245
+ Returns:
246
+ True if the environment variable is set.
247
+ """
248
+ return bool(os.getenv(self.name, "").strip())
249
+
250
+ def get(self) -> T:
251
+ """Get the interpreted environment variable value or the default value if not set.
252
+
253
+ Returns:
254
+ The interpreted value.
255
+ """
256
+ env_value = self.getenv()
257
+ if env_value is not None:
258
+ return env_value
259
+ return self.default
260
+
261
+ def set(self, value: T | None) -> None:
262
+ """Set the environment variable. None unsets the variable.
263
+
264
+ Args:
265
+ value: The value to set.
266
+ """
267
+ if value is None:
268
+ _ = os.environ.pop(self.name, None)
269
+ else:
270
+ if isinstance(value, enum.Enum):
271
+ value = value.value
272
+ if isinstance(value, list):
273
+ str_value = ":".join(str(v) for v in value)
274
+ else:
275
+ str_value = str(value)
276
+ os.environ[self.name] = str_value
277
+
278
+
279
+ @lru_cache
280
+ def get_type_hints_environment(cls: type) -> dict[str, Any]:
281
+ """Get the type hints for the environment variables.
282
+
283
+ Args:
284
+ cls: The class.
285
+
286
+ Returns:
287
+ The type hints.
288
+ """
289
+ return get_type_hints(cls)
290
+
291
+
292
+ class env_var: # noqa: N801 # pyright: ignore [reportRedeclaration]
293
+ """Descriptor for environment variables."""
294
+
295
+ name: str
296
+ default: Any
297
+ internal: bool = False
298
+
299
+ def __init__(self, default: Any, internal: bool = False) -> None:
300
+ """Initialize the descriptor.
301
+
302
+ Args:
303
+ default: The default value.
304
+ internal: Whether the environment variable is reflex internal.
305
+ """
306
+ self.default = default
307
+ self.internal = internal
308
+
309
+ def __set_name__(self, owner: Any, name: str):
310
+ """Set the name of the descriptor.
311
+
312
+ Args:
313
+ owner: The owner class.
314
+ name: The name of the descriptor.
315
+ """
316
+ self.name = name
317
+
318
+ def __get__(
319
+ self, instance: EnvironmentVariables, owner: type[EnvironmentVariables]
320
+ ):
321
+ """Get the EnvVar instance.
322
+
323
+ Args:
324
+ instance: The instance.
325
+ owner: The owner class.
326
+
327
+ Returns:
328
+ The EnvVar instance.
329
+ """
330
+ type_ = get_args(get_type_hints_environment(owner)[self.name])[0]
331
+ env_name = self.name
332
+ if self.internal:
333
+ env_name = f"__{env_name}"
334
+ return EnvVar(name=env_name, default=self.default, type_=type_)
335
+
336
+
337
+ if TYPE_CHECKING:
338
+
339
+ def env_var(default: Any, internal: bool = False) -> EnvVar:
340
+ """Typing helper for the env_var descriptor.
341
+
342
+ Args:
343
+ default: The default value.
344
+ internal: Whether the environment variable is reflex internal.
345
+
346
+ Returns:
347
+ The EnvVar instance.
348
+ """
349
+ return default
350
+
351
+
352
+ class PathExistsFlag:
353
+ """Flag to indicate that a path must exist."""
354
+
355
+
356
+ ExistingPath = Annotated[Path, PathExistsFlag]
357
+
358
+
359
+ class PerformanceMode(enum.Enum):
360
+ """Performance mode for the app."""
361
+
362
+ WARN = "warn"
363
+ RAISE = "raise"
364
+ OFF = "off"
365
+
366
+
367
+ class ExecutorType(enum.Enum):
368
+ """Executor for compiling the frontend."""
369
+
370
+ THREAD = "thread"
371
+ PROCESS = "process"
372
+ MAIN_THREAD = "main_thread"
373
+
374
+ @classmethod
375
+ def get_executor_from_environment(cls):
376
+ """Get the executor based on the environment variables.
377
+
378
+ Returns:
379
+ The executor.
380
+ """
381
+ from reflex.utils import console
382
+
383
+ executor_type = environment.REFLEX_COMPILE_EXECUTOR.get()
384
+
385
+ reflex_compile_processes = environment.REFLEX_COMPILE_PROCESSES.get()
386
+ reflex_compile_threads = environment.REFLEX_COMPILE_THREADS.get()
387
+ # By default, use the main thread. Unless the user has specified a different executor.
388
+ # Using a process pool is much faster, but not supported on all platforms. It's gated behind a flag.
389
+ if executor_type is None:
390
+ if (
391
+ platform.system() not in ("Linux", "Darwin")
392
+ and reflex_compile_processes is not None
393
+ ):
394
+ console.warn("Multiprocessing is only supported on Linux and MacOS.")
395
+
396
+ if (
397
+ platform.system() in ("Linux", "Darwin")
398
+ and reflex_compile_processes is not None
399
+ ):
400
+ if reflex_compile_processes == 0:
401
+ console.warn(
402
+ "Number of processes must be greater than 0. If you want to use the default number of processes, set REFLEX_COMPILE_EXECUTOR to 'process'. Defaulting to None."
403
+ )
404
+ reflex_compile_processes = None
405
+ elif reflex_compile_processes < 0:
406
+ console.warn(
407
+ "Number of processes must be greater than 0. Defaulting to None."
408
+ )
409
+ reflex_compile_processes = None
410
+ executor_type = ExecutorType.PROCESS
411
+ elif reflex_compile_threads is not None:
412
+ if reflex_compile_threads == 0:
413
+ console.warn(
414
+ "Number of threads must be greater than 0. If you want to use the default number of threads, set REFLEX_COMPILE_EXECUTOR to 'thread'. Defaulting to None."
415
+ )
416
+ reflex_compile_threads = None
417
+ elif reflex_compile_threads < 0:
418
+ console.warn(
419
+ "Number of threads must be greater than 0. Defaulting to None."
420
+ )
421
+ reflex_compile_threads = None
422
+ executor_type = ExecutorType.THREAD
423
+ else:
424
+ executor_type = ExecutorType.MAIN_THREAD
425
+
426
+ match executor_type:
427
+ case ExecutorType.PROCESS:
428
+ executor = concurrent.futures.ProcessPoolExecutor(
429
+ max_workers=reflex_compile_processes,
430
+ mp_context=multiprocessing.get_context("fork"),
431
+ )
432
+ case ExecutorType.THREAD:
433
+ executor = concurrent.futures.ThreadPoolExecutor(
434
+ max_workers=reflex_compile_threads
435
+ )
436
+ case ExecutorType.MAIN_THREAD:
437
+ FUTURE_RESULT_TYPE = TypeVar("FUTURE_RESULT_TYPE")
438
+
439
+ class MainThreadExecutor:
440
+ def __enter__(self):
441
+ return self
442
+
443
+ def __exit__(self, *args):
444
+ pass
445
+
446
+ def submit(
447
+ self, fn: Callable[..., FUTURE_RESULT_TYPE], *args, **kwargs
448
+ ) -> concurrent.futures.Future[FUTURE_RESULT_TYPE]:
449
+ future_job = concurrent.futures.Future()
450
+ future_job.set_result(fn(*args, **kwargs))
451
+ return future_job
452
+
453
+ executor = MainThreadExecutor()
454
+
455
+ return executor
456
+
457
+
458
+ class EnvironmentVariables:
459
+ """Environment variables class to instantiate environment variables."""
460
+
461
+ # Indicate the current command that was invoked in the reflex CLI.
462
+ REFLEX_COMPILE_CONTEXT: EnvVar[constants.CompileContext] = env_var(
463
+ constants.CompileContext.UNDEFINED, internal=True
464
+ )
465
+
466
+ # Whether to use npm over bun to install and run the frontend.
467
+ REFLEX_USE_NPM: EnvVar[bool] = env_var(False)
468
+
469
+ # The npm registry to use.
470
+ NPM_CONFIG_REGISTRY: EnvVar[str | None] = env_var(None)
471
+
472
+ # Whether to use Granian for the backend. By default, the backend uses Uvicorn if available.
473
+ REFLEX_USE_GRANIAN: EnvVar[bool] = env_var(False)
474
+
475
+ # Whether to use the system installed bun. If set to false, bun will be bundled with the app.
476
+ REFLEX_USE_SYSTEM_BUN: EnvVar[bool] = env_var(False)
477
+
478
+ # The working directory for the next.js commands.
479
+ REFLEX_WEB_WORKDIR: EnvVar[Path] = env_var(Path(constants.Dirs.WEB))
480
+
481
+ # The working directory for the states directory.
482
+ REFLEX_STATES_WORKDIR: EnvVar[Path] = env_var(Path(constants.Dirs.STATES))
483
+
484
+ # Path to the alembic config file
485
+ ALEMBIC_CONFIG: EnvVar[ExistingPath] = env_var(Path(constants.ALEMBIC_CONFIG))
486
+
487
+ # Disable SSL verification for HTTPX requests.
488
+ SSL_NO_VERIFY: EnvVar[bool] = env_var(False)
489
+
490
+ # The directory to store uploaded files.
491
+ REFLEX_UPLOADED_FILES_DIR: EnvVar[Path] = env_var(
492
+ Path(constants.Dirs.UPLOADED_FILES)
493
+ )
494
+
495
+ REFLEX_COMPILE_EXECUTOR: EnvVar[ExecutorType | None] = env_var(None)
496
+
497
+ # Whether to use separate processes to compile the frontend and how many. If not set, defaults to thread executor.
498
+ REFLEX_COMPILE_PROCESSES: EnvVar[int | None] = env_var(None)
499
+
500
+ # Whether to use separate threads to compile the frontend and how many. Defaults to `min(32, os.cpu_count() + 4)`.
501
+ REFLEX_COMPILE_THREADS: EnvVar[int | None] = env_var(None)
502
+
503
+ # The directory to store reflex dependencies.
504
+ REFLEX_DIR: EnvVar[Path] = env_var(constants.Reflex.DIR)
505
+
506
+ # Whether to print the SQL queries if the log level is INFO or lower.
507
+ SQLALCHEMY_ECHO: EnvVar[bool] = env_var(False)
508
+
509
+ # Whether to check db connections before using them.
510
+ SQLALCHEMY_POOL_PRE_PING: EnvVar[bool] = env_var(True)
511
+
512
+ # Whether to ignore the redis config error. Some redis servers only allow out-of-band configuration.
513
+ REFLEX_IGNORE_REDIS_CONFIG_ERROR: EnvVar[bool] = env_var(False)
514
+
515
+ # Whether to skip purging the web directory in dev mode.
516
+ REFLEX_PERSIST_WEB_DIR: EnvVar[bool] = env_var(False)
517
+
518
+ # The reflex.build frontend host.
519
+ REFLEX_BUILD_FRONTEND: EnvVar[str] = env_var(
520
+ constants.Templates.REFLEX_BUILD_FRONTEND
521
+ )
522
+
523
+ # The reflex.build backend host.
524
+ REFLEX_BUILD_BACKEND: EnvVar[str] = env_var(
525
+ constants.Templates.REFLEX_BUILD_BACKEND
526
+ )
527
+
528
+ # This env var stores the execution mode of the app
529
+ REFLEX_ENV_MODE: EnvVar[constants.Env] = env_var(constants.Env.DEV)
530
+
531
+ # Whether to run the backend only. Exclusive with REFLEX_FRONTEND_ONLY.
532
+ REFLEX_BACKEND_ONLY: EnvVar[bool] = env_var(False)
533
+
534
+ # Whether to run the frontend only. Exclusive with REFLEX_BACKEND_ONLY.
535
+ REFLEX_FRONTEND_ONLY: EnvVar[bool] = env_var(False)
536
+
537
+ # The port to run the frontend on.
538
+ REFLEX_FRONTEND_PORT: EnvVar[int | None] = env_var(None)
539
+
540
+ # The port to run the backend on.
541
+ REFLEX_BACKEND_PORT: EnvVar[int | None] = env_var(None)
542
+
543
+ # If this env var is set to "yes", App.compile will be a no-op
544
+ REFLEX_SKIP_COMPILE: EnvVar[bool] = env_var(False, internal=True)
545
+
546
+ # Whether to run app harness tests in headless mode.
547
+ APP_HARNESS_HEADLESS: EnvVar[bool] = env_var(False)
548
+
549
+ # Which app harness driver to use.
550
+ APP_HARNESS_DRIVER: EnvVar[str] = env_var("Chrome")
551
+
552
+ # Arguments to pass to the app harness driver.
553
+ APP_HARNESS_DRIVER_ARGS: EnvVar[str] = env_var("")
554
+
555
+ # Whether to check for outdated package versions.
556
+ REFLEX_CHECK_LATEST_VERSION: EnvVar[bool] = env_var(True)
557
+
558
+ # In which performance mode to run the app.
559
+ REFLEX_PERF_MODE: EnvVar[PerformanceMode] = env_var(PerformanceMode.WARN)
560
+
561
+ # The maximum size of the reflex state in kilobytes.
562
+ REFLEX_STATE_SIZE_LIMIT: EnvVar[int] = env_var(1000)
563
+
564
+ # Whether to use the turbopack bundler.
565
+ REFLEX_USE_TURBOPACK: EnvVar[bool] = env_var(False)
566
+
567
+ # Additional paths to include in the hot reload. Separated by a colon.
568
+ REFLEX_HOT_RELOAD_INCLUDE_PATHS: EnvVar[list[Path]] = env_var([])
569
+
570
+ # Paths to exclude from the hot reload. Takes precedence over include paths. Separated by a colon.
571
+ REFLEX_HOT_RELOAD_EXCLUDE_PATHS: EnvVar[list[Path]] = env_var([])
572
+
573
+ # Enables different behavior for when the backend would do a cold start if it was inactive.
574
+ REFLEX_DOES_BACKEND_COLD_START: EnvVar[bool] = env_var(False)
575
+
576
+ # The timeout for the backend to do a cold start in seconds.
577
+ REFLEX_BACKEND_COLD_START_TIMEOUT: EnvVar[int] = env_var(10)
578
+
579
+ # Used by flexgen to enumerate the pages.
580
+ REFLEX_ADD_ALL_ROUTES_ENDPOINT: EnvVar[bool] = env_var(False)
581
+
582
+ # The address to bind the HTTP client to. You can set this to "::" to enable IPv6.
583
+ REFLEX_HTTP_CLIENT_BIND_ADDRESS: EnvVar[str | None] = env_var(None)
584
+
585
+ # Maximum size of the message in the websocket server in bytes.
586
+ REFLEX_SOCKET_MAX_HTTP_BUFFER_SIZE: EnvVar[int] = env_var(
587
+ constants.POLLING_MAX_HTTP_BUFFER_SIZE
588
+ )
589
+
590
+ # The interval to send a ping to the websocket server in seconds.
591
+ REFLEX_SOCKET_INTERVAL: EnvVar[int] = env_var(constants.Ping.INTERVAL)
592
+
593
+ # The timeout to wait for a pong from the websocket server in seconds.
594
+ REFLEX_SOCKET_TIMEOUT: EnvVar[int] = env_var(constants.Ping.TIMEOUT)
595
+
596
+ # Whether to run Granian in a spawn process. This enables Reflex to pick up on environment variable changes between hot reloads.
597
+ REFLEX_STRICT_HOT_RELOAD: EnvVar[bool] = env_var(False)
598
+
599
+ # The path to the reflex log file. If not set, the log file will be stored in the reflex user directory.
600
+ REFLEX_LOG_FILE: EnvVar[Path | None] = env_var(None)
601
+
602
+ # Enable full logging of debug messages to reflex user directory.
603
+ REFLEX_ENABLE_FULL_LOGGING: EnvVar[bool] = env_var(False)
604
+
605
+
606
+ environment = EnvironmentVariables()
reflex/istate/manager.py CHANGED
@@ -17,7 +17,8 @@ from redis.asyncio.client import PubSub
17
17
  from typing_extensions import override
18
18
 
19
19
  from reflex import constants
20
- from reflex.config import environment, get_config
20
+ from reflex.config import get_config
21
+ from reflex.environment import environment
21
22
  from reflex.state import BaseState, _split_substate_key, _substate_key
22
23
  from reflex.utils import console, path_ops, prerequisites
23
24
  from reflex.utils.exceptions import (
reflex/model.py CHANGED
@@ -21,7 +21,8 @@ import sqlalchemy.orm
21
21
  from alembic.runtime.migration import MigrationContext
22
22
 
23
23
  from reflex.base import Base
24
- from reflex.config import environment, get_config
24
+ from reflex.config import get_config
25
+ from reflex.environment import environment
25
26
  from reflex.utils import console
26
27
  from reflex.utils.compat import sqlmodel, sqlmodel_field_has_primary_key
27
28
 
reflex/reflex.py CHANGED
@@ -11,9 +11,10 @@ import click
11
11
  from reflex_cli.v2.deployments import hosting_cli
12
12
 
13
13
  from reflex import constants
14
- from reflex.config import environment, get_config
14
+ from reflex.config import get_config
15
15
  from reflex.constants.base import LITERAL_ENV
16
16
  from reflex.custom_components.custom_components import custom_components_cli
17
+ from reflex.environment import environment
17
18
  from reflex.state import reset_disk_state_manager
18
19
  from reflex.utils import console, redir, telemetry
19
20
  from reflex.utils.exec import should_use_granian
reflex/state.py CHANGED
@@ -38,7 +38,7 @@ from typing_extensions import Self
38
38
  import reflex.istate.dynamic
39
39
  from reflex import constants, event
40
40
  from reflex.base import Base
41
- from reflex.config import PerformanceMode, environment
41
+ from reflex.environment import PerformanceMode, environment
42
42
  from reflex.event import (
43
43
  BACKGROUND_TASK_MARKER,
44
44
  Event,
reflex/testing.py CHANGED
@@ -28,6 +28,7 @@ import psutil
28
28
  import uvicorn
29
29
 
30
30
  import reflex
31
+ import reflex.environment
31
32
  import reflex.reflex
32
33
  import reflex.utils.build
33
34
  import reflex.utils.exec
@@ -35,7 +36,8 @@ import reflex.utils.format
35
36
  import reflex.utils.prerequisites
36
37
  import reflex.utils.processes
37
38
  from reflex.components.component import CustomComponent
38
- from reflex.config import environment, get_config
39
+ from reflex.config import get_config
40
+ from reflex.environment import environment
39
41
  from reflex.state import (
40
42
  BaseState,
41
43
  StateManager,