Skip to content

Commit

Permalink
Added validation for epochs and batchsize
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Aug 10, 2023
1 parent ea61b47 commit 267d108
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/aiproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
OSM_SECRET_KEY = env("OSM_SECRET_KEY")


# Limiter
EPOCHS_LIMIT = env("EPOCHS_LIMIT", default=30)
BATCH_SIZE_LIMIT = env("BATCH_SIZE_LIMIT", default=8)


# Application definition

INSTALLED_APPS = [
Expand Down
12 changes: 12 additions & 0 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ def create(self, validated_data):
"Another training is already running or submitted for this model."
)

epochs = validated_data["epochs"]
batch_size = validated_data["batch_size"]

if epochs > settings.EPOCHS_LIMIT:
raise ValidationError(
f"Epochs can't be greater than {settings.EPOCHS_LIMIT} on this server"
)
if batch_size > settings.BATCH_SIZE_LIMIT:
raise ValidationError(
f"Batch size can't be greater than {settings.BATCH_SIZE_LIMIT} on this server"
)

user = self.context["request"].user
validated_data["created_by"] = user
# create the model instance
Expand Down

0 comments on commit 267d108

Please sign in to comment.