Skip to content

Commit 2e4f15c

Browse files
fixup
1 parent 43f915d commit 2e4f15c

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

app/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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(

app/module.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44

55
from app.core.utils.config import Settings
6+
from app.types.exceptions import InvalidModuleRootInDotenvError
67
from app.types.module import CoreModule, Module
78

89
hyperion_error_logger = logging.getLogger("hyperion.error")
@@ -12,6 +13,9 @@
1213

1314

1415
def 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

app/types/exceptions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
3540
class ContentHTTPException(HTTPException):
3641
"""
3742
A custom HTTPException allowing to return custom content.

0 commit comments

Comments
 (0)