Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
null0NULL123 opened this issue Apr 13, 2025 · 3 comments

Comments

@null0NULL123
Copy link

null0NULL123 commented Apr 13, 2025

Note: when running commands via the deepsearcher CLI, the configuration file located at deepsearcher/config.yaml seems to be loaded twice.

Describe the bug
It appears that the Configuration() class is instantiated multiple times within the execution path of a single CLI command (in cli.py). This results in the configuration file being read and potentially processed twice unnecessarily.

To Reproduce

  1. Modify the deepsearcher/configuration.py file.
  2. Add a print(config_path) statement inside the __init__ method of the Configuration class, right at the beginning (around line 36).
    class Configuration:
        def __init__(self, config_path: str = DEFAULT_CONFIG_YAML_PATH):
            print(f"Initializing Configuration with path: {config_path}") # Added for debugging
            # ... rest of the init method ...
  3. Run a deepsearcher CLI command (e.g., deepsearcher load ... or any other command that initializes the configuration).
  4. Observe the terminal output. You will see the "Initializing Configuration with path: ..." message printed twice, indicating that the Configuration class constructor is being called twice during the execution of a single command.

Image

Expected behavior
The configuration file should ideally be loaded only once per CLI command invocation to ensure efficiency and consistency.
Refactor the CLI command handling code (in cli.py) to ensure that the Configuration object is instantiated only once and shared where needed within the scope of a single command execution.

@zc277584121
Copy link
Collaborator

@null0NULL123 thank you for this suggestion, it's an issue. I think currently the cli configration is not flexible. I want to add a cli argument named config_path to align config approach with other ends, as well as make the cli configration more flexible. What 's your opinion?

@null0NULL123
Copy link
Author

Sorry for not responding sooner! I missed your reply from two weeks ago. @zc277584121

@null0NULL123
Copy link
Author

I think adding a --config_path CLI argument is a good idea. Also, I think the global config = Configuration() instance on line 174 of configuration.py should be removed in that it is also initialized in cli.py. @zc277584121

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

No branches or pull requests

3 participants
@zc277584121 @null0NULL123 and others