mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
fix: load yml config files most specific to least
This commit is contained in:
parent
95535b9294
commit
1cc1ce0bd4
2 changed files with 14 additions and 12 deletions
|
@ -324,6 +324,8 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
default_config_files.append(Path.home() / conf_fname) # homedir
|
default_config_files.append(Path.home() / conf_fname) # homedir
|
||||||
default_config_files = list(map(str, default_config_files))
|
default_config_files = list(map(str, default_config_files))
|
||||||
|
|
||||||
|
default_config_files.reverse()
|
||||||
|
|
||||||
parser = get_parser(default_config_files, git_root)
|
parser = get_parser(default_config_files, git_root)
|
||||||
args, unknown = parser.parse_known_args(argv)
|
args, unknown = parser.parse_known_args(argv)
|
||||||
|
|
||||||
|
|
|
@ -394,15 +394,25 @@ class TestMain(TestCase):
|
||||||
cwd_config = cwd / ".aider.conf.yml"
|
cwd_config = cwd / ".aider.conf.yml"
|
||||||
named_config = git_dir / "named.aider.conf.yml"
|
named_config = git_dir / "named.aider.conf.yml"
|
||||||
|
|
||||||
home_config.write_text("model: gpt-3.5-turbo\nmap-tokens: 1024\n")
|
|
||||||
git_config.write_text("model: gpt-4\nmap-tokens: 2048\n")
|
|
||||||
cwd_config.write_text("model: gpt-4-32k\nmap-tokens: 4096\n")
|
cwd_config.write_text("model: gpt-4-32k\nmap-tokens: 4096\n")
|
||||||
|
git_config.write_text("model: gpt-4\nmap-tokens: 2048\n")
|
||||||
|
home_config.write_text("model: gpt-3.5-turbo\nmap-tokens: 1024\n")
|
||||||
named_config.write_text("model: gpt-4-1106-preview\nmap-tokens: 8192\n")
|
named_config.write_text("model: gpt-4-1106-preview\nmap-tokens: 8192\n")
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch("pathlib.Path.home", return_value=fake_home),
|
patch("pathlib.Path.home", return_value=fake_home),
|
||||||
patch("aider.coders.Coder.create") as MockCoder,
|
patch("aider.coders.Coder.create") as MockCoder,
|
||||||
):
|
):
|
||||||
|
# Test loading from specified config file
|
||||||
|
main(
|
||||||
|
["--yes", "--exit", "--config", str(named_config)],
|
||||||
|
input=DummyInput(),
|
||||||
|
output=DummyOutput(),
|
||||||
|
)
|
||||||
|
_, kwargs = MockCoder.call_args
|
||||||
|
self.assertEqual(kwargs["main_model"].name, "gpt-4-1106-preview")
|
||||||
|
self.assertEqual(kwargs["map_tokens"], 8192)
|
||||||
|
|
||||||
# Test loading from current working directory
|
# Test loading from current working directory
|
||||||
main(["--yes", "--exit"], input=DummyInput(), output=DummyOutput())
|
main(["--yes", "--exit"], input=DummyInput(), output=DummyOutput())
|
||||||
_, kwargs = MockCoder.call_args
|
_, kwargs = MockCoder.call_args
|
||||||
|
@ -425,16 +435,6 @@ class TestMain(TestCase):
|
||||||
self.assertEqual(kwargs["main_model"].name, "gpt-3.5-turbo")
|
self.assertEqual(kwargs["main_model"].name, "gpt-3.5-turbo")
|
||||||
self.assertEqual(kwargs["map_tokens"], 1024)
|
self.assertEqual(kwargs["map_tokens"], 1024)
|
||||||
|
|
||||||
# Test loading from specified config file
|
|
||||||
main(
|
|
||||||
["--yes", "--exit", "--config", str(named_config)],
|
|
||||||
input=DummyInput(),
|
|
||||||
output=DummyOutput(),
|
|
||||||
)
|
|
||||||
_, kwargs = MockCoder.call_args
|
|
||||||
self.assertEqual(kwargs["main_model"].name, "gpt-4-1106-preview")
|
|
||||||
self.assertEqual(kwargs["map_tokens"], 8192)
|
|
||||||
|
|
||||||
def test_map_tokens_option(self):
|
def test_map_tokens_option(self):
|
||||||
with GitTemporaryDirectory():
|
with GitTemporaryDirectory():
|
||||||
with patch("aider.coders.base_coder.RepoMap") as MockRepoMap:
|
with patch("aider.coders.base_coder.RepoMap") as MockRepoMap:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue