From 7ed0f448ba84107ddd6abd162f9fd4851139f8b7 Mon Sep 17 00:00:00 2001 From: Olzhas Arystanov Date: Mon, 6 May 2024 21:08:07 +0500 Subject: [PATCH] Use DecimalField for hyperparameter values --- .../core/migrations/0001_initial.py | 14 +++++++++++--- .../0002_alter_hyperparameter_value.py | 17 ----------------- app/src/bittensor_panel/core/models.py | 2 +- app/src/bittensor_panel/core/services.py | 2 +- 4 files changed, 13 insertions(+), 22 deletions(-) delete mode 100644 app/src/bittensor_panel/core/migrations/0002_alter_hyperparameter_value.py diff --git a/app/src/bittensor_panel/core/migrations/0001_initial.py b/app/src/bittensor_panel/core/migrations/0001_initial.py index fe0ea6b..f7e0b57 100644 --- a/app/src/bittensor_panel/core/migrations/0001_initial.py +++ b/app/src/bittensor_panel/core/migrations/0001_initial.py @@ -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 @@ -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)), ], ), ] diff --git a/app/src/bittensor_panel/core/migrations/0002_alter_hyperparameter_value.py b/app/src/bittensor_panel/core/migrations/0002_alter_hyperparameter_value.py deleted file mode 100644 index 3f30077..0000000 --- a/app/src/bittensor_panel/core/migrations/0002_alter_hyperparameter_value.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 4.2.11 on 2024-05-04 22:32 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("core", "0001_initial"), - ] - - operations = [ - migrations.AlterField( - model_name="hyperparameter", - name="value", - field=models.BigIntegerField(), - ), - ] diff --git a/app/src/bittensor_panel/core/models.py b/app/src/bittensor_panel/core/models.py index ffdd409..0e5f2f4 100644 --- a/app/src/bittensor_panel/core/models.py +++ b/app/src/bittensor_panel/core/models.py @@ -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) diff --git a/app/src/bittensor_panel/core/services.py b/app/src/bittensor_panel/core/services.py index fd00544..c713f2b 100644 --- a/app/src/bittensor_panel/core/services.py +++ b/app/src/bittensor_panel/core/services.py @@ -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.")