Skip to content

Commit

Permalink
Use DecimalField for hyperparameter values
Browse files Browse the repository at this point in the history
  • Loading branch information
olzhasar-reef committed May 6, 2024
1 parent 09dbcd9 commit 7ed0f44
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
14 changes: 11 additions & 3 deletions app/src/bittensor_panel/core/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.11 on 2024-05-03 20:44
# Generated by Django 4.2.11 on 2024-05-06 16:07

from django.db import migrations, models

Expand All @@ -12,11 +12,19 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name="HyperParameter",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("name", models.CharField(max_length=255, unique=True)),
("value", models.IntegerField()),
("value", models.DecimalField(decimal_places=0, max_digits=32)),
],
),
]

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/bittensor_panel/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ class HyperParameter(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=255, unique=True)
value = models.BigIntegerField()
value = models.DecimalField(max_digits=32, decimal_places=0)
2 changes: 1 addition & 1 deletion app/src/bittensor_panel/core/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def update_hyperparam(instance: HyperParameter) -> None:
Update hyperparameter in the subtensor with the new value and save changes to the database.
"""

result = update_remote_hyperparam(instance.name, instance.value)
result = update_remote_hyperparam(instance.name, int(instance.value))

if not result:
raise HyperParameterUpdateFailed("Failed to update remote hyperparameter. Subtensor returned False.")
Expand Down

0 comments on commit 7ed0f44

Please sign in to comment.