def unregister_model(model): """Remove model from all models. This function removes the given model from the main ggrc module and the all_models list. Args: model: sqlalchemy model that should be removed from the ggrc module """ current_module = sys.modules[__name__] delattr(current_module, model.__name__) inflector.unregister_inflector(model._inflector) if model in all_models: all_models.remove(model) if model.__name__ in __all__: __all__.remove(model.__name__)