@@ -395,11 +395,14 @@ def get_app(reload: bool = False) -> ModuleType:
395395 return app
396396
397397
398- def get_and_validate_app (reload : bool = False ) -> AppInfo :
398+ def get_and_validate_app (
399+ reload : bool = False , check_if_schema_up_to_date : bool = False
400+ ) -> AppInfo :
399401 """Get the app instance based on the default config and validate it.
400402
401403 Args:
402404 reload: Re-import the app module from disk
405+ check_if_schema_up_to_date: If True, check if the schema is up to date.
403406
404407 Returns:
405408 The app instance and the app module.
@@ -415,32 +418,47 @@ def get_and_validate_app(reload: bool = False) -> AppInfo:
415418 raise RuntimeError (
416419 "The app instance in the specified app_module_import in rxconfig must be an instance of rx.App."
417420 )
421+
422+ if check_if_schema_up_to_date :
423+ check_schema_up_to_date ()
424+
418425 return AppInfo (app = app , module = app_module )
419426
420427
421- def validate_app (reload : bool = False ) -> None :
428+ def validate_app (
429+ reload : bool = False , check_if_schema_up_to_date : bool = False
430+ ) -> None :
422431 """Validate the app instance based on the default config.
423432
424433 Args:
425434 reload: Re-import the app module from disk
435+ check_if_schema_up_to_date: If True, check if the schema is up to date.
426436 """
427- get_and_validate_app (reload = reload )
437+ get_and_validate_app (
438+ reload = reload , check_if_schema_up_to_date = check_if_schema_up_to_date
439+ )
428440
429441
430442def get_compiled_app (
431- reload : bool = False , export : bool = False , dry_run : bool = False
443+ reload : bool = False ,
444+ export : bool = False ,
445+ dry_run : bool = False ,
446+ check_if_schema_up_to_date : bool = False ,
432447) -> ModuleType :
433448 """Get the app module based on the default config after first compiling it.
434449
435450 Args:
436451 reload: Re-import the app module from disk
437452 export: Compile the app for export
438453 dry_run: If True, do not write the compiled app to disk.
454+ check_if_schema_up_to_date: If True, check if the schema is up to date.
439455
440456 Returns:
441457 The compiled app based on the default config.
442458 """
443- app , app_module = get_and_validate_app (reload = reload )
459+ app , app_module = get_and_validate_app (
460+ reload = reload , check_if_schema_up_to_date = check_if_schema_up_to_date
461+ )
444462 # For py3.9 compatibility when redis is used, we MUST add any decorator pages
445463 # before compiling the app in a thread to avoid event loop error (REF-2172).
446464 app ._apply_decorated_pages ()
@@ -449,16 +467,25 @@ def get_compiled_app(
449467
450468
451469def compile_app (
452- reload : bool = False , export : bool = False , dry_run : bool = False
470+ reload : bool = False ,
471+ export : bool = False ,
472+ dry_run : bool = False ,
473+ check_if_schema_up_to_date : bool = False ,
453474) -> None :
454475 """Compile the app module based on the default config.
455476
456477 Args:
457478 reload: Re-import the app module from disk
458479 export: Compile the app for export
459480 dry_run: If True, do not write the compiled app to disk.
481+ check_if_schema_up_to_date: If True, check if the schema is up to date.
460482 """
461- get_compiled_app (reload = reload , export = export , dry_run = dry_run )
483+ get_compiled_app (
484+ reload = reload ,
485+ export = export ,
486+ dry_run = dry_run ,
487+ check_if_schema_up_to_date = check_if_schema_up_to_date ,
488+ )
462489
463490
464491def _can_colorize () -> bool :
@@ -503,20 +530,23 @@ def _can_colorize() -> bool:
503530 return file .isatty ()
504531
505532
506- def compile_or_validate_app (compile : bool = False ) -> bool :
533+ def compile_or_validate_app (
534+ compile : bool = False , check_if_schema_up_to_date : bool = False
535+ ) -> bool :
507536 """Compile or validate the app module based on the default config.
508537
509538 Args:
510539 compile: Whether to compile the app.
540+ check_if_schema_up_to_date: If True, check if the schema is up to date.
511541
512542 Returns:
513543 If the app is compiled successfully.
514544 """
515545 try :
516546 if compile :
517- compile_app ()
547+ compile_app (check_if_schema_up_to_date = check_if_schema_up_to_date )
518548 else :
519- validate_app ()
549+ validate_app (check_if_schema_up_to_date = check_if_schema_up_to_date )
520550 except Exception as e :
521551 if isinstance (e , click .exceptions .Exit ):
522552 return False
0 commit comments