Skip to content

Commit

Permalink
Update version to 0.2.1rc5 and remove hard dependency to dp_accounting (
Browse files Browse the repository at this point in the history
  • Loading branch information
dvadym authored Aug 29, 2023
1 parent 6e922ad commit 09b7aad
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 14 deletions.
6 changes: 4 additions & 2 deletions analysis/parameter_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ def _find_candidate_parameters(
if calculate_sum_per_partition_param:
if hist.linf_sum_contributions_histogram.bins[0].lower >= 0:
logging.warning(
"max_sum_per_partition should not contain negative sums because min_sum_per_partition tuning is not supported yet and therefore tuning for max_sum_per_partition works only when linf_sum_contributions_histogram does not negative sums"
)
"max_sum_per_partition should not contain negative sums because"
" min_sum_per_partition tuning is not supported yet and "
"therefore tuning for max_sum_per_partition works only when "
"linf_sum_contributions_histogram does not negative sums")

if calculate_l0_param and calculate_linf_count:
l0_bounds, linf_bounds = _find_candidates_parameters_in_2d_grid(
Expand Down
2 changes: 1 addition & 1 deletion pipeline_dp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
from pipeline_dp.pipeline_backend import PipelineBackend
from pipeline_dp.pipeline_backend import SparkRDDBackend

__version__ = '0.2.1rc4'
__version__ = '0.2.1rc5'
12 changes: 12 additions & 0 deletions pipeline_dp/budget_accounting.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
pass


def _check_pldlib_imported() -> bool:
import sys
return "dp_accounting.pld.privacy_loss_distribution" in sys.modules


@dataclass
class MechanismSpec:
"""Specifies the parameters for a DP mechanism.
Expand Down Expand Up @@ -446,6 +451,13 @@ def __init__(self,
super().__init__(total_epsilon, total_delta, num_aggregations,
aggregation_weights)

if not _check_pldlib_imported():
raise ImportError("dp_accounting library is not imported. It is"
"required for using PLD budget accounting. "
"Please install dp_accounting library or use"
"NaiveBudgetAccountant instead of "
"PLDBudgetAccountant")

self.minimum_noise_std = None
self._pld_discretization = pld_discretization

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pipeline-dp"
version = "0.2.1rc4"
version = "0.2.1rc5"
description = ""
authors = ["Chinmay Shah <[email protected]>", "Vadym Doroshenko <[email protected]>"]
license = "Apache-2.0"
Expand All @@ -9,7 +9,6 @@ license = "Apache-2.0"
python = "^3.8, < 3.12"
python-dp = "^1.1.4"
numpy = "^1.20.1"
dp_accounting = "^0.4.2"

[tool.poetry.dev-dependencies]
yapf = "^0.32.0"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.1rc4
current_version = 0.2.1rc5
commit = True
tag = True

Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
install_requires = \
['numpy>=1.20.1,<2.0.0',
'python-dp>=1.1.4',
'scipy>=1.7.3,<2.0.0',
'dp_accounting>=0.4.2'
'scipy>=1.7.3,<2.0.0'
]


Expand All @@ -22,7 +21,7 @@ def read(fname):

setup_kwargs = {
'name': 'pipeline-dp',
'version': '0.2.1rc4',
'version': '0.2.1rc5',
'description': 'Framework for applying differential privacy to large datasets using batch processing systems',
'author': 'Chinmay Shah',
'author_email': '[email protected]',
Expand Down
5 changes: 2 additions & 3 deletions tests/budget_accounting_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@ def test_not_enough_aggregations(self, use_num_aggregations):
budget_accountant.compute_budgets()


@unittest.skipIf(
sys.version_info.major == 3 and sys.version_info.minor == 8,
"There are some problems with dp_accounting library in python 3.8")
@unittest.skipIf(sys.version_info.major == 3 and sys.version_info.minor <= 8,
"dp_accounting library only support python >=3.9")
class PLDBudgetAccountantTest(unittest.TestCase):

def test_noise_not_calculated(self):
Expand Down
10 changes: 8 additions & 2 deletions tests/dp_engine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,8 @@ def run_e2e_private_partition_selection_large_budget(self, col, backend):
return col

@unittest.skipIf(
sys.version_info.major == 3 and sys.version_info.minor == 8,
"There are some problems with dp_accounting library in python 3.8")
sys.version_info.major == 3 and sys.version_info.minor <= 8,
"dp_accounting library only support python >=3.9")
@parameterized.parameters(False, True)
def test_run_e2e_count_public_partition_local(self, pld_accounting):
Accountant = pipeline_dp.PLDBudgetAccountant if pld_accounting else pipeline_dp.NaiveBudgetAccountant
Expand Down Expand Up @@ -1224,6 +1224,9 @@ def test_min_max_sum_per_partition(self):
self.assertLen(output, 1)
self.assertAlmostEqual(output[0][1].sum, -3, delta=0.1)

@unittest.skipIf(
sys.version_info.major == 3 and sys.version_info.minor <= 8,
"dp_accounting library only support python >=3.9")
def test_pld_not_supported_metrics(self):
with self.assertRaisesRegex(
NotImplementedError,
Expand All @@ -1237,6 +1240,9 @@ def test_pld_not_supported_metrics(self):
engine.aggregate([1], aggregate_params,
self._get_default_extractors(), public_partitions)

@unittest.skipIf(
sys.version_info.major == 3 and sys.version_info.minor <= 8,
"dp_accounting library only support python >=3.9")
def test_pld_not_support_private_partition_selection(self):
with self.assertRaisesRegex(
NotImplementedError,
Expand Down

0 comments on commit 09b7aad

Please sign in to comment.