Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
03937dd
update cellpop import to pypi (to fix pandas issue)
thomcsmits Feb 12, 2025
5c9a4c6
Merge pull request #122 from hubmapconsortium/thomcsmits/cellpop-fix
thomcsmits Feb 13, 2025
57fcc5c
add 2 vitessce examples
thomcsmits Mar 6, 2025
20ee867
update vitessce name
thomcsmits Mar 6, 2025
1f6e2ef
add example for codex clustering
thomcsmits Mar 6, 2025
ace86bb
uncomment all package installs
thomcsmits Mar 6, 2025
d940e26
fix capitalization
thomcsmits Mar 6, 2025
eb09e7d
Merge pull request #123 from hubmapconsortium/thomcsmits/add-examples…
thomcsmits Mar 7, 2025
b37c9d0
Update VERSION
jpuerto-psc Mar 11, 2025
c2a1654
remove 1 example vitessce for debug
thomcsmits Mar 11, 2025
0c21515
Merge pull request #125 from hubmapconsortium/thomcsmits/vitessce-rem…
thomcsmits Mar 11, 2025
985c0ea
change vitessce template to use portal_visualization as package
thomcsmits Mar 12, 2025
6952dab
remove portal-visualization dependency
thomcsmits Mar 12, 2025
ed2c159
update template_format to jinja
thomcsmits Mar 12, 2025
978092f
Merge pull request #126 from hubmapconsortium/thomcsmits/rebuild-vite…
jpuerto-psc Mar 12, 2025
cfc237a
add back 2nd example vitessce
thomcsmits Mar 13, 2025
3126508
rewrite api_tutorial to use jinja, remove portal-visualization get_cl…
thomcsmits Apr 14, 2025
c9234e3
lint
thomcsmits Apr 14, 2025
40be9fb
fix datasets url
thomcsmits Apr 14, 2025
71da350
Merge pull request #128 from hubmapconsortium/thomcsmits/remove-porta…
jpuerto-psc Apr 14, 2025
88287f2
Merge pull request #127 from hubmapconsortium/thomcsmits/add
thomcsmits Apr 17, 2025
5ef2c11
update spatialquery imports
thomcsmits Apr 28, 2025
31111f2
Merge pull request #130 from hubmapconsortium/thomcsmits/fix-templates
jpuerto-psc Apr 28, 2025
102f862
bump portal-visualization to 0.4.5
thomcsmits May 8, 2025
f2f5d4a
Merge pull request #131 from hubmapconsortium/thomcsmits/bump-portal-…
jpuerto-psc May 8, 2025
9aeddd3
bump portal-vis to 0.4.6 for nbformat
thomcsmits May 12, 2025
107091f
Merge pull request #132 from hubmapconsortium/thomcsmits/fix-pv
thomcsmits May 13, 2025
b9f10af
remove pinned vitessce version
thomcsmits May 13, 2025
c82ea69
Merge pull request #133 from hubmapconsortium/thomcsmits/fix-codex-ve…
thomcsmits May 13, 2025
bb41bb8
remove newline character from spatial query template
thomcsmits May 15, 2025
0cc98b5
Merge pull request #134 from hubmapconsortium/thomcsmits/fix-spatial-…
jpuerto-psc May 15, 2025
5c2e1b7
hide anndata
austenem May 21, 2025
1e1c235
Merge pull request #135 from hubmapconsortium/austenem/hide-anndata-t…
jpuerto-psc May 22, 2025
56a0297
Merge branch 'main' into development
jpuerto-psc May 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.1
2.3.0
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ numpy==1.24.1
pandas==1.5.2
pathspec==0.10.3
platformdirs==2.6.2
portal-visualization @ https://github.com/hubmapconsortium/portal-visualization/archive/refs/tags/0.2.3.zip
property==2.2
prov==2.0.0
pycodestyle==2.10.0
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ numpy==1.24.1
pandas==1.5.2
pathspec==0.10.3
platformdirs==2.6.2
portal-visualization @ https://github.com/hubmapconsortium/portal-visualization/archive/refs/tags/0.2.6.zip
property==2.2
prov==2.0.0
pycparser==2.21
Expand Down
90 changes: 43 additions & 47 deletions src/user_templates_api/templates/jupyter_lab/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
from pathlib import Path

from django.template import engines
from nbformat.v4 import new_code_cell, new_markdown_cell

