Skip to content

Commit

Permalink
Merge pull request #61 from LeoBreebaart/master
Browse files Browse the repository at this point in the history
Python package compatibiliy fixes
  • Loading branch information
aliFrancis authored Jul 24, 2024
2 parents 40cf00d + 8b2cc58 commit 10ffd4e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
7 changes: 4 additions & 3 deletions iris/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from datetime import timedelta

import flask
import markupsafe
from sqlalchemy import func

from iris.user import requires_admin, requires_auth
Expand Down Expand Up @@ -44,7 +45,7 @@ def users():
users_json = [user.to_json() for user in users]

html = flask.render_template('admin/users.html', users=users_json, order_by=order_by, ascending=ascending)
return flask.render_template('admin/index.html', user=user, page=flask.Markup(html))
return flask.render_template('admin/index.html', user=user, page=markupsafe.Markup(html))

@admin_app.route('/actions/<type>', methods=['GET'])
@requires_auth
Expand Down Expand Up @@ -74,7 +75,7 @@ def actions(type):
'admin/actions.html', action_type=type, actions=actions_json,
image_stats=image_stats, order_by=order_by, ascending=ascending
)
return flask.render_template('admin/index.html', user=user, page=flask.Markup(html))
return flask.render_template('admin/index.html', user=user, page=markupsafe.Markup(html))

@admin_app.route('/images', methods=['GET'])
@requires_auth
Expand Down Expand Up @@ -117,4 +118,4 @@ def images():
html = flask.render_template(
'admin/images.html', images=images, order_by=order_by, ascending=ascending
)
return flask.render_template('admin/index.html', user=user, page=flask.Markup(html))
return flask.render_template('admin/index.html', user=user, page=markupsafe.Markup(html))
3 changes: 2 additions & 1 deletion iris/main/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json

import flask
import markupsafe
import numpy as np
from PIL import Image as PILImage
from skimage.transform import resize
Expand Down Expand Up @@ -92,7 +93,7 @@ def metadata(image_id):

if flask.request.args.get('safe_html', False):
metadata = {
k: flask.Markup(str(v))
k: markupsafe.Markup(str(v))
for k, v in metadata.items()
}

Expand Down
4 changes: 3 additions & 1 deletion iris/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import re

import flask
import markupsafe

import json
from matplotlib import cm
import numpy as np
Expand Down Expand Up @@ -95,7 +97,7 @@ def load_from(self, filename):
# Make sure the HTML is understood in the descriptions:
for name, view in self.config['views'].items():
view['name'] = name
view['description'] = flask.Markup(
view['description'] = markupsafe.Markup(
view.get('description', view['name'])
)
view['stretch'] = view.get('stretch', 'linear')
Expand Down
2 changes: 1 addition & 1 deletion iris/segmentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def save_mask(image_id):
# The user mask denotes who classified the pixels in the mask:
# if true: the user classified the pixel
# if false: the AI classified the pixel
user_mask = data[1+mask_length:-1].astype(np.bool)
user_mask = data[1+mask_length:-1].astype(bool)
user_mask = user_mask.reshape(project['segmentation']['mask_shape'][::-1])

final_mask_file, user_mask_file = get_mask_filenames(image_id, user_id)
Expand Down
6 changes: 3 additions & 3 deletions iris/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from copy import deepcopy

import flask

import markupsafe


class View:
Expand All @@ -12,8 +12,8 @@ def __init__(self, name, description, loader):

def to_json(self):
return {
'name': flask.Markup(self.name),
'description': flask.Markup(self.description),
'name': markupsafe.Markup(self.name),
'description': markupsafe.Markup(self.description),
}

def merge_deep_dicts(d1, d2):
Expand Down

0 comments on commit 10ffd4e

Please sign in to comment.