Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 7 additions & 4 deletions dp_wizard/shiny/panels/results_panel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import html
import json
import re
from pathlib import Path
from shutil import make_archive
from tempfile import TemporaryDirectory

from dp_wizard_templates.converters import convert_from_notebook, convert_to_notebook
from dp_wizard_templates.converters import (
clean_notebook,
convert_from_notebook,
convert_to_notebook,
)
from shiny import Inputs, Outputs, Session, reactive, render, types, ui

from dp_wizard import config_root
Expand Down Expand Up @@ -384,11 +387,11 @@ def notebook_dict_unexecuted():

@reactive.calc
def notebook_json():
return json.dumps(notebook_dict())
return clean_notebook(notebook_dict())

@reactive.calc
def notebook_json_unexecuted():
return json.dumps(notebook_dict_unexecuted())
return clean_notebook(notebook_dict_unexecuted())

@reactive.calc
def notebook_html():
Expand Down
23 changes: 19 additions & 4 deletions dp_wizard/utils/code_generators/abstract_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
from abc import ABC, abstractmethod
from math import gcd
from typing import Iterable
Expand Down Expand Up @@ -89,9 +90,7 @@ def imports_template():
.fill_blocks(
IMPORTS_BLOCK=DefaultsTemplate(imports_template).finish(),
UTILS_BLOCK=bins_py + plots_py,
**self._make_extra_blocks(), # type: ignore
)
.fill_blocks(
CUSTOM_NOTE=self.note,
WINDOWS_COMMENT_BLOCK="""
(If installing in the Windows CMD shell,
use double-quotes instead of single-quotes below.)""",
Expand All @@ -108,7 +107,23 @@ def imports_template():
so it is safer to ignore them. That said, if a significant number of records
are ignored because of errors, it will bias results.
""",
CUSTOM_NOTE=self.note,
**self._make_extra_blocks(), # type: ignore
)
.fill_blocks(
FRONTMATTER_BLOCK=json.dumps(
{
"tag_map": {
"Brief Report": [],
"Full Tutorial": ["tutorial"],
"Include Postprocessing": ["tutorial", "postprocessing"],
},
"css_map": {
"tutorial": "background: lightblue;",
"postprocessing": "background: lightblue;",
},
}
),
optional=True, # Not used by script template
)
.finish(reformat=reformat)
)
Expand Down
6 changes: 1 addition & 5 deletions dp_wizard/utils/code_generators/no-tests/_stats_notebook.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# {"tagmap":{
# "Brief Report": [],
# "Full Tutorial": ["tutorial"],
# "Include Postprocessing": ["tutorial", "postprocessing"]
# }}
# FRONTMATTER_BLOCK

# # TITLE
#
Expand Down
6 changes: 1 addition & 5 deletions dp_wizard/utils/code_generators/no-tests/_synth_notebook.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# {"tagmap":{
# "Brief Report": [],
# "Full Tutorial": ["tutorial"],
# "Include Postprocessing": ["tutorial", "postprocessing"]
# }}
# FRONTMATTER_BLOCK

# # TITLE
#
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ classifiers = [
keywords = ["differential privacy"]
dynamic = ["version", "description"]
dependencies = [
"dp-wizard-templates==0.8.2",
"dp-wizard-templates==0.9.0",
"faicons",
"matplotlib",
"opendp[mbi]==0.14.1",
Expand Down Expand Up @@ -77,7 +77,7 @@ pins = [
"decorator==5.2.1",
"defusedxml==0.7.1",
"deprecated==1.2.18",
"dp-wizard-templates==0.8.2",
"dp-wizard-templates==0.9.0",
"exceptiongroup==1.3.0",
"executing==2.2.0",
"faicons==0.2.2",
Expand Down
14 changes: 10 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ black==25.1.0
# -r requirements-dev.in
# dp-wizard-templates
bleach[css]==6.2.0
# via nbconvert
# via
# bleach
# nbconvert
build==1.2.2.post1
# via pip-tools
certifi==2025.1.31
Expand All @@ -59,7 +61,9 @@ comm==0.2.2
contourpy==1.3.2
# via matplotlib
coverage[toml]==7.8.0
# via pytest-cov
# via
# coverage
# pytest-cov
cycler==0.12.1
# via matplotlib
debugpy==1.8.14
Expand All @@ -76,7 +80,7 @@ distlib==0.3.9
# via virtualenv
docutils==0.21.2
# via flit
dp-wizard-templates==0.8.2
dp-wizard-templates==0.9.0
# via -r .../dp-wizard/requirements.in
exceptiongroup==1.3.0
# via
Expand Down Expand Up @@ -243,7 +247,9 @@ numpy==2.2.4
# scikit-learn
# scipy
opendp[mbi]==0.14.1
# via -r .../dp-wizard/requirements.in
# via
# -r .../dp-wizard/requirements.in
# opendp
opt-einsum==3.4.0
# via jax
optax==0.2.5
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
opendp[mbi]==0.14.1

# Templating and notebook generation:
dp-wizard-templates==0.8.2
dp-wizard-templates==0.9.0

# Shiny:
shiny
Expand Down
14 changes: 11 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ beautifulsoup4==4.13.4
black==25.1.0
# via dp-wizard-templates
bleach[css]==6.2.0
# via nbconvert
# via
# bleach
# nbconvert
certifi==2025.4.26
# via requests
charset-normalizer==3.4.2
# via requests
chex==0.1.90
# via
# mbi
Expand All @@ -54,7 +60,7 @@ defusedxml==0.7.1
# via nbconvert
deprecated==1.2.18
# via opendp
dp-wizard-templates==0.8.2
dp-wizard-templates==0.9.0
# via -r requirements.in
exceptiongroup==1.3.0
# via
Expand Down Expand Up @@ -183,7 +189,9 @@ numpy==2.2.4
# scikit-learn
# scipy
opendp[mbi]==0.14.1
# via -r requirements.in
# via
# -r requirements.in
# opendp
opt-einsum==3.4.0
# via jax
optax==0.2.5
Expand Down
Loading