generated from kyegomez/Python-Package-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kye
committed
Dec 21, 2023
1 parent
4e7fcb9
commit 37f9877
Showing
8 changed files
with
108 additions
and
22 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ pandas | |
zetascale | ||
mamba-ssm | ||
causal-conv1d | ||
pytest | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# Navigate to the directory containing the 'swarms' folder | ||
# cd /path/to/your/code/directory | ||
|
||
# Run autopep8 with max aggressiveness (-aaa) and in-place modification (-i) | ||
# on all Python files (*.py) under the 'swarms' directory. | ||
autopep8 --in-place --aggressive --aggressive --recursive --experimental --list-fixes swarms/ | ||
|
||
# Run black with default settings, since black does not have an aggressiveness level. | ||
# Black will format all Python files it finds in the 'swarms' directory. | ||
black --experimental-string-processing swarms/ | ||
|
||
# Run ruff on the 'swarms' directory. | ||
# Add any additional flags if needed according to your version of ruff. | ||
ruff --unsafe_fix | ||
|
||
# YAPF | ||
yapf --recursive --in-place --verbose --style=google --parallel swarms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pkg_resources | ||
|
||
|
||
def get_package_versions(requirements_path, output_path): | ||
try: | ||
with open(requirements_path, "r") as file: | ||
requirements = file.readlines() | ||
except FileNotFoundError: | ||
print(f"Error: The file '{requirements_path}' was not found.") | ||
return | ||
|
||
package_versions = [] | ||
|
||
for requirement in requirements: | ||
# Skip empty lines and comments | ||
if ( | ||
requirement.strip() == "" | ||
or requirement.strip().startswith("#") | ||
): | ||
continue | ||
|
||
# Extract package name | ||
package_name = requirement.split("==")[0].strip() | ||
try: | ||
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: | ||
for package_version in package_versions: | ||
file.write(package_version + "\n") | ||
print(f"Versions written to {output_path}") | ||
|
||
|
||
# Usage | ||
get_package_versions("requirements.txt", "installed_versions.txt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
find ./tests -name "*.py" -type f | while read file | ||
do | ||
filename=$(basename "$file") | ||
dir=$(dirname "$file") | ||
if [[ $filename != test_* ]]; then | ||
mv "$file" "$dir/test_$filename" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
find ./tests -name '*.py' -exec pytest {} \; |