Skip to content

fix: avoid calling set_ui_server_port() during LogSettings initialization (#1434)#1436

Open
utsab345 wants to merge 2 commits into
microsoft:mainfrom
utsab345:fix/log_settings-set_ui_server_port
Open

fix: avoid calling set_ui_server_port() during LogSettings initialization (#1434)#1436
utsab345 wants to merge 2 commits into
microsoft:mainfrom
utsab345:fix/log_settings-set_ui_server_port

Conversation

@utsab345

@utsab345 utsab345 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1434.

This PR resolves an AttributeError raised during LogSettings initialization by removing the dependency on set_ui_server_port() inside model_post_init.

Changes

  • Removed the call to self.set_ui_server_port() from LogSettings.model_post_init().

  • Inlined only the initialization-specific logic required during model construction:

    • Adds WebStorage to storages when ui_server_port is configured (including via LOG_UI_SERVER_PORT).
  • Preserved the existing set_ui_server_port() method unchanged for runtime use after initialization.

Why

model_post_init() should be self-contained and should not rely on another instance method during object construction. Calling set_ui_server_port() at initialization could result in an AttributeError if the method is unavailable at that stage of the model lifecycle.

This change preserves the original behavior while making the initialization process more robust.

Testing

Verified the following:

  • Default initialization works correctly.
  • Setting a UI server port updates the configuration as expected.
  • Clearing the UI server port behaves correctly.
  • LOG_UI_SERVER_PORT environment variable is handled correctly.
  • All existing tests pass (4/4).
  • server_ui starts successfully.
  • _run() subprocess path continues to work as expected.
  • set_ui_server_port() remains available and functional for runtime updates.

This change is limited to the initialization path and does not alter the runtime behavior of set_ui_server_port().


📚 Documentation preview 📚: https://RDAgent--1436.org.readthedocs.build/en/1436/

utsab added 2 commits June 30, 2026 22:26
…ctor_env/get_model_env

Both get_factor_env() and get_model_env() used extra_volumes: dict = {}
as default and unconditionally assigned env.conf.extra_volumes =
extra_volumes.copy(), which wiped out the correct defaults set by
QlibDockerConf (e.g., mounting ~/.qlib/ to /root/.qlib/). This caused
StopIteration in QTDockerEnv.prepare() when calling
next(iter(self.conf.extra_volumes.keys())) on the empty dict.

Changed default to None and only overwrite when a non-None value is
explicitly passed.
model_post_init should not depend on calling set_ui_server_port during
instance creation. Inline the init-time logic directly so that
LogSettings() construction is self-contained and does not rely on
another method being available on the class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'LogSettings' object has no attribute 'set_ui_server_port'

1 participant