Skip to content

Commit

Permalink
nb reads public or private
Browse files Browse the repository at this point in the history
  • Loading branch information
mccalluc committed Jan 15, 2025
1 parent 38160f5 commit 48c1239
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion dp_wizard/app/results_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def analysis_plan() -> AnalysisPlan:
for col in weights().keys()
}
return AnalysisPlan(
csv_path=private_csv_path(),
# Prefer private CSV, if available:
csv_path=private_csv_path() or public_csv_path(),
contributions=contributions(),
epsilon=epsilon(),
columns=columns,
Expand Down
4 changes: 4 additions & 0 deletions dp_wizard/utils/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def convert_py_to_nb(python_str: str, execute: bool = False):
temp_dir_path = Path(temp_dir)
py_path = temp_dir_path / "input.py"
py_path.write_text(python_str)

# DEBUG:
Path("/tmp/script.py").write_text(python_str)

argv = (
[
"jupytext",
Expand Down
12 changes: 3 additions & 9 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
default_app = create_app_fixture(Path(__file__).parent / "fixtures/default_app.py")
tooltip = "#choose_csv_demo_tooltip_ui svg"
for_the_demo = "For the demo, we'll imagine"
simulation = "This simulation will assume a normal distribution"


# TODO: Why is incomplete coverage reported here?
Expand Down Expand Up @@ -67,8 +66,7 @@ def expect_no_error():

# Now upload:
csv_path = Path(__file__).parent / "fixtures" / "fake.csv"
# TODO: Switch to public
page.get_by_label("Choose Private CSV").set_input_files(csv_path.resolve())
page.get_by_label("Choose Public CSV").set_input_files(csv_path.resolve())
expect_no_error()

# -- Define analysis --
Expand All @@ -95,8 +93,7 @@ def expect_no_error():
page.locator(".irs-bar").click()
expect_visible("Epsilon: 0.158")
# Simulation
# TODO: Should be public!
expect_visible("This simulation will assume")
expect_visible("Because you've provided a public CSV")

# Button disabled until column selected:
download_results_button = page.get_by_role("button", name="Download results")
Expand All @@ -108,7 +105,6 @@ def expect_no_error():

# Set column details:
page.get_by_label("grade").check()
expect_visible(simulation)
expect_not_visible("Weight")
# Check that default is set correctly:
assert page.get_by_label("Upper").input_value() == "10"
Expand All @@ -117,14 +113,12 @@ def expect_no_error():
page.get_by_label("Upper").fill(new_value)
# Uncheck the column:
page.get_by_label("grade").uncheck()
expect_visible(simulation)
# Recheck the column:
page.get_by_label("grade").check()
expect_visible(simulation)
assert page.get_by_label("Upper").input_value() == new_value
expect_visible("The 95% confidence interval is ±794")
page.get_by_text("Data Table").click()
expect_visible("(0, 2]")
expect_visible(f"({new_value}, inf]") # Because values are well above the bins.

# Add a second column:
# page.get_by_label("blank").check()
Expand Down

0 comments on commit 48c1239

Please sign in to comment.