Skip to content

Commit

Permalink
Merge pull request hotosm#148 from hotosm/feature/validation_eb
Browse files Browse the repository at this point in the history
Feature : Validation for epochs and batch size
  • Loading branch information
kshitijrajsharma authored Aug 11, 2023
2 parents 54ebf07 + 62aa500 commit b91976d
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 b91976d

Please sign in to comment.