Merge branch 'main' into fix-readme-typos

This commit is contained in:
LeonOstrez
2023-11-04 20:27:33 +00:00
committed by GitHub
7 changed files with 38 additions and 25 deletions

View File

@@ -21,20 +21,15 @@ jobs:
run: docker ps
- name: Stop the Docker image
run: docker compose down
Test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# 3.10 - 04 Oct 2021
# 3.11 - 24 Oct 2022
python-version: ['3.9', '3.10', '3.11', '3.12']
# Test latest and oldest supported Python releases
# See https://devguide.python.org/versions/
python-version: ['3.9', '3.12']
os: [ubuntu-latest, macos-latest, windows-latest]
exclude:
# LINK : fatal error LNK1181: cannot open input file 'libpq.lib'
# Maybe related: https://github.com/psycopg/psycopg2/issues/1628
- os: windows-latest
python-version: '3.12'
steps:
- uses: actions/checkout@v4

View File

@@ -54,7 +54,8 @@ https://github.com/Pythagora-io/gpt-pilot/assets/10895136/0495631b-511e-451b-93d
# 🔌 Requirements
- **Python 3.9-3.11** (3.12 is currently not working due to a [dependency issue](https://github.com/psycopg/psycopg2/issues/1628))
- **Python 3.9-3.12**
- **PostgreSQL** (optional, projects default is SQLite)
- DB is needed for multiple reasons like continuing app development. If you have to stop at any point or the app crashes, go back to a specific step so that you can change some later steps in development, and easier debugging, in future we will add functionality to update project (change some things in existing project or add new features to the project and so on..)

View File

@@ -568,7 +568,7 @@ class Developer(Agent):
user_feedback = response['user_input']
if user_feedback is not None and user_feedback != 'continue':
debug_success = self.debugger.debug(convo, user_input=user_feedback, issue_description=description)
debug_success = self.debugger.debug(convo, user_input=user_feedback, issue_description=description) # noqa
# return_value = {'success': debug_success, 'user_input': user_feedback}
else:
return_value = {'success': True, 'user_input': user_feedback}

View File

@@ -168,6 +168,7 @@ This step will not be executed. no, use a better command
# Then
assert result == {'success': True, 'user_input': 'continue'}
@pytest.mark.skip("endless loop in questionary")
@patch('helpers.AgentConvo.get_saved_development_step')
@patch('helpers.AgentConvo.save_development_step')
@patch('helpers.AgentConvo.create_gpt_chat_completion')

View File

@@ -1,20 +1,27 @@
from unittest.mock import patch, MagicMock
import platform
from unittest.mock import patch, MagicMock, call
from helpers.cli import execute_command, terminate_process, run_command_until_success
from helpers.test_Project import create_project
@patch("helpers.cli.os")
@patch("helpers.cli.subprocess")
def test_terminate_process_not_running(mock_subprocess, mock_os):
terminate_process(1234, 'not running')
if platform.system() == 'Windows':
mock_subprocess.run.assert_called_once_with(["taskkill", "/F", "/T", "/PID", "1234"])
else:
mock_os.killpg.assert_called_once_with(1234, 9)
def test_terminate_process_not_running():
terminate_process(999999999, 'not running')
assert True
@patch("helpers.cli.MIN_COMMAND_RUN_TIME", create=True, new=100)
@patch('helpers.cli.get_saved_command_run')
@patch('helpers.cli.run_command')
def test_execute_command_timeout_exit_code(mock_run, mock_get_saved_command):
@patch("helpers.cli.terminate_process")
def test_execute_command_timeout_exit_code(mock_terminate_process, mock_run, mock_get_saved_command):
# Given
project = create_project()
command = 'ping www.google.com'
timeout = 1
command = 'cat'
timeout = 0.1
mock_process = MagicMock()
mock_process.poll.return_value = None
mock_process.pid = 1234
@@ -25,21 +32,27 @@ def test_execute_command_timeout_exit_code(mock_run, mock_get_saved_command):
# Then
assert cli_response is not None
assert llm_response == 'took longer than 2000ms so I killed it'
assert llm_response == 'took longer than 100.0ms so I killed it'
assert exit_code is not None
mock_terminate_process.assert_has_calls([
call(1234),
call(1234),
])
def mock_run_command(command, path, q, q_stderr):
q.put('hello')
mock_process = MagicMock()
mock_process.returncode = 0
mock_process.pid = 1234
return mock_process
@patch('helpers.cli.get_saved_command_run')
@patch('helpers.cli.ask_user', return_value='')
@patch('helpers.cli.run_command')
def test_execute_command_enter(mock_run, mock_ask, mock_get_saved_command):
@patch("helpers.cli.terminate_process")
def test_execute_command_enter(mock_terminate_process, mock_run, mock_ask, mock_get_saved_command):
# Given
project = create_project()
command = 'echo hello'
@@ -53,12 +66,14 @@ def test_execute_command_enter(mock_run, mock_ask, mock_get_saved_command):
assert 'hello' in cli_response
assert llm_response is None
assert exit_code == 0
mock_terminate_process.assert_called_once_with(1234)
@patch('helpers.cli.get_saved_command_run')
@patch('helpers.cli.ask_user', return_value='yes')
@patch('helpers.cli.run_command')
def test_execute_command_yes(mock_run, mock_ask, mock_get_saved_command):
@patch('helpers.cli.terminate_process')
def test_execute_command_yes(mock_terminate_process, mock_run, mock_ask, mock_get_saved_command):
# Given
project = create_project()
command = 'echo hello'
@@ -72,6 +87,7 @@ def test_execute_command_yes(mock_run, mock_ask, mock_get_saved_command):
assert 'hello' in cli_response
assert llm_response is None
assert exit_code == 0
mock_terminate_process.assert_called_once_with(1234)
@patch('helpers.cli.get_saved_command_run')

View File

@@ -25,7 +25,7 @@ class DotGptPilot:
def with_root_path(self, root_path: str, create=True):
if not USE_GPTPILOT_FOLDER:
return
dot_gpt_pilot_path = os.path.join(root_path, '.gpt-pilot')
dot_gpt_pilot_path = os.path.expanduser(os.path.join(root_path, '.gpt-pilot'))
self.dot_gpt_pilot_path = dot_gpt_pilot_path
# Create the `.gpt-pilot` directory if required.

View File

@@ -9,7 +9,7 @@ Jinja2==3.1.2
MarkupSafe==2.1.3
peewee==3.16.2
prompt-toolkit==3.0.39
psycopg2-binary==2.9.6
psycopg2-binary==2.9.9
python-dotenv==1.0.0
python-editor==1.0.4
pytest==7.4.2