-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1887 from opentensor/tests/gus/overview
feat: Refactor phase 2 overview cmd & add test cov. Adds factories
- Loading branch information
Showing
5 changed files
with
169 additions
and
13 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -12,3 +12,4 @@ mypy==1.8.0 | |
types-retry==0.9.9.4 | ||
freezegun==1.5.0 | ||
torch>=1.13.1 | ||
factory-boy==3.3.0 |
Empty file.
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,63 @@ | ||
import factory | ||
|
||
from bittensor.chain_data import AxonInfo, NeuronInfoLite, PrometheusInfo | ||
from bittensor.utils.balance import Balance | ||
|
||
|
||
class BalanceFactory(factory.Factory): | ||
class Meta: | ||
model = Balance | ||
|
||
balance = factory.Faker("pyfloat", left_digits=3, right_digits=6, positive=True) | ||
|
||
|
||
class PrometheusInfoFactory(factory.Factory): | ||
class Meta: | ||
model = PrometheusInfo | ||
|
||
block = factory.Faker("random_int", min=0, max=100) | ||
version = factory.Faker("random_int", min=0, max=100) | ||
ip = factory.Faker("ipv4") | ||
port = factory.Faker("random_int", min=0, max=100) | ||
ip_type = factory.Faker("random_int", min=0, max=100) | ||
|
||
|
||
class AxonInfoFactory(factory.Factory): | ||
class Meta: | ||
model = AxonInfo | ||
|
||
version = factory.Faker("random_int", min=0, max=100) | ||
ip = factory.Faker("ipv4") | ||
port = factory.Faker("random_int", min=0, max=100) | ||
ip_type = factory.Faker("random_int", min=0, max=100) | ||
hotkey = factory.Faker("uuid4") | ||
coldkey = factory.Faker("uuid4") | ||
|
||
|
||
class NeuronInfoLiteFactory(factory.Factory): | ||
class Meta: | ||
model = NeuronInfoLite | ||
|
||
hotkey = factory.Faker("uuid4") | ||
coldkey = factory.Faker("uuid4") | ||
uid = factory.Sequence(lambda n: n) | ||
netuid = factory.Sequence(lambda n: n) | ||
active = factory.Faker("random_int", min=0, max=1) | ||
stake = factory.SubFactory(BalanceFactory) | ||
stake_dict = factory.Dict({"balance": 10}) | ||
total_stake = factory.SubFactory(BalanceFactory) | ||
rank = factory.Faker("pyfloat", left_digits=3, right_digits=6, positive=True) | ||
emission = factory.Faker("pyfloat", left_digits=3, right_digits=6, positive=True) | ||
incentive = factory.Faker("pyfloat", left_digits=3, right_digits=6, positive=True) | ||
consensus = factory.Faker("pyfloat", left_digits=3, right_digits=6, positive=True) | ||
trust = factory.Faker("pyfloat", left_digits=3, right_digits=6, positive=True) | ||
validator_trust = factory.Faker( | ||
"pyfloat", left_digits=3, right_digits=6, positive=True | ||
) | ||
dividends = factory.Faker("pyfloat", left_digits=3, right_digits=6, positive=True) | ||
last_update = factory.Faker("unix_time") | ||
validator_permit = factory.Faker("boolean") | ||
prometheus_info = factory.SubFactory(PrometheusInfoFactory) | ||
axon_info = factory.SubFactory(AxonInfoFactory) | ||
pruning_score = factory.Faker("random_int", min=0, max=100) | ||
is_null = factory.Faker("boolean") |
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