[FEAT][__INIT__ update]

pull/299/head
Kye 1 year ago
parent c6ee451377
commit b0baec99c9

@ -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 <kye@apac.ai>"]

@ -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")

@ -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")

@ -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

@ -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

Loading…
Cancel
Save