sweepai / sweep

Sweep: open-source AI-powered Software Developer for small features and bug fixes.
https://sweep.dev
Other
7.43k stars 425 forks source link

Sweep: Add traceback to exception handling in tests/rerun_issue.py #1852

Open sweep-nightly[bot] opened 1 year ago

sweep-nightly[bot] commented 1 year ago

In the file tests/rerun_issue.py, the function wait_for_server(host: str) does not log the traceback during exceptions. This is contrary to the user's rules which require all error logs to use traceback during exceptions.

Here is the code snippet that needs to be changed:

try:
    response = requests.get(host)
    if response.status_code == 200:
        break
except:
    print(
        f"Waited for server to start ({i+1}s)"
        + ("." * (i % 4) + " " * (4 - (i % 4))),
        end="\r",
    )
    time.sleep(1)
    continue

To conform to the rules, the except clause should be modified to log the traceback of the exception. This can be done using the traceback module in Python. Here is an example of how it can be done:

import traceback

try:
    response = requests.get(host)
    if response.status_code == 200:
        break
except Exception as e:
    print(
        f"Waited for server to start ({i+1}s)"
        + ("." * (i % 4) + " " * (4 - (i % 4))),
        end="\r",
    )
    print(traceback.format_exc())
    time.sleep(1)
    continue

Please make this change to ensure all exceptions are properly logged with traceback.

Checklist - [ ] `tests/rerun_issue.py`
sweep-nightly[bot] commented 1 year ago
Sweeping

50%

Actions (click)


❌ Unable to Complete PR

I'm sorry, but it looks like an error has occurred. Try changing the issue description to re-trigger Sweep. If this error persists contact team@sweep.dev.

For bonus GPT-4 tickets, please report this bug on Discord.


Please look at the generated plan. If something looks wrong, please add more details to your issue.

File Path Proposed Changes
tests/rerun_issue.py Modify tests/rerun_issue.py with contents:
❌ Unable to modify files in tests/
Edit sweep.yaml to configure.

🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.