import user_templates_api.templates.jupyter_lab.utils.utils as jl_utils
from user_templates_api.utils.client import get_client
# from nbformat.v4 import new_code_cell, new_markdown_cell
# import user_templates_api.templates.jupyter_lab.utils.utils as jl_utils


class JupyterLabRender:
Expand All @@ -32,54 +31,51 @@ def render(self, data):
def python_generate_template_data(self, data):
return []

def json_generate_template_data(self, data):
django_engine = engines["django"]

uuids = data["uuids"]
group_token = data["group_token"]

util_client = get_client(group_token)

template_json = data.get("template")
if template_json is None:
class_file_path = inspect.getfile(self.__class__)
# Convert the string to a pathlib Path
class_file_path = Path(class_file_path)
# Grab the parent path and append template.json
template_file_path = class_file_path.parent / "template.json"
# Load that filepath since it should be the json template
template_json = json.load(open(template_file_path))

cells = []
for template_item in template_json:
cell_type = template_item["cell_type"]
src = template_item["src"]
if cell_type == "template_cell":
if src == "get_metadata_cells":
cells += jl_utils.get_metadata_cells(uuids, util_client)
elif src == "get_file_cells":
cells += jl_utils.get_file_cells(uuids, util_client)
elif src == "get_anndata_cells":
cells += jl_utils.get_anndata_cells(uuids, util_client)
elif cell_type == "code_cell":
template = django_engine.from_string(src)
# Need to do something w/ the source to make sure that it has its vars replaced
# Have to use append here since the nbformat cell object has an add/iadd function that is really a merge
cells.append(new_code_cell(template.render(data)))
elif cell_type == "markdown_cell":
template = django_engine.from_string(src)
# Need to do something w/ the source to make sure that it has its vars replaced
cells.append(new_markdown_cell(template.render(data)))

return cells
# TODO: see if this can be used without get_client
# def json_generate_template_data(self, data):
# django_engine = engines["django"]

# uuids = data["uuids"]
# group_token = data["group_token"]

# util_client = get_client(group_token)

# template_json = data.get("template")
# if template_json is None:
# class_file_path = inspect.getfile(self.__class__)
# # Convert the string to a pathlib Path
# class_file_path = Path(class_file_path)
# # Grab the parent path and append template.json
# template_file_path = class_file_path.parent / "template.json"
# # Load that filepath since it should be the json template
# template_json = json.load(open(template_file_path))

# cells = []
# for template_item in template_json:
# cell_type = template_item["cell_type"]
# src = template_item["src"]
# if cell_type == "template_cell":
# if src == "get_metadata_cells":
# cells += jl_utils.get_metadata_cells(uuids, util_client)
# elif src == "get_file_cells":
# cells += jl_utils.get_file_cells(uuids, util_client)
# elif src == "get_anndata_cells":
# cells += jl_utils.get_anndata_cells(uuids, util_client)
# elif cell_type == "code_cell":
# template = django_engine.from_string(src)
# # Need to do something w/ the source to make sure that it has its vars replaced
# # Have to use append here since the nbformat cell object has an add/iadd function that is really a merge
# cells.append(new_code_cell(template.render(data)))
# elif cell_type == "markdown_cell":
# template = django_engine.from_string(src)
# # Need to do something w/ the source to make sure that it has its vars replaced
# cells.append(new_markdown_cell(template.render(data)))

# return cells

def jinja_generate_template_data(self, data):
django_engine = engines["django"]

group_token = data["group_token"]

data["util_client"] = get_client(group_token)

# Get the file path first
class_file_path = inspect.getfile(self.__class__)
# Convert the string to a pathlib Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"api"
],
"is_multi_dataset_template": true,
"template_format": "python",
"template_format": "jinja",
"examples": [
{
"title": "Working with API examples",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import user_templates_api.templates.jupyter_lab.utils.utils as jl_utils
from user_templates_api.templates.jupyter_lab.render import JupyterLabRender
from user_templates_api.utils.client import get_client


class JupyterLabAPITutorialRender(JupyterLabRender):
def python_generate_template_data(self, data):
uuids = data["uuids"]

util_client = get_client(data["group_token"])

cells = jl_utils.get_metadata_cells(uuids, util_client)
cells += jl_utils.get_file_cells(uuids, util_client)
cells += jl_utils.get_anndata_cells(uuids, util_client)
return cells
class JupyterLabExampleJinjaRender(JupyterLabRender):
def __init__(self):
pass
Loading
Loading