aboutsummaryrefslogtreecommitdiff
path: root/cli.py
diff options
context:
space:
mode:
authorGravatar SwiftyOS <craigswift13@gmail.com> 2023-09-16 18:27:42 +0200
committerGravatar SwiftyOS <craigswift13@gmail.com> 2023-09-16 18:27:42 +0200
commit7fda0c78848dcc2e74507ee4d3d599f181286e1e (patch)
treed54b1807fdbf8b3ca077492c61fd52bbaf030ffe /cli.py
parentdeleted sync command (diff)
downloadAuto-GPT-7fda0c78848dcc2e74507ee4d3d599f181286e1e.tar.gz
Auto-GPT-7fda0c78848dcc2e74507ee4d3d599f181286e1e.tar.bz2
Auto-GPT-7fda0c78848dcc2e74507ee4d3d599f181286e1e.zip
removed submit command
Diffstat (limited to 'cli.py')
-rw-r--r--cli.py85
1 files changed, 0 insertions, 85 deletions
diff --git a/cli.py b/cli.py
index 1c8324715..d892139a9 100644
--- a/cli.py
+++ b/cli.py
@@ -447,91 +447,6 @@ Please replace this text with your own introduction, the names of your team memb
# Switch back to the master branch
subprocess.check_call(['git', 'checkout', branch_to_use])
-@arena.command()
-@click.argument('agent_name')
-@click.option('--branch', default='master', help='Branch to get the git hash from')
-def submit(agent_name, branch):
- import subprocess
- from github import Github
- from datetime import datetime
- import json
- import os
- agent_dir = f'./autogpts/{agent_name}'
- if not os.path.exists(agent_dir):
- click.echo(click.style(f"❌ The directory for agent '{agent_name}' does not exist in the autogpts directory.", fg='red'))
- click.echo(click.style(f"🚀 Run './run agent create {agent_name}' to create the agent. Then you can enter the arena with ./run arena enter", fg='yellow'))
- return
-
-
- # Check if there are staged changes
- staged_changes = [line for line in subprocess.check_output(['git', 'status', '--porcelain']).decode('utf-8').split('\n') if line and line[0] in ('A', 'M', 'D', 'R', 'C')]
- if staged_changes:
- click.echo(click.style(f"❌ There are staged changes. Please commit or stash them and run the command again.", fg='red'))
- return
-
- try:
- # Load GitHub access token from file
- with open('.github_access_token', 'r') as file:
- github_access_token = file.read().strip()
- arena_submission_branch = f'arena_submission_{agent_name}'
-
- # Get GitHub repository URL
- github_repo_url = subprocess.check_output(['git', 'config', '--get', 'remote.origin.url']).decode('utf-8').strip()
-
- # Get the git hash of the head of master or the provided branch
- commit_hash_to_benchmark = subprocess.check_output(['git', 'rev-parse', branch]).decode('utf-8').strip()
-
- # Stash any uncommitted changes
- subprocess.check_call(['git', 'stash'])
-
- # Switch to the arena_submission branch
- subprocess.check_call(['git', 'checkout', arena_submission_branch])
-
- # Update the agent_name.json file in the arena folder with the new hash and timestamp
- json_file_path = f'arena/{agent_name}.json'
- with open(json_file_path, 'r') as json_file:
- data = json.load(json_file)
-
- data['commit_hash_to_benchmark'] = commit_hash_to_benchmark
- data['timestamp'] = datetime.utcnow().isoformat()
-
- with open(json_file_path, 'w') as json_file:
- json.dump(data, json_file, indent=4)
-
- # Commit and push the changes
- subprocess.check_call(['git', 'add', json_file_path])
- subprocess.check_call(['git', 'commit', '-m', f'{agent_name} submitting to the arena'])
- subprocess.check_call(['git', 'push', 'origin', arena_submission_branch])
-
- # Create a new PR onto the fork's parent repo
- g = Github(github_access_token)
- repo = g.get_repo(github_repo_url.split(':')[-1].split('.git')[0])
- parent_repo = repo.parent
- if parent_repo:
- parent_repo.create_pull(
- title=f'{agent_name} submitting to the arena',
- body='''**Introduction:**
-
-**Team Members:**
-
-**Changes made to the agent:**
-
-Please replace this text with your own introduction, the names of your team members, a brief description of your work, and the changes you have made to your agent.''',
- head=f'{repo.owner.login}:{arena_submission_branch}',
- base=branch,
- )
- click.echo(click.style(f"🚀 {agent_name} has been submitted to the arena!", fg='green'))
- else:
- click.echo(click.style("❌ This repository does not have a parent repository to sync with.", fg='red'))
- return
-
- # Switch back to the original branch and pop the stashed changes
- subprocess.check_call(['git', 'checkout', branch])
- subprocess.check_call(['git', 'stash', 'pop'])
-
- except Exception as e:
- click.echo(click.style(f"❌ An error occurred: {e}", fg='red'))
-
if __name__ == '__main__':
cli()