Skip to content

Commit

Permalink
Merge branch 'main' into 7-demo-cli-option
Browse files Browse the repository at this point in the history
  • Loading branch information
mccalluc committed Oct 18, 2024
2 parents db437fe + 792a768 commit 9bec576
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Building on what we've learned from [DP Creator](https://github.com/opendp/dpcre
- Streamlined workflow that doesn't assume familiarity with differential privacy
- Interactive visualization of privacy budget choices
- UI development in Python with [Shiny](https://shiny.posit.co/py/)
- Tracking of cumulative privacy consumption between sessions

We plan to implement a [proof of concept](https://docs.google.com/document/d/1dteip598-jYj6KFuoYRyrZDPUuwDl9fHgxARiSieVGw/edit) over a couple months, and then get feedback from users before deciding on next steps.

Expand Down
5 changes: 5 additions & 0 deletions dp_creator_ii/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
)


def ctrl_c_reminder():
print("Session ended (Press CTRL+C to quit)")


def server(input, output, session):
dataset_panel.dataset_server(input, output, session)
analysis_panel.analysis_server(input, output, session)
results_panel.results_server(input, output, session)
session.on_ended(ctrl_c_reminder)


app = App(app_ui, server)
16 changes: 12 additions & 4 deletions dp_creator_ii/app/analysis_panel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from math import pow

from shiny import ui, reactive, render

from dp_creator_ii.mock_data import mock_data, ColumnDef
Expand All @@ -22,10 +24,8 @@ def analysis_ui():
"Values above 1 will add less noise to the data, "
"but have greater risk of revealing individual data."
),
ui.markdown(
"[TODO: Logarithmic slider]"
"(https://github.com/opendp/dp-creator-ii/issues/25)"
),
ui.input_slider("log_epsilon_slider", None, -1, 1, 0, step=0.1),
ui.output_text("epsilon"),
ui.markdown(
"## Preview\n"
"These plots assume a normal distribution for the columns you've selected, "
Expand All @@ -39,6 +39,14 @@ def analysis_ui():


def analysis_server(input, output, session):
@reactive.calc
def epsilon_calc():
return pow(10, input.log_epsilon_slider())

@render.text
def epsilon():
return f"Epsilon: {epsilon_calc():0.3}"

@render.plot()
def plot_preview():
min_x = 0
Expand Down
5 changes: 5 additions & 0 deletions dp_creator_ii/app/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ body {
#top_level_nav {
margin-bottom: 1em;
}

/* Rather than engineer a new widget, hide the numbers we don't want. */
.irs-min, .irs-max, .irs-single {
display: none;
}
14 changes: 7 additions & 7 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# pip-compile requirements-dev.in
#
anyio==4.6.0
anyio==4.6.2.post1
# via
# starlette
# watchfiles
Expand Down Expand Up @@ -45,7 +45,7 @@ comm==0.2.2
# via ipykernel
contourpy==1.3.0
# via matplotlib
coverage==7.6.2
coverage==7.6.3
# via -r requirements-dev.in
cycler==0.12.1
# via matplotlib
Expand Down Expand Up @@ -150,7 +150,7 @@ mdurl==0.1.2
# via markdown-it-py
mistune==3.0.2
# via nbconvert
mypy==1.11.2
mypy==1.12.0
# via -r requirements-dev.in
mypy-extensions==1.0.0
# via
Expand Down Expand Up @@ -199,7 +199,7 @@ pathspec==0.12.1
# via black
pexpect==4.9.0
# via ipython
pillow==10.4.0
pillow==11.0.0
# via matplotlib
pip-tools==7.4.1
# via -r requirements-dev.in
Expand Down Expand Up @@ -239,7 +239,7 @@ pygments==2.18.0
# via
# ipython
# nbconvert
pyparsing==3.1.4
pyparsing==3.2.0
# via matplotlib
pyproject-hooks==1.2.0
# via
Expand Down Expand Up @@ -305,7 +305,7 @@ soupsieve==2.6
# via beautifulsoup4
stack-data==0.6.3
# via ipython
starlette==0.39.2
starlette==0.41.0
# via shiny
text-unidecode==1.3
# via python-slugify
Expand Down Expand Up @@ -340,7 +340,7 @@ uc-micro-py==1.0.3
# via linkify-it-py
urllib3==2.2.3
# via requests
uvicorn==0.31.1
uvicorn==0.32.0
# via shiny
virtualenv==20.26.6
# via pre-commit
Expand Down

0 comments on commit 9bec576

Please sign in to comment.