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: Update "tests/rerun_issue.py" to log traceback during exceptions #1896

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 catches exceptions but does not log the traceback. This makes it difficult to debug issues when they occur.

Here is the current code:

def wait_for_server(host: str):
    for i in range(120):
        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 fix this issue, import the traceback module and use traceback.print_exc() to print the traceback when an exception occurs. Here is an example of how to do this:

import traceback

def wait_for_server(host: str):
    for i in range(120):
        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",
            )
            traceback.print_exc()
            time.sleep(1)
            continue
sweep-nightly[bot] commented 1 year ago
Sweeping

0%

Actions (click)


❌ Unable to Complete PR

It looks like an issue has occurred around fetching the files. Perhaps the repo has not been initialized. If this error persists contact team@sweep.dev.

@sweep-nightly[bot], editing this issue description to include more details will automatically make me relaunch.

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


🎉 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.