opendp / opendp

The core library of differential privacy algorithms powering the OpenDP Project.
https://opendp.org
MIT License
284 stars 46 forks source link

Usability with debug binary? `make_randomized_response` with numbers #1552

Closed mccalluc closed 2 weeks ago

mccalluc commented 2 weeks ago

Strings work:

>>> random_string = dp.m.make_randomized_response(['a', 'b', 'c'], 0.99)
>>> random_string('a')
a

but numbers don't:

>>> randomized_response = dp.m.make_randomized_response([1.0, 2.0, 3.0], 0.99)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/chuckmccallum/github/opendp/opendp/python/src/opendp/measurements.py", line 709, in make_randomized_response
    output = c_to_py(unwrap(lib_function(c_categories, c_prob, c_constant_time, c_T, c_QO), Measurement))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chuckmccallum/github/opendp/opendp/python/src/opendp/_lib.py", line 270, in unwrap
    raise OpenDPException(variant, message, backtrace)
opendp.mod.OpenDPException:
  FFI("No match for concrete type f64. You've got a debug binary! Debug binaries support fewer types. Consult https://docs.opendp.org/en/stable/contributor/development-environment.html#build-opendp")
>>> randomized_response = dp.m.make_randomized_response([1, 2, 3], 0.99)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/chuckmccallum/github/opendp/opendp/python/src/opendp/measurements.py", line 709, in make_randomized_response
    output = c_to_py(unwrap(lib_function(c_categories, c_prob, c_constant_time, c_T, c_QO), Measurement))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chuckmccallum/github/opendp/opendp/python/src/opendp/_lib.py", line 270, in unwrap
    raise OpenDPException(variant, message, backtrace)
opendp.mod.OpenDPException:
  FFI("No match for concrete type i32. You've got a debug binary! Debug binaries support fewer types. Consult https://docs.opendp.org/en/stable/contributor/development-environment.html#build-opendp")

Am I doing something wrong?

mccalluc commented 2 weeks ago

This would make the dev build a lot slower, so this is fine as is. If Polars does more of the lifting, we can get rid of code, but leave as is for now.

raprasad commented 2 weeks ago

(Using a "debug" binary only takes strings. Release builds have all types)