Rename loop-claude to build-release, with no alias
This commit is contained in:
@@ -12,7 +12,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
|
||||
|
||||
from failure import Failure
|
||||
from loop_effects.doubles import FakeEffects
|
||||
from chunk_driver.drivers import LOOP_CLAUDE
|
||||
from chunk_driver.drivers import BUILD_RELEASE
|
||||
from chunk_driver.project import model_choice
|
||||
from loop_state.paths import paths_from
|
||||
from text_files.file_writes import replace_file
|
||||
@@ -22,8 +22,8 @@ from agent_cycle.stop import Stop
|
||||
class Overridden(unittest.TestCase):
|
||||
def test_the_environment_names_the_judges_or_the_workers_model_over_the_default(self):
|
||||
self.assertEqual(model_choice.overridden({}, "saved"), model_choice.Models("saved", "saved"))
|
||||
self.assertEqual(model_choice.overridden({"LOOP_CLAUDE_JUDGE_MODEL": "j", "LOOP_CLAUDE_WORKER_MODEL": ""}, "saved"), model_choice.Models("j", "saved"))
|
||||
self.assertEqual(model_choice.overridden({"LOOP_CLAUDE_JUDGE_MODEL": "j", "LOOP_CLAUDE_WORKER_MODEL": "w"}, "saved"), model_choice.Models("j", "w"))
|
||||
self.assertEqual(model_choice.overridden({"BUILD_RELEASE_JUDGE_MODEL": "j", "BUILD_RELEASE_WORKER_MODEL": ""}, "saved"), model_choice.Models("j", "saved"))
|
||||
self.assertEqual(model_choice.overridden({"BUILD_RELEASE_JUDGE_MODEL": "j", "BUILD_RELEASE_WORKER_MODEL": "w"}, "saved"), model_choice.Models("j", "w"))
|
||||
|
||||
|
||||
class ModelsOfARun(unittest.TestCase):
|
||||
@@ -36,39 +36,39 @@ class ModelsOfARun(unittest.TestCase):
|
||||
def test_a_run_that_names_both_models_reads_no_models_file_and_asks_nothing(self):
|
||||
self.paths.models_file.write_text("not json")
|
||||
fake = FakeEffects()
|
||||
env = {"LOOP_CLAUDE_JUDGE_MODEL": "j", "LOOP_CLAUDE_WORKER_MODEL": "w"}
|
||||
self.assertEqual(model_choice.get_or_ask_models("proj", self.paths, env, LOOP_CLAUDE, fake.effects()), model_choice.Models("j", "w"))
|
||||
env = {"BUILD_RELEASE_JUDGE_MODEL": "j", "BUILD_RELEASE_WORKER_MODEL": "w"}
|
||||
self.assertEqual(model_choice.get_or_ask_models("proj", self.paths, env, BUILD_RELEASE, fake.effects()), model_choice.Models("j", "w"))
|
||||
self.assertEqual(fake.calls, [])
|
||||
|
||||
def test_a_run_that_names_one_model_takes_the_other_from_the_models_file(self):
|
||||
self.paths.models_file.write_text(json.dumps({"proj": "saved"}))
|
||||
fake = FakeEffects()
|
||||
self.assertEqual(model_choice.get_or_ask_models("proj", self.paths, {"LOOP_CLAUDE_JUDGE_MODEL": "j"}, LOOP_CLAUDE, fake.effects()), model_choice.Models("j", "saved"))
|
||||
self.assertEqual(model_choice.get_or_ask_models("proj", self.paths, {"LOOP_CLAUDE_WORKER_MODEL": "w"}, LOOP_CLAUDE, fake.effects()), model_choice.Models("saved", "w"))
|
||||
self.assertEqual(model_choice.get_or_ask_models("proj", self.paths, {"BUILD_RELEASE_JUDGE_MODEL": "j"}, BUILD_RELEASE, fake.effects()), model_choice.Models("j", "saved"))
|
||||
self.assertEqual(model_choice.get_or_ask_models("proj", self.paths, {"BUILD_RELEASE_WORKER_MODEL": "w"}, BUILD_RELEASE, fake.effects()), model_choice.Models("saved", "w"))
|
||||
self.assertEqual(fake.calls, [])
|
||||
|
||||
def test_a_run_that_names_one_model_asks_for_the_projects_where_none_is_saved_and_saves_the_pick(self):
|
||||
fake, said = FakeEffects(inputs=["my-model"]), io.StringIO()
|
||||
with contextlib.redirect_stderr(said):
|
||||
models = model_choice.get_or_ask_models("proj", self.paths, {"LOOP_CLAUDE_JUDGE_MODEL": "j"}, LOOP_CLAUDE, fake.effects())
|
||||
models = model_choice.get_or_ask_models("proj", self.paths, {"BUILD_RELEASE_JUDGE_MODEL": "j"}, BUILD_RELEASE, fake.effects())
|
||||
self.assertEqual(models, model_choice.Models("j", "my-model"))
|
||||
self.assertEqual(json.loads(self.paths.models_file.read_text()), {"proj": "my-model"})
|
||||
self.assertIn(" proj runs on my-model\n", said.getvalue())
|
||||
|
||||
def test_off_a_terminal_it_stops_naming_the_driver_to_rerun_and_the_file_to_merge_the_model_into(self):
|
||||
fake = FakeEffects(on_terminal=False)
|
||||
stop = model_choice.get_or_ask_models("proj", self.paths, {}, LOOP_CLAUDE, fake.effects())
|
||||
stop = model_choice.get_or_ask_models("proj", self.paths, {}, BUILD_RELEASE, fake.effects())
|
||||
assert isinstance(stop, Stop)
|
||||
self.assertEqual(stop.code, 2)
|
||||
self.assertIn(f"pick proj's model, or merge {{\"proj\": \"<model>\"}} into {self.paths.models_file}", stop.reason)
|
||||
self.assertIn(LOOP_CLAUDE, stop.reason)
|
||||
self.assertIn(BUILD_RELEASE, stop.reason)
|
||||
self.assertFalse(self.paths.models_file.exists())
|
||||
|
||||
def test_stops_with_exit_1_where_the_models_file_maps_no_projects_to_model_names(self):
|
||||
for held in ("[]", '{"proj": 5}', '{"proj": ""}'):
|
||||
with self.subTest(held=held):
|
||||
self.paths.models_file.write_text(held)
|
||||
stop = model_choice.get_or_ask_models("proj", self.paths, {}, LOOP_CLAUDE, FakeEffects().effects())
|
||||
stop = model_choice.get_or_ask_models("proj", self.paths, {}, BUILD_RELEASE, FakeEffects().effects())
|
||||
self.assertEqual(stop, Stop(1, f"could not read {self.paths.models_file}: not an object mapping projects to model names"))
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ class SavingAModel(unittest.TestCase):
|
||||
return Failure("could not save")
|
||||
|
||||
fake.replace_file = replace
|
||||
self.assertEqual(model_choice.get_or_ask_model("proj", self.paths, LOOP_CLAUDE, fake.effects()), Stop(1, f"could not save the model in {self.paths.models_file}: could not save"))
|
||||
self.assertEqual(model_choice.get_or_ask_model("proj", self.paths, BUILD_RELEASE, fake.effects()), Stop(1, f"could not save the model in {self.paths.models_file}: could not save"))
|
||||
self.assertEqual(held, [True])
|
||||
|
||||
|
||||
@@ -155,10 +155,10 @@ class ModelPrompt(unittest.TestCase):
|
||||
def test_asks_again_until_an_answer_picks_a_model(self):
|
||||
with tempfile.TemporaryDirectory() as empty:
|
||||
fake = FakeEffects(inputs=["", "my-model"])
|
||||
self.assertEqual(model_choice.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), LOOP_CLAUDE, fake.effects()), "my-model")
|
||||
self.assertEqual(model_choice.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), BUILD_RELEASE, fake.effects()), "my-model")
|
||||
self.assertEqual(len(fake.made("input")), 2)
|
||||
fake = FakeEffects(inputs=[EOFError()])
|
||||
self.assertEqual(model_choice.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), LOOP_CLAUDE, fake.effects()), Stop(2, "the human is needed to pick proj's model, but the input ended"))
|
||||
self.assertEqual(model_choice.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), BUILD_RELEASE, fake.effects()), Stop(2, "the human is needed to pick proj's model, but the input ended"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user