From ad4ab4940efe45716e71a7706ec75b73dc8399f5 Mon Sep 17 00:00:00 2001 From: Trevor Decker Date: Wed, 29 Mar 2023 06:23:54 +0000 Subject: [PATCH 1/2] have pytest auto pip installed, if it was not already installed --- agent/agi.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/agent/agi.py b/agent/agi.py index ebe0ad3..4262788 100644 --- a/agent/agi.py +++ b/agent/agi.py @@ -98,9 +98,13 @@ def call_test(purpose, task, history, directory, action_input): text=True, ) if result.returncode != 0: - history += "observation: there are no tests! Test should be written in a test folder under {}\n".format( - directory - ) + if "No module named pytest" in result.stderr: + os.system("pip install pytest") + history += "observation: pytest was not installed, so it was installed\n" + else: + history += "observation: there are no tests! Test should be written in a test folder under {}\n".format( + directory + ) return "MAIN", None, history, task result = subprocess.run( ["python", "-m", "pytest", directory], capture_output=True, text=True From 96c3aed056eb00eeb8267ff3837cceee746e5ffd Mon Sep 17 00:00:00 2001 From: Trevor Decker Date: Thu, 30 Mar 2023 01:30:47 +0000 Subject: [PATCH 2/2] moved pytest to be an exception asking the user to install instead of doing it for them --- agent/agi.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/agent/agi.py b/agent/agi.py index 4262788..029f3ae 100644 --- a/agent/agi.py +++ b/agent/agi.py @@ -99,8 +99,7 @@ def call_test(purpose, task, history, directory, action_input): ) if result.returncode != 0: if "No module named pytest" in result.stderr: - os.system("pip install pytest") - history += "observation: pytest was not installed, so it was installed\n" + raise Exception("pytest not installed. Please install pytest (pip install pytest)") else: history += "observation: there are no tests! Test should be written in a test folder under {}\n".format( directory