Skip to content

Conversation

asmacdo
Copy link
Member

@asmacdo asmacdo commented Sep 11, 2025

@yarikoptic this is a WIP, but non-draft since this could use design review before continuing into the weeds

TODO (adjust) At the high level:

  • startup using DEFAULT_CONFIG defined in __main__
  • retrieve -C --config first if passed
  • load in DEFAULT_CONFIG and then override from each file in order (colon separated)
  • use environment variables if they are present (this is also reflected in the config object
  • the config is then used by the CLI to set default values, which the user can override

NOTE! If you use config files, duct --help will show options' default values to be the ones specified in the config, which I think makes sense but a little unusual.

TODO:

  • fix tests
  • add tests
  • add to con-duct CLI
  • make sure -C --config shows up in helptext (currently not)
  • reconsider behavior "fail if user-provided paths DNE, but pass if default paths DNE" maybe just try and proceed with DEBUG
  • hand-test thoroughly
  • optional: use config everywhere instead of args. IMO nicer usage, but uglier code and a substantially large patch so not worth it
  • optional: add con-duct init-conf to scaffold a config.json file with all default values.

@asmacdo asmacdo requested a review from Copilot September 11, 2025 23:54
@asmacdo asmacdo added the semver-minor Increment the minor version when merged label Sep 11, 2025
Copy link

mergify bot commented Sep 11, 2025

🧪 CI Insights

Here's what we observed from your CI run for 0fb8b2c.

🟢 All jobs passed!

But CI Insights is watching 👀

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive configuration file support to the con-duct tool, allowing users to configure options through JSON files, environment variables, or command line arguments with proper precedence handling.

  • Implements a configuration system with precedence: defaults < config files < environment variables < CLI arguments
  • Refactors argument parsing to use a custom ConfigurableArgumentParser that integrates with the new config system
  • Updates the help text to reflect configuration capabilities and show current default values

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/con_duct/main.py Core implementation of config system including Config class, ConfigurableArgumentParser, and integration with argument parsing
src/con_duct/suite/main.py Added TODO comments for future config integration in the suite subcommands

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@asmacdo
Copy link
Member Author

asmacdo commented Sep 12, 2025

@yarikoptic also mergify says green but tests failed... now that I think about it, I'm not sure if I've seen mergify comments that were helpful, have you?

@asmacdo asmacdo changed the title enh: Add ability to read from config files enh: Support duct config files Sep 12, 2025
configuration:
Many options can be configured via JSON config file (--config), environment
variables, or command line arguments. Precedence: built-in defaults < config
file < environment variables < command line arguments.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
file < environment variables < command line arguments.
file(s) < environment variables < command line arguments.

per directory, per user, system?

@yarikoptic
Copy link
Member

I think we decided to go with jsonargparse and thus this PR could be closed

@yarikoptic yarikoptic closed this Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor Increment the minor version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to read from duct config
2 participants