Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasrberg committed Jul 17, 2024
1 parent 4787484 commit b2ae164
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/webapp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ def get_example_drawings(json_data):
if (lang == "NO"):
label = models.to_english(label)

example_drawing_urls = models.get_n_random_example_images(label, number_of_images)
example_drawings = storage.get_images_from_relative_url(example_drawing_urls)
example_drawing_urls = models.get_n_random_example_images(
label, number_of_images)
example_drawings = storage.get_images_from_relative_url(
example_drawing_urls)
emit("getExampleDrawings", json.dumps(example_drawings), room=game_id)


Expand Down
4 changes: 3 additions & 1 deletion src/webapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class Difficulty(db.Model):
id = db.Column(db.Integer, primary_key=True)
difficulty = db.Column(db.String(32), nullable=False)


class ExampleImages(db.Model):
"""
Model for storing example image urls that the model has predicted correctly.
Expand Down Expand Up @@ -589,6 +590,7 @@ def get_translation_dict():
except Exception as e:
raise Exception("Could not read Labels table: " + str(e))


def insert_into_example_images(images, label):
"""
Insert values into ExampleImages table.
Expand Down Expand Up @@ -638,4 +640,4 @@ def populate_example_images(app):
db.session.commit()
except Exception as e:
raise Exception(
"Could not insert into ExampleImages table: " + str(e))
"Could not insert into ExampleImages table: " + str(e))
3 changes: 2 additions & 1 deletion src/webapp/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def image_to_data_url(image_data, content_type):
base64_image = base64.b64encode(image_data).decode('utf-8')
return f"data:{content_type};base64,{base64_image}"


def get_images_from_relative_url(image_urls):
"""
Returns a list of images from a list of relative URLs.
Expand All @@ -156,4 +157,4 @@ def get_images_from_relative_url(image_urls):
decoded_image = image_to_data_url(
image_data, "application/octet-stream")
images.append(decoded_image)
return images
return images

0 comments on commit b2ae164

Please sign in to comment.