4545from io import StringIO
4646from pathlib import Path
4747from shutil import rmtree
48- from types import MappingProxyType
48+ from types import MappingProxyType , SimpleNamespace
4949
5050import pandas as pd
5151from sqlglot import Dialect , exp
@@ -318,9 +318,7 @@ def __init__(
318318 self .configs = (
319319 config if isinstance (config , dict ) else load_configs (config , self .CONFIG_TYPE , paths )
320320 )
321- self ._loaders : UniqueKeyDict [str , t .Dict [str , Loader | t .Dict [Path , C ]]] = UniqueKeyDict (
322- "loaders"
323- )
321+ self ._loaders : UniqueKeyDict [str , SimpleNamespace ] = UniqueKeyDict ("loaders" )
324322 self .dag : DAG [str ] = DAG ()
325323 self ._models : UniqueKeyDict [str , Model ] = UniqueKeyDict ("models" )
326324 self ._audits : UniqueKeyDict [str , ModelAudit ] = UniqueKeyDict ("audits" )
@@ -337,11 +335,10 @@ def __init__(
337335 for path , config in self .configs .items ():
338336 project_type = c .DBT if issubclass (config .loader , DbtLoader ) else c .NATIVE
339337 if project_type not in self ._loaders :
340- self ._loaders [project_type ] = {
341- "loader" : (loader or config .loader )(** config .loader_kwargs ),
342- "configs" : {},
343- }
344- self ._loaders [project_type ]["configs" ][path ] = config
338+ self ._loaders [project_type ] = SimpleNamespace (
339+ loader = (loader or config .loader )(** config .loader_kwargs ), configs = {}
340+ )
341+ self ._loaders [project_type ].configs [path ] = config
345342
346343 self .project_type = c .HYBRID if len (self ._loaders ) > 1 else project_type
347344 self ._all_dialects : t .Set [str ] = {self .config .dialect or "" }
@@ -528,17 +525,17 @@ def state_reader(self) -> StateReader:
528525
529526 def refresh (self ) -> None :
530527 """Refresh all models that have been updated."""
531- if any (loader_dict [ " loader" ] .reload_needed () for loader_dict in self ._loaders .values ()):
528+ if any (context_loader . loader .reload_needed () for context_loader in self ._loaders .values ()):
532529 self .load ()
533530
534531 def load (self , update_schemas : bool = True ) -> GenericContext [C ]:
535532 """Load all files in the context's path."""
536533 load_start_ts = time .perf_counter ()
537534
538535 projects = []
539- for loader_dict in self ._loaders .values ():
540- with sys_path (* loader_dict [ " configs" ] ):
541- projects .append (loader_dict [ " loader" ] .load (self , update_schemas ))
536+ for context_loader in self ._loaders .values ():
537+ with sys_path (* context_loader . configs ):
538+ projects .append (context_loader . loader .load (self , update_schemas ))
542539
543540 self ._standalone_audits .clear ()
544541 self ._audits .clear ()
@@ -620,9 +617,9 @@ def run(
620617
621618 if not self ._loaded :
622619 # Signals should be loaded to run correctly.
623- for loader_dict in self ._loaders .values ():
624- with sys_path (* loader_dict [ " configs" ] ):
625- loader_dict [ " loader" ] .load_signals (self )
620+ for context_loader in self ._loaders .values ():
621+ with sys_path (* context_loader . configs ):
622+ context_loader . loader .load_signals (self )
626623
627624 success = False
628625 try :
0 commit comments