File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -298,6 +298,7 @@ def initialize_module_visibility(
298298 coredata_core .ModuleVisibilityAwareness ,
299299 db ,
300300 )
301+ known_roots = module_awareness .roots
301302
302303 new_modules = [
303304 module
@@ -310,6 +311,7 @@ def initialize_module_visibility(
310311 f"Startup: Some modules visibility settings are empty, initializing them ({ [module .root for module in new_modules ]} )" ,
311312 )
312313 for module in new_modules :
314+ known_roots .append (module .root )
313315 if module .default_allowed_groups_ids is not None :
314316 for group_id in module .default_allowed_groups_ids :
315317 module_group_visibility = models_core .ModuleGroupVisibility (
@@ -343,9 +345,7 @@ def initialize_module_visibility(
343345 f"Startup: Could not add module visibility { module .root } in the database: { error } " ,
344346 )
345347 initialization .set_core_data_sync (
346- coredata_core .ModuleVisibilityAwareness (
347- roots = [module .root for module in get_module_list ()],
348- ),
348+ coredata_core .ModuleVisibilityAwareness (roots = known_roots ),
349349 db ,
350350 )
351351 hyperion_error_logger .info (
Original file line number Diff line number Diff line change 33from pathlib import Path
44
55from app .core .utils .config import Settings
6+ from app .types .exceptions import InvalidModuleRootInDotenvError
67from app .types .module import CoreModule , Module
78
89hyperion_error_logger = logging .getLogger ("hyperion.error" )
1213
1314
1415def init_module_list (settings : Settings ):
16+ _module_list .clear ()
17+ _core_module_list .clear ()
18+
1519 module_list = []
1620 for endpoints_file in Path ().glob ("app/modules/*/endpoints_*.py" ):
1721 endpoint_module = importlib .import_module (
@@ -29,7 +33,7 @@ def init_module_list(settings: Settings):
2933 existing_module_roots = [module .root for module in module_list ]
3034 for root in settings .RESTRICT_TO_MODULES :
3135 if root not in existing_module_roots :
32- raise ValueError ( )
36+ raise InvalidModuleRootInDotenvError ( root )
3337 for module in module_list :
3438 if (
3539 settings .RESTRICT_TO_MODULES
Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ def __init__(self):
3232 super ().__init__ ("Google API is not configured in dotenv" )
3333
3434
35+ class InvalidModuleRootInDotenvError (Exception ):
36+ def __init__ (self , root : str ):
37+ super ().__init__ (f"Module root { root } does not exist" )
38+
39+
3540class ContentHTTPException (HTTPException ):
3641 """
3742 A custom HTTPException allowing to return custom content.
You can’t perform that action at this time.
0 commit comments