-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sweep: allow sweep.yaml to be read from the user/organization's .github repository. #2758
Comments
🚀 Here's the PR! #2764See Sweep's progress at the progress dashboard! 💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID:
4e91638360 )Actions (click)
Sandbox Execution ✓Here are the sandbox execution logs prior to making any changes: Sandbox logs for
|
@lru_cache(maxsize=None) | |
def get_branch_name_config(repo: Repository): | |
try: | |
contents = repo.get_contents("sweep.yaml") | |
description = yaml.safe_load(contents.decoded_content.decode("utf-8")).get( | |
"branch_use_underscores", False | |
) | |
return description | |
except SystemExit: | |
raise SystemExit | |
except Exception: | |
return False |
sweep/sweepai/config/client.py
Lines 166 to 192 in 5d2923a
@staticmethod | |
def get_draft(repo: Repository): | |
try: | |
contents = repo.get_contents("sweep.yaml") | |
config = yaml.safe_load(contents.decoded_content.decode("utf-8")) | |
return config.get("draft", False) | |
except SystemExit: | |
raise SystemExit | |
except Exception as e: | |
logger.warning(f"Error when getting draft: {e}, returning False") | |
return False | |
@lru_cache(maxsize=None) | |
def get_gha_enabled(repo: Repository) -> bool: | |
try: | |
contents = repo.get_contents("sweep.yaml") | |
gha_enabled = yaml.safe_load(contents.decoded_content.decode("utf-8")).get( | |
"gha_enabled", True | |
) | |
return gha_enabled | |
except SystemExit: | |
raise SystemExit | |
except Exception as e: | |
logger.exception( | |
f"Error when getting gha enabled: {e}, traceback: {traceback.format_exc()}, falling back to True" | |
) |
Step 2: ⌨️ Coding
Modify sweepai/config/client.py with contents:
• Modify the get_branch_name_config method to first check if the sweep.yaml file exists in the .github directory of the repository.
• If the file exists in the .github directory, read its contents and return the branch_use_underscores configuration.
• If the file does not exist in the .github directory, fall back to the current behavior of reading the file from the root of the repository.
• Make sure to handle any exceptions that may occur during this process.--- +++ @@ -225,7 +225,10 @@ @lru_cache(maxsize=None) def get_branch_name_config(repo: Repository): try: - contents = repo.get_contents("sweep.yaml") + try: + contents = repo.get_contents(".github/sweep.yaml") + except Exception: + contents = repo.get_contents("sweep.yaml") description = yaml.safe_load(contents.decoded_content.decode("utf-8")).get( "branch_use_underscores", False )
- Running GitHub Actions for
sweepai/config/client.py
✓ Edit
Check sweepai/config/client.py with contents:Ran GitHub Actions for e509f1c894a252fa606303a2bd3acee60a35c52c:
• black: ✓
• Vercel Preview Comments: ✓
Modify sweepai/config/client.py with contents:
• Modify the get_draft method to first check if the sweep.yaml file exists in the .github directory of the repository.
• If the file exists in the .github directory, read its contents and return the draft configuration.
• If the file does not exist in the .github directory, fall back to the current behavior of reading the file from the root of the repository.
• Make sure to handle any exceptions that may occur during this process.--- +++ @@ -166,7 +166,10 @@ @staticmethod def get_draft(repo: Repository): try: - contents = repo.get_contents("sweep.yaml") + try: + contents = repo.get_contents(".github/sweep.yaml") + except Exception: + contents = repo.get_contents("sweep.yaml") config = yaml.safe_load(contents.decoded_content.decode("utf-8")) return config.get("draft", False) except SystemExit: @@ -225,7 +228,10 @@ @lru_cache(maxsize=None) def get_branch_name_config(repo: Repository): try: - contents = repo.get_contents("sweep.yaml") + try: + contents = repo.get_contents(".github/sweep.yaml") + except Exception: + contents = repo.get_contents("sweep.yaml") description = yaml.safe_load(contents.decoded_content.decode("utf-8")).get( "branch_use_underscores", False )
- Running GitHub Actions for
sweepai/config/client.py
✓ Edit
Check sweepai/config/client.py with contents:Ran GitHub Actions for d6d8df8f45aa95e51f990128808c0c8c7deb6073:
• black: ✓
• Vercel Preview Comments: ✓
Modify sweepai/config/client.py with contents:
• Modify the get_gha_enabled method to first check if the sweep.yaml file exists in the .github directory of the repository.
• If the file exists in the .github directory, read its contents and return the gha_enabled configuration.
• If the file does not exist in the .github directory, fall back to the current behavior of reading the file from the root of the repository.
• Make sure to handle any exceptions that may occur during this process.--- +++ @@ -166,7 +166,10 @@ @staticmethod def get_draft(repo: Repository): try: - contents = repo.get_contents("sweep.yaml") + try: + contents = repo.get_contents(".github/sweep.yaml") + except Exception: + contents = repo.get_contents("sweep.yaml") config = yaml.safe_load(contents.decoded_content.decode("utf-8")) return config.get("draft", False) except SystemExit: @@ -179,7 +182,10 @@ @lru_cache(maxsize=None) def get_gha_enabled(repo: Repository) -> bool: try: - contents = repo.get_contents("sweep.yaml") + try: + contents = repo.get_contents(".github/sweep.yaml") + except Exception: + contents = repo.get_contents("sweep.yaml") gha_enabled = yaml.safe_load(contents.decoded_content.decode("utf-8")).get( "gha_enabled", True ) @@ -187,7 +193,7 @@ except SystemExit: raise SystemExit except Exception as e: - logger.exception( + logger.warning( f"Error when getting gha enabled: {e}, traceback: {traceback.format_exc()}, falling back to True" ) return True @@ -225,7 +231,10 @@ @lru_cache(maxsize=None) def get_branch_name_config(repo: Repository): try: - contents = repo.get_contents("sweep.yaml") + try: + contents = repo.get_contents(".github/sweep.yaml") + except Exception: + contents = repo.get_contents("sweep.yaml") description = yaml.safe_load(contents.decoded_content.decode("utf-8")).get( "branch_use_underscores", False )
- Running GitHub Actions for
sweepai/config/client.py
✓ Edit
Check sweepai/config/client.py with contents:Ran GitHub Actions for 586ea4a559661ae44b93a1496dc7347d197e7fc8:
• black: ✓
• Vercel Preview Comments: ✓
Step 3: 🔁 Code Review
I have finished reviewing the code for completeness. I did not find errors for sweep/allow_sweepyaml_to_be_read_from_the_user
.
🎉 Latest improvements to Sweep:
- We just released a dashboard to track Sweep's progress on your issue in real-time, showing every stage of the process – from search to planning and coding.
- Sweep uses OpenAI's latest Assistant API to plan code changes and modify code! This is 3x faster and significantly more reliable as it allows Sweep to edit code and validate the changes in tight iterations, the same way as a human would.
- Try using the GitHub issues extension to create Sweep issues directly from your editor! GitHub Issues and Pull Requests.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.
Join Our Discord
### I created this PR to address this rule: "Leftover TODOs in the code should be handled." ## Description This PR addresses the issue of a commented out TODO in the .vscode/launch.json file. As per our coding standards, we should not leave TODOs in the code. The TODO was a URL (#2758) that was not in use but might be necessary for future reference. ## Summary of Changes - Removed the commented out TODO on line 24 of .vscode/launch.json. Please review and let me know if there are any concerns. Co-authored-by: sweep-nightly[bot] <131841235+sweep-nightly[bot]@users.noreply.github.com>
Checklist
sweepai/config/client.py
✓ e509f1c Editsweepai/config/client.py
✓ Editsweepai/config/client.py
✓ d6d8df8 Editsweepai/config/client.py
✓ Editsweepai/config/client.py
✓ 586ea4a Editsweepai/config/client.py
✓ EditThe text was updated successfully, but these errors were encountered: