-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mccalluc/serve notebooks plus introspection #1877
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f52d0fa
get rid of ext params
mccalluc 9a9ec1b
serve hello world
mccalluc 0008c31
Make it default to download
mccalluc 2fe1716
More complicated notebook
mccalluc 41b0c22
changelog
mccalluc c9a1a27
missing "="
mccalluc 9698c46
unused import
mccalluc 51a3d26
Add widget viewing.
ilan-gold 00e2e79
todo: actually fill in the steps
mccalluc ab32889
proof of concept
mccalluc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Add an endpoint which serves a Jupyter notebook with the viewconf for a dataset. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
from pathlib import Path | ||
import re | ||
|
||
import nbformat | ||
from flask import current_app | ||
from vitessce import ( | ||
VitessceConfig, | ||
|
@@ -119,7 +120,8 @@ def __init__(self, entity, nexus_token, is_mock=False): | |
self.image_pyramid_regex = IMAGE_PYRAMID_DIR | ||
super().__init__(entity, nexus_token, is_mock) | ||
|
||
def build_vitessce_conf(self): | ||
def build_vitessce_conf_cells(self): | ||
cells = [] | ||
file_paths_found = self._get_file_paths() | ||
found_images = get_matches( | ||
file_paths_found, self.image_pyramid_regex + r".*\.ome\.tiff?$", | ||
|
@@ -131,8 +133,18 @@ def build_vitessce_conf(self): | |
raise FileNotFoundError(message) | ||
|
||
vc = VitessceConfig(name="HuBMAP Data Portal") | ||
cells.append(nbformat.v4.new_code_cell( | ||
'vc = VitessceConfig(name="HuBMAP Data Portal")' | ||
)) | ||
|
||
dataset = vc.add_dataset(name="Visualization Files") | ||
cells.append(nbformat.v4.new_code_cell( | ||
'vc.add_dataset(name="Visualization Files")' | ||
)) | ||
|
||
images = [] | ||
cells.append(nbformat.v4.new_code_cell(f'images = []')) | ||
|
||
for img_path in found_images: | ||
img_url, offsets_url = self._get_img_and_offset_url( | ||
img_path, self.image_pyramid_regex | ||
|
@@ -142,12 +154,29 @@ def build_vitessce_conf(self): | |
img_url=img_url, offsets_url=offsets_url, name=Path(img_path).name | ||
) | ||
) | ||
cells.append(nbformat.v4.new_code_cell( | ||
f"images.append(OmeTiffWrapper(img_url='{img_url}', offsets_url='{offsets_url}', name=Path('{img_path}').name))" | ||
)) | ||
# NOTE: If OmeTiffWrapper had a repr which reproduced the object, we could just say: | ||
# f"images = {images}" | ||
Comment on lines
+160
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or, better, do it at the very end, with |
||
|
||
dataset = dataset.add_object(MultiImageWrapper(images)) | ||
cells.append(nbformat.v4.new_code_cell( | ||
'dataset = dataset.add_object(MultiImageWrapper(images))' | ||
)) | ||
|
||
vc = self._setup_view_config_raster(vc, dataset) | ||
cells.append(nbformat.v4.new_code_cell( | ||
f'vc = self._setup_view_config_raster(vc, dataset)' | ||
)) | ||
|
||
# NOTE: We could skip the serialization to JSON and then back to an object. | ||
# ... but not sure how to handle the del below... does a method need to be added to the viewconf? | ||
|
||
conf = vc.to_dict() | ||
# Don't want to render all layers | ||
del conf["datasets"][0]["files"][0]["options"]["renderLayers"] | ||
return conf | ||
return (conf, cells) | ||
|
||
|
||
class ScatterplotViewConf(ViewConf): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
nbformat==5.1.2 | ||
Flask==1.1.2 | ||
globus-sdk==2.0.1 | ||
requests==2.22.0 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.