diff --git a/pyproject.toml b/pyproject.toml index 1b30a083..41e24242 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "2.8.1" +version = "2.8.2" description = "Swarms - Pytorch" license = "MIT" authors = ["Kye Gomez "] diff --git a/scripts/get_package_requirements.py b/scripts/get_package_requirements.py index e6cd08c7..9494409b 100644 --- a/scripts/get_package_requirements.py +++ b/scripts/get_package_requirements.py @@ -1,8 +1,9 @@ import pkg_resources + def get_package_versions(requirements_path, output_path): try: - with open(requirements_path, 'r') as file: + with open(requirements_path, "r") as file: requirements = file.readlines() except FileNotFoundError: print(f"Error: The file '{requirements_path}' was not found.") @@ -12,21 +13,27 @@ def get_package_versions(requirements_path, output_path): for requirement in requirements: # Skip empty lines and comments - if requirement.strip() == '' or requirement.strip().startswith('#'): + if ( + requirement.strip() == "" + or requirement.strip().startswith("#") + ): continue - + # Extract package name - package_name = requirement.split('==')[0].strip() + package_name = requirement.split("==")[0].strip() try: - version = pkg_resources.get_distribution(package_name).version + version = pkg_resources.get_distribution( + package_name + ).version package_versions.append(f"{package_name}=={version}") except pkg_resources.DistributionNotFound: package_versions.append(f"{package_name}: not installed") - with open(output_path, 'w') as file: + with open(output_path, "w") as file: for package_version in package_versions: - file.write(package_version + '\n') + file.write(package_version + "\n") print(f"Versions written to {output_path}") + # Usage -get_package_versions('requirements.txt', 'installed_versions.txt') +get_package_versions("requirements.txt", "installed_versions.txt") diff --git a/scripts/requirementstxt_to_pyproject.py b/scripts/requirementstxt_to_pyproject.py new file mode 100644 index 00000000..5710db61 --- /dev/null +++ b/scripts/requirementstxt_to_pyproject.py @@ -0,0 +1,40 @@ +import toml +import pkg_resources + + +def update_pyproject_versions(pyproject_path): + try: + with open(pyproject_path, "r") as file: + data = toml.load(file) + except FileNotFoundError: + print(f"Error: The file '{pyproject_path}' was not found.") + return + except toml.TomlDecodeError: + print( + f"Error: The file '{pyproject_path}' is not a valid TOML" + " file." + ) + return + + dependencies = ( + data.get("tool", {}).get("poetry", {}).get("dependencies", {}) + ) + + for package in dependencies: + if package.lower() == "python": + continue # Skip the Python version dependency + + try: + version = pkg_resources.get_distribution(package).version + dependencies[package] = version + except pkg_resources.DistributionNotFound: + print(f"Warning: Package '{package}' not installed.") + + with open(pyproject_path, "w") as file: + toml.dump(data, file) + + print(f"Updated versions written to {pyproject_path}") + + +# Usage +update_pyproject_versions("pyproject.toml") diff --git a/swarms/__init__.py b/swarms/__init__.py index 9ceb78f2..fd7b75aa 100644 --- a/swarms/__init__.py +++ b/swarms/__init__.py @@ -6,3 +6,4 @@ from swarms.agents import * # noqa: E402, F403 from swarms.swarms import * # noqa: E402, F403 from swarms.structs import * # noqa: E402, F403 from swarms.models import * # noqa: E402, F403 +from swarms.telemetry import * # noqa: E402, F403 \ No newline at end of file diff --git a/tests/telemetry/user_utils.py b/tests/telemetry/user_utils.py index bbf854d4..c7b5962c 100644 --- a/tests/telemetry/user_utils.py +++ b/tests/telemetry/user_utils.py @@ -7,6 +7,7 @@ from swarms.telemetry.user_utils import ( get_system_info, ) + # Helper functions tests def test_generate_user_id(): # Generate user IDs and ensure they are UUID strings