@@ -77,19 +77,6 @@ def _set_state_safe(obj: SettingsBase, state: StateType):
7777 datamodel_logger .debug (f"set_state failed at { obj .path } " )
7878
7979
80- def _import_settings_root (root ):
81- _class_dict = {}
82- api_keys = []
83- if hasattr (root , "child_names" ):
84- api_keys = root .child_names
85-
86- for root_item in api_keys :
87- _class_dict [root_item ] = root .__dict__ [root_item ]
88-
89- settings_api_root = type ("SettingsRoot" , (object ,), _class_dict )
90- return settings_api_root ()
91-
92-
9380class Solver (BaseSession ):
9481 """Encapsulates a Fluent solver session.
9582
@@ -143,9 +130,17 @@ def _build_from_fluent_connection(
143130 self ._tui = None
144131 self ._workflow = None
145132 self ._system_coupling = None
146- self ._settings_root = None
147133 self ._fluent_version = None
148134 self ._bg_session_threads = []
135+
136+ #: Root settings object.
137+ self .settings = flobject .get_root (
138+ flproxy = self ._settings_service ,
139+ version = self ._version ,
140+ interrupt = Solver ._interrupt ,
141+ file_transfer_service = self ._file_transfer_service ,
142+ scheme_eval = self .scheme_eval .scheme_eval ,
143+ )
149144 self ._solution_variable_service = service_creator ("svar" ).create (
150145 fluent_connection ._channel , fluent_connection ._metadata
151146 )
@@ -161,7 +156,6 @@ def _build_from_fluent_connection(
161156 )
162157 else :
163158 self .fields .reduction = reduction_old
164- self ._settings_api_root = None
165159 self .fields .solution_variable_data = self ._solution_variable_data ()
166160
167161 monitors_service = service_creator ("monitors" ).create (
@@ -270,19 +264,6 @@ def _interrupt(cls, command):
270264 if command .path in interruptible_commands :
271265 command ._root .solution .run_calculation .interrupt ()
272266
273- @property
274- def settings (self ):
275- """Root settings object."""
276- if self ._settings_root is None :
277- self ._settings_root = flobject .get_root (
278- flproxy = self ._settings_service ,
279- version = self ._version ,
280- interrupt = Solver ._interrupt ,
281- file_transfer_service = self ._file_transfer_service ,
282- scheme_eval = self .scheme_eval .scheme_eval ,
283- )
284- return self ._settings_root
285-
286267 @property
287268 def system_coupling (self ):
288269 """System coupling object."""
@@ -352,35 +333,23 @@ def set_state(self, state: StateT | None = None, **kwargs):
352333 def __call__ (self ):
353334 return self .get_state ()
354335
355- def _populate_settings_api_root (self ):
356- if not self ._settings_api_root :
357- self ._settings_api_root = _import_settings_root (self .settings )
358-
359- def __getattr__ (self , attr ):
360- self ._populate_settings_api_root ()
361- if not attr .startswith ("_" ) and attr in dir (self ._settings_api_root ):
362- if self .get_fluent_version () > FluentVersion .v242 :
336+ def __getattr__ (self , name ):
337+ try :
338+ return super ().__getattribute__ (name )
339+ except AttributeError as ex :
340+ if name in self .settings .child_names :
363341 warnings .warn (
364- f"'{ attr } ' is deprecated. Use 'settings.{ attr } ' instead." ,
342+ f"'{ name } ' is deprecated. Use 'settings.{ name } ' instead." ,
365343 DeprecatedSettingWarning ,
366344 )
367- # Try forwarding attribute access to the settings API root.
368- # If that fails with AttributeError, fall back to normal attribute lookup.
369- # Using object.__getattribute__ triggers the standard AttributeError with default messaging.
370- try :
371- return getattr (self ._settings_api_root , attr )
372- except AttributeError :
373- # Let standard attribute access raise the appropriate error
374- return object .__getattribute__ (self , attr )
345+ return getattr (self .settings , name )
346+ else :
347+ raise ex
375348
376349 def __dir__ (self ):
377350 if self ._fluent_connection is None :
378351 return ["is_active" ]
379- settings_dir = []
380- if self .get_fluent_version () <= FluentVersion .v242 :
381- self ._populate_settings_api_root ()
382- settings_dir = dir (self ._settings_api_root )
383- dir_list = set (list (self .__dict__ .keys ()) + dir (type (self )) + settings_dir ) - {
352+ dir_list = set (list (self .__dict__ .keys ()) + dir (type (self ))) - {
384353 "svar_data" ,
385354 "svar_info" ,
386355 "reduction" ,
0 commit comments