@@ -393,11 +393,14 @@ def get_app(reload: bool = False) -> ModuleType:
393393 return app
394394
395395
396- def get_and_validate_app (reload : bool = False ) -> AppInfo :
396+ def get_and_validate_app (
397+ reload : bool = False , check_if_schema_up_to_date : bool = False
398+ ) -> AppInfo :
397399 """Get the app instance based on the default config and validate it.
398400
399401 Args:
400402 reload: Re-import the app module from disk
403+ check_if_schema_up_to_date: If True, check if the schema is up to date.
401404
402405 Returns:
403406 The app instance and the app module.
@@ -412,32 +415,47 @@ def get_and_validate_app(reload: bool = False) -> AppInfo:
412415 if not isinstance (app , App ):
413416 msg = "The app instance in the specified app_module_import in rxconfig must be an instance of rx.App."
414417 raise RuntimeError (msg )
418+
419+ if check_if_schema_up_to_date :
420+ check_schema_up_to_date ()
421+
415422 return AppInfo (app = app , module = app_module )
416423
417424
418- def validate_app (reload : bool = False ) -> None :
425+ def validate_app (
426+ reload : bool = False , check_if_schema_up_to_date : bool = False
427+ ) -> None :
419428 """Validate the app instance based on the default config.
420429
421430 Args:
422431 reload: Re-import the app module from disk
432+ check_if_schema_up_to_date: If True, check if the schema is up to date.
423433 """
424- get_and_validate_app (reload = reload )
434+ get_and_validate_app (
435+ reload = reload , check_if_schema_up_to_date = check_if_schema_up_to_date
436+ )
425437
426438
427439def get_compiled_app (
428- reload : bool = False , export : bool = False , dry_run : bool = False
440+ reload : bool = False ,
441+ export : bool = False ,
442+ dry_run : bool = False ,
443+ check_if_schema_up_to_date : bool = False ,
429444) -> ModuleType :
430445 """Get the app module based on the default config after first compiling it.
431446
432447 Args:
433448 reload: Re-import the app module from disk
434449 export: Compile the app for export
435450 dry_run: If True, do not write the compiled app to disk.
451+ check_if_schema_up_to_date: If True, check if the schema is up to date.
436452
437453 Returns:
438454 The compiled app based on the default config.
439455 """
440- app , app_module = get_and_validate_app (reload = reload )
456+ app , app_module = get_and_validate_app (
457+ reload = reload , check_if_schema_up_to_date = check_if_schema_up_to_date
458+ )
441459 # For py3.9 compatibility when redis is used, we MUST add any decorator pages
442460 # before compiling the app in a thread to avoid event loop error (REF-2172).
443461 app ._apply_decorated_pages ()
@@ -446,16 +464,25 @@ def get_compiled_app(
446464
447465
448466def compile_app (
449- reload : bool = False , export : bool = False , dry_run : bool = False
467+ reload : bool = False ,
468+ export : bool = False ,
469+ dry_run : bool = False ,
470+ check_if_schema_up_to_date : bool = False ,
450471) -> None :
451472 """Compile the app module based on the default config.
452473
453474 Args:
454475 reload: Re-import the app module from disk
455476 export: Compile the app for export
456477 dry_run: If True, do not write the compiled app to disk.
478+ check_if_schema_up_to_date: If True, check if the schema is up to date.
457479 """
458- get_compiled_app (reload = reload , export = export , dry_run = dry_run )
480+ get_compiled_app (
481+ reload = reload ,
482+ export = export ,
483+ dry_run = dry_run ,
484+ check_if_schema_up_to_date = check_if_schema_up_to_date ,
485+ )
459486
460487
461488def _can_colorize () -> bool :
@@ -500,20 +527,23 @@ def _can_colorize() -> bool:
500527 return file .isatty ()
501528
502529
503- def compile_or_validate_app (compile : bool = False ) -> bool :
530+ def compile_or_validate_app (
531+ compile : bool = False , check_if_schema_up_to_date : bool = False
532+ ) -> bool :
504533 """Compile or validate the app module based on the default config.
505534
506535 Args:
507536 compile: Whether to compile the app.
537+ check_if_schema_up_to_date: If True, check if the schema is up to date.
508538
509539 Returns:
510540 If the app is compiled successfully.
511541 """
512542 try :
513543 if compile :
514- compile_app ()
544+ compile_app (check_if_schema_up_to_date = check_if_schema_up_to_date )
515545 else :
516- validate_app ()
546+ validate_app (check_if_schema_up_to_date = check_if_schema_up_to_date )
517547 except Exception as e :
518548 if isinstance (e , click .exceptions .Exit ):
519549 return False
0 commit comments