Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 18, 2024
1 parent 69408d0 commit c06469d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 9 additions & 5 deletions pydatalab/pydatalab/apps/mri/blocks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import bokeh
import numpy as np
import pandas as pd

from pydatalab.blocks.base import DataBlock
from pydatalab.logger import LOGGER
from pydatalab.bokeh_plots import DATALAB_BOKEH_THEME
from pydatalab.file_utils import get_file_info_by_id

Expand Down Expand Up @@ -47,7 +45,7 @@ def load_2dseq(
def generate_mri_plot(self):
"""Generate image plots of MRI data."""
from bokeh.layouts import column
from bokeh.models import ColumnDataSource, CustomJS, Slider, ColorBar, LinearColorMapper
from bokeh.models import ColorBar, ColumnDataSource, CustomJS, Slider
from bokeh.plotting import figure

if "file_id" not in self.data:
Expand Down Expand Up @@ -90,13 +88,19 @@ def generate_mri_plot(self):

# Set limits to edge of images defined by 10x10
p.x_range.start = 0
p.x_range.end = 10
p.x_range.end = 10
p.y_range.start = 0
p.y_range.end = 10

color_bar = ColorBar(color_mapper=color_mapper)

slider = Slider(start=0, end=len(image_array) - 1, step=1, value=0, title=f"Select image ({len(image_array)} images)")
slider = Slider(
start=0,
end=len(image_array) - 1,
step=1,
value=0,
title=f"Select image ({len(image_array)} images)",
)

slider_callback = CustomJS(
args=dict(image_source=image_source, image_array=image_array, slider=slider),
Expand Down
8 changes: 5 additions & 3 deletions pydatalab/pydatalab/routes/v0_1/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,21 @@ def _save_block_to_db(block: DataBlock) -> bool:
print(updated_block.keys())

if block.data.get("collection_id"):
match = {"collection_id": block.data["collection_id"], **get_default_permissions(user_only=False)}
match = {
"collection_id": block.data["collection_id"],
**get_default_permissions(user_only=False),
}
else:
match = {"block_id": block.data["block_id"], **get_default_permissions(user_only=False)}


try:
result = flask_mongo.db.items.update_one(
match,
update,
)
except pymongo.errors.DocumentTooLarge:
LOGGER.warning(
f"_save_block_to_db failed, trying to strip down the block plot to fit in the 16MB limit"
"_save_block_to_db failed, trying to strip down the block plot to fit in the 16MB limit"
)

return False
Expand Down

0 comments on commit c06469d

Please sign in to comment.