Skip to content

fix: eliminate duplicate Configuration init and add --config CLI arg#264

Open
octo-patch wants to merge 1 commit intozilliztech:masterfrom
octo-patch:fix/issue-197-config-loaded-twice
Open

fix: eliminate duplicate Configuration init and add --config CLI arg#264
octo-patch wants to merge 1 commit intozilliztech:masterfrom
octo-patch:fix/issue-197-config-loaded-twice

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #197

Problem

When any CLI command is executed, Configuration() is instantiated twice:

  1. First instantiation — the module-level config = Configuration() in configuration.py fires as a side-effect of the import statement in cli.py.
  2. Second instantiationcli.py explicitly calls config = Configuration() before init_config().

This is unnecessary: the module-level instance is never consumed by any code path — online_query.py and offline_loading.py access configuration.default_searcher, configuration.vector_db, etc., which are set only by init_config().

Solution

  1. Remove the unused config = Configuration() module-level statement from configuration.py.
  2. Move config initialization in cli.py to after argument parsing (avoids any startup overhead before the user's intent is known).
  3. Add a --config flag to the CLI so users can specify a custom YAML path without editing source files, as suggested in the issue thread.

Testing

  • Verified Configuration.__init__ is called exactly once when running a CLI command after the patch.
  • Existing examples and main.py are unaffected — they always instantiated Configuration() themselves and passed it to init_config().

…ixes zilliztech#197)

The module-level config = Configuration() in configuration.py was
instantiated on every import, causing a redundant second instantiation
when cli.py explicitly created its own Configuration object. Remove the
module-level instance since it is unused by any consumer.

Move config initialization in cli.py to after argument parsing, and add
a --config flag so users can point to a custom YAML file without
editing the source, as discussed in the issue thread.
@sre-ci-robot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: octo-patch
To complete the pull request process, please assign xiaofan-luan after the PR has been reviewed.
You can assign the PR to them by writing /assign @xiaofan-luan in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@octo-patch
Copy link
Copy Markdown
Author

/assign @xiaofan-luan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuration file (deepsearcher/config.yaml) is loaded twice during CLI command execution

3 participants