From 96b51b988a6d15e354f4c8d8e0fa60850443ad74 Mon Sep 17 00:00:00 2001 From: Kye Date: Fri, 21 Jul 2023 19:45:55 -0400 Subject: [PATCH] clean up --- setup.py | 2 +- swarms/swarms.py | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 03fa032a..87d95c0b 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup, find_packages setup( name = 'swarms', packages = find_packages(exclude=[]), - version = '0.9.3', + version = '0.9.4', license='MIT', description = 'Swarms - Pytorch', author = 'Kye Gomez', diff --git a/swarms/swarms.py b/swarms/swarms.py index bb0c86d4..82174de6 100644 --- a/swarms/swarms.py +++ b/swarms/swarms.py @@ -176,8 +176,8 @@ class Swarms: logging.error(f"An error occurred in run_swarms: {e}") return None -# usage- -def swarm(api_key="", objective=""): +# usage-# usage- +async def swarm(api_key="", objective=""): """ Run the swarm with the given API key and objective. @@ -197,15 +197,12 @@ def swarm(api_key="", objective=""): raise ValueError("A valid objective is required") try: swarms = Swarms(api_key) - loop = asyncio.get_event_loop() - tasks = [loop.create_task(swarms.run_swarms(objective))] - completed, pending = loop.run_until_complete(asyncio.wait(tasks)) - results = [t.result() for t in completed] - if not results or any(result is None for result in results): + result = await swarms.run_swarms(objective) + if result is None: logging.error("Failed to run swarms") else: - logging.info(f"Successfully ran swarms with results: {results}") - return results + logging.info(f"Successfully ran swarms with results: {result}") + return result except Exception as e: logging.error(f"An error occured in swarm: {e}") - return None \ No newline at end of file + return None