pull/286/head
Kye 1 year ago
parent f68832af38
commit 39888fcb3b

@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "swarms"
version = "2.6.0"
version = "2.6.1"
description = "Swarms - Pytorch"
license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"]
@ -94,3 +94,8 @@ target-version = ['py38']
preview = true
[tool.poetry.scripts]
swarms = "swarms.cli._cli:run_file"

@ -0,0 +1,40 @@
# import argparse
# import sys
# def run_file():
# parser = argparse.ArgumentParser(description='Swarms CLI')
# parser.add_argument('file_name', help='Python file containing Swarms code to run')
# # Help message for the -h flag is automatically generated by argparse
# parser.add_argument('-v', '--version', action='version', version='%(prog)s 0.1.0')
# # Check deployments for a given model
# parser.add_argument('-c', '--check', help='Check deployments for a given agent')
# args = parser.parse_args()
# # Execute the specified file
# try:
# with open(args.file_name, 'r') as file:
# exec(file.read(), globals())
# except FileNotFoundError:
# print(f"Error: File '{args.file_name}' not found.")
# sys.exit(1)
# except Exception as e:
# print(f"Error executing file '{args.file_name}': {e}")
# sys.exit(1)
# if __name__ == '__main__':
# main()
# swarms/cli/_cli.py
import sys
import subprocess
def run_file():
if len(sys.argv) != 3 or sys.argv[1] != "run":
print("Usage: swarms run file_name.py")
sys.exit(1)
file_name = sys.argv[2]
subprocess.run(["python", file_name], check=True)

@ -12,18 +12,18 @@ try:
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import Session
except ImportError:
print("The PgVectorVectorStore requires sqlalchemy to be installed")
print(
"The PgVectorVectorStore requires sqlalchemy to be installed"
)
print("pip install sqlalchemy")
subprocess.run(["pip", "install", "sqlalchemy"])
try:
from pgvector.sqlalchemy import Vector
except ImportError:
print("The PgVectorVectorStore requires pgvector to be installed")
print("pip install pgvector")
subprocess.run(["pip", "install", "pgvector"])
@define

@ -3,7 +3,6 @@ from typing import List
from httpx import RequestError
try:
from sentence_transformers import SentenceTransformer
except ImportError:
print("Please install the sentence-transformers package")
@ -13,7 +12,6 @@ except ImportError:
try:
from qdrant_client import QdrantClient
from qdrant_client.http.models import (
Distance,

@ -8,51 +8,60 @@ from dotenv import load_dotenv
load_dotenv
# Constants
GITHUB_USERNAME = os.getenv('GITHUB_USERNAME')
REPO_NAME = os.getenv('GITHUB_REPO_NAME')
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
ISSUES_URL = f'https://api.github.com/repos/{GITHUB_USERNAME}/{REPO_NAME}/issues'
GITHUB_USERNAME = os.getenv("GITHUB_USERNAME")
REPO_NAME = os.getenv("GITHUB_REPO_NAME")
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
ISSUES_URL = f"https://api.github.com/repos/{GITHUB_USERNAME}/{REPO_NAME}/issues"
# Headers for authentication
headers = {
'Authorization': f'token {GITHUB_TOKEN}',
'Accept': 'application/vnd.github.v3+json'
"Authorization": f"token {GITHUB_TOKEN}",
"Accept": "application/vnd.github.v3+json",
}
def run_pytest():
result = subprocess.run(['pytest'], capture_output=True, text=True)
result = subprocess.run(
["pytest"], capture_output=True, text=True
)
return result.stdout + result.stderr
def parse_pytest_output(output):
errors = []
current_error = None
for line in output.split('\n'):
if line.startswith('_________________________'):
for line in output.split("\n"):
if line.startswith("_________________________"):
if current_error:
errors.append(current_error)
current_error = {'title': '', 'body': ''}
current_error = {"title": "", "body": ""}
elif current_error is not None:
if not current_error['title']:
current_error['title'] = line.strip()
current_error['body'] += line + '\n'
if not current_error["title"]:
current_error["title"] = line.strip()
current_error["body"] += line + "\n"
if current_error:
errors.append(current_error)
return errors
def create_github_issue(title, body):
issue = {'title': title, 'body': body}
issue = {"title": title, "body": body}
response = requests.post(ISSUES_URL, headers=headers, json=issue)
return response.json()
def main():
pytest_output = run_pytest()
errors = parse_pytest_output(pytest_output)
for error in errors:
issue_response = create_github_issue(error['title'], error['body'])
issue_response = create_github_issue(
error["title"], error["body"]
)
print(f"Issue created: {issue_response.get('html_url')}")
if __name__ == '__main__':
if __name__ == "__main__":
main()

Loading…
Cancel
Save