Skip to content

Commit 8e89cff

Browse files
authored
Merge pull request #124 from hubmapconsortium/development
v2.3.0
2 parents 24da37c + 56a0297 commit 8e89cff

18 files changed

Lines changed: 371 additions & 327 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.1
1+
2.3.0

requirements-dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ numpy==1.24.1
4545
pandas==1.5.2
4646
pathspec==0.10.3
4747
platformdirs==2.6.2
48-
portal-visualization @ https://github.com/hubmapconsortium/portal-visualization/archive/refs/tags/0.2.3.zip
4948
property==2.2
5049
prov==2.0.0
5150
pycodestyle==2.10.0

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ numpy==1.24.1
4444
pandas==1.5.2
4545
pathspec==0.10.3
4646
platformdirs==2.6.2
47-
portal-visualization @ https://github.com/hubmapconsortium/portal-visualization/archive/refs/tags/0.2.6.zip
4847
property==2.2
4948
prov==2.0.0
5049
pycparser==2.21

src/user_templates_api/templates/jupyter_lab/render.py

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
from pathlib import Path
44

55
from django.template import engines
6-
from nbformat.v4 import new_code_cell, new_markdown_cell
76

8-
import user_templates_api.templates.jupyter_lab.utils.utils as jl_utils
9-
from user_templates_api.utils.client import get_client
7+
# from nbformat.v4 import new_code_cell, new_markdown_cell
8+
# import user_templates_api.templates.jupyter_lab.utils.utils as jl_utils
109

1110

1211
class JupyterLabRender:
@@ -32,54 +31,51 @@ def render(self, data):
3231
def python_generate_template_data(self, data):
3332
return []
3433

35-
def json_generate_template_data(self, data):
36-
django_engine = engines["django"]
37-
38-
uuids = data["uuids"]
39-
group_token = data["group_token"]
40-
41-
util_client = get_client(group_token)
42-
43-
template_json = data.get("template")
44-
if template_json is None:
45-
class_file_path = inspect.getfile(self.__class__)
46-
# Convert the string to a pathlib Path
47-
class_file_path = Path(class_file_path)
48-
# Grab the parent path and append template.json
49-
template_file_path = class_file_path.parent / "template.json"
50-
# Load that filepath since it should be the json template
51-
template_json = json.load(open(template_file_path))
52-
53-
cells = []
54-
for template_item in template_json:
55-
cell_type = template_item["cell_type"]
56-
src = template_item["src"]
57-
if cell_type == "template_cell":
58-
if src == "get_metadata_cells":
59-
cells += jl_utils.get_metadata_cells(uuids, util_client)
60-
elif src == "get_file_cells":
61-
cells += jl_utils.get_file_cells(uuids, util_client)
62-
elif src == "get_anndata_cells":
63-
cells += jl_utils.get_anndata_cells(uuids, util_client)
64-
elif cell_type == "code_cell":
65-
template = django_engine.from_string(src)
66-
# Need to do something w/ the source to make sure that it has its vars replaced
67-
# Have to use append here since the nbformat cell object has an add/iadd function that is really a merge
68-
cells.append(new_code_cell(template.render(data)))
69-
elif cell_type == "markdown_cell":
70-
template = django_engine.from_string(src)
71-
# Need to do something w/ the source to make sure that it has its vars replaced
72-
cells.append(new_markdown_cell(template.render(data)))
73-
74-
return cells
34+
# TODO: see if this can be used without get_client
35+
# def json_generate_template_data(self, data):
36+
# django_engine = engines["django"]
37+
38+
# uuids = data["uuids"]
39+
# group_token = data["group_token"]
40+
41+
# util_client = get_client(group_token)
42+
43+
# template_json = data.get("template")
44+
# if template_json is None:
45+
# class_file_path = inspect.getfile(self.__class__)
46+
# # Convert the string to a pathlib Path
47+
# class_file_path = Path(class_file_path)
48+
# # Grab the parent path and append template.json
49+
# template_file_path = class_file_path.parent / "template.json"
50+
# # Load that filepath since it should be the json template
51+
# template_json = json.load(open(template_file_path))
52+
53+
# cells = []
54+
# for template_item in template_json:
55+
# cell_type = template_item["cell_type"]
56+
# src = template_item["src"]
57+
# if cell_type == "template_cell":
58+
# if src == "get_metadata_cells":
59+
# cells += jl_utils.get_metadata_cells(uuids, util_client)
60+
# elif src == "get_file_cells":
61+
# cells += jl_utils.get_file_cells(uuids, util_client)
62+
# elif src == "get_anndata_cells":
63+
# cells += jl_utils.get_anndata_cells(uuids, util_client)
64+
# elif cell_type == "code_cell":
65+
# template = django_engine.from_string(src)
66+
# # Need to do something w/ the source to make sure that it has its vars replaced
67+
# # Have to use append here since the nbformat cell object has an add/iadd function that is really a merge
68+
# cells.append(new_code_cell(template.render(data)))
69+
# elif cell_type == "markdown_cell":
70+
# template = django_engine.from_string(src)
71+
# # Need to do something w/ the source to make sure that it has its vars replaced
72+
# cells.append(new_markdown_cell(template.render(data)))
73+
74+
# return cells
7575

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

79-
group_token = data["group_token"]
80-
81-
data["util_client"] = get_client(group_token)
82-
8379
# Get the file path first
8480
class_file_path = inspect.getfile(self.__class__)
8581
# Convert the string to a pathlib Path

src/user_templates_api/templates/jupyter_lab/templates/api_tutorial/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"api"
77
],
88
"is_multi_dataset_template": true,
9-
"template_format": "python",
9+
"template_format": "jinja",
1010
"examples": [
1111
{
1212
"title": "Working with API examples",
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
import user_templates_api.templates.jupyter_lab.utils.utils as jl_utils
21
from user_templates_api.templates.jupyter_lab.render import JupyterLabRender
3-
from user_templates_api.utils.client import get_client
42

53

6-
class JupyterLabAPITutorialRender(JupyterLabRender):
7-
def python_generate_template_data(self, data):
8-
uuids = data["uuids"]
9-
10-
util_client = get_client(data["group_token"])
11-
12-
cells = jl_utils.get_metadata_cells(uuids, util_client)
13-
cells += jl_utils.get_file_cells(uuids, util_client)
14-
cells += jl_utils.get_anndata_cells(uuids, util_client)
15-
return cells
4+
class JupyterLabExampleJinjaRender(JupyterLabRender):
5+
def __init__(self):
6+
pass

0 commit comments

Comments
 (0)