Skip to content

Commit

Permalink
Merge branch 'staging' into tests/gus/overview
Browse files Browse the repository at this point in the history
  • Loading branch information
gus-opentensor committed May 17, 2024
2 parents 6f32495 + 0a44098 commit a34cc07
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
7 changes: 2 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,6 @@ jobs:
workflows:
compatibility_checks:
jobs:
- check_compatibility:
python_version: "3.8"
name: check-compatibility-3.8
- check_compatibility:
python_version: "3.9"
name: check-compatibility-3.9
Expand All @@ -294,7 +291,7 @@ workflows:
pr-requirements:
jobs:
- black:
python-version: "3.8.12"
python-version: "3.9.13"
- build-and-test:
matrix:
parameters:
Expand All @@ -305,7 +302,7 @@ workflows:
- lint-and-type-check:
matrix:
parameters:
python-version: ["3.8.12", "3.9.13", "3.10.6"]
python-version: ["3.9.13", "3.10.6", "3.11.4"]
requires:
- build-and-test
#- coveralls:
Expand Down
13 changes: 6 additions & 7 deletions bittensor/keyfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,12 @@ def get_coldkey_password_from_environment(coldkey_name: str) -> Optional[str]:
Returns:
password (str): The password retrieved from the environment variables, or ``None`` if not found.
"""
for env_var in os.environ:
if env_var.upper().startswith("BT_COLD_PW_") and env_var.upper().endswith(
coldkey_name.upper()
):
return os.getenv(env_var)

return None
envs = {
normalized_env_name: env_value
for env_name, env_value in os.environ.items()
if (normalized_env_name := env_name.upper()).startswith("BT_COLD_PW_")
}
return envs.get(f"BT_COLD_PW_{coldkey_name.upper()}")


def decrypt_keyfile_data(
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def read_requirements(path):
include_package_data=True,
author_email="",
license="MIT",
python_requires=">=3.8",
python_requires=">=3.9",
install_requires=requirements,
extras_require={
"dev": extra_requirements_dev,
Expand All @@ -85,9 +85,9 @@ def read_requirements(path):
# Pick your license as you wish
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
Expand Down
17 changes: 17 additions & 0 deletions tests/unit_tests/test_keyfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from substrateinterface.exceptions import ConfigurationError
from bip39 import bip39_validate

from bittensor import get_coldkey_password_from_environment


def test_generate_mnemonic():
"""
Expand Down Expand Up @@ -606,3 +608,18 @@ def test_deserialize_keypair_from_keyfile_data(keyfile_setup_teardown):
assert deserialized_keypair.ss58_address == keypair.ss58_address
assert deserialized_keypair.public_key == keypair.public_key
assert deserialized_keypair.private_key == keypair.private_key


def test_get_coldkey_password_from_environment(monkeypatch):
password_by_wallet = {
"WALLET": "password",
"my_wallet": "password",
}

monkeypatch.setenv("bt_cold_pw_wallet", password_by_wallet["WALLET"])
monkeypatch.setenv("BT_COLD_PW_My_Wallet", password_by_wallet["my_wallet"])

for wallet, password in password_by_wallet.items():
assert get_coldkey_password_from_environment(wallet) == password

assert get_coldkey_password_from_environment("non_existent_wallet") is None

0 comments on commit a34cc07

Please sign in to comment.