From 94ea4d4e75ab63d2897a818bb3cec1abcac9552a Mon Sep 17 00:00:00 2001 From: Justin Patriquin Date: Tue, 23 Jun 2020 10:04:07 -0300 Subject: [PATCH] 0.1.0rc0 release plus minor fixes --- .github/workflows/release.yml | 1 + cape_privacy/pandas/__init__.py | 3 ++- cape_privacy/spark/__init__.py | 2 ++ examples/simple_transformation.py | 4 ++-- examples/spark_example.py | 2 +- examples/spark_round.yaml | 24 +++++++------------ .../tutorials/apply_policy_on_pandas_df.py | 2 +- .../tutorials/apply_policy_on_spark_df.py | 2 +- setup.py | 4 ++-- 9 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b2a8d90..cf6cff4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,4 +32,5 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + repository: capeprivacy/cape-python tag_with_ref: true diff --git a/cape_privacy/pandas/__init__.py b/cape_privacy/pandas/__init__.py index 5fecd7f..724320b 100644 --- a/cape_privacy/pandas/__init__.py +++ b/cape_privacy/pandas/__init__.py @@ -1,5 +1,6 @@ from cape_privacy.pandas import dtypes +from cape_privacy.pandas import registry from cape_privacy.pandas import transformations from cape_privacy.pandas.transformer import transformer -__all__ = ["dtypes", "transformations", "transformer"] +__all__ = ["dtypes", "transformations", "transformer", "registry"] diff --git a/cape_privacy/spark/__init__.py b/cape_privacy/spark/__init__.py index 61d571d..6f17e5d 100644 --- a/cape_privacy/spark/__init__.py +++ b/cape_privacy/spark/__init__.py @@ -14,6 +14,7 @@ def is_available(): from cape_privacy.spark import dtypes from cape_privacy.spark import transformations from cape_privacy.spark.transformer import transformer + from cape_privacy.spark import registry def is_available(): return True @@ -24,6 +25,7 @@ def is_available(): "is_available", "transformations", "transformer", + "registry", ] del importlib diff --git a/examples/simple_transformation.py b/examples/simple_transformation.py index e5e9c9e..91b1ea8 100644 --- a/examples/simple_transformation.py +++ b/examples/simple_transformation.py @@ -1,11 +1,11 @@ import pandas as pd import numpy as np -import cape_privacy.pandas as cape +import cape_privacy as cape df = pd.DataFrame(np.ones(5,), columns=["value"]) policy = cape.parse_policy("perturb_value_field.yaml") -df = cape.apply_policy([policy], df) +df = cape.apply_policy(policy, df) print(df.head()) diff --git a/examples/spark_example.py b/examples/spark_example.py index 85794cd..fb73c5a 100644 --- a/examples/spark_example.py +++ b/examples/spark_example.py @@ -20,6 +20,6 @@ rounding_spec = policy.transformations[0] type_arg = getattr(dtypes, rounding_spec.args['dtype']) rounding_spec.args['dtype'] = type_arg -rounder = tfms.Rounding(**rounding_spec.args) +rounder = tfms.NumericRounding(**rounding_spec.args) df = df.select(rounder(functions.col('value'))) df.show() diff --git a/examples/spark_round.yaml b/examples/spark_round.yaml index 7c9192e..46ced52 100644 --- a/examples/spark_round.yaml +++ b/examples/spark_round.yaml @@ -1,19 +1,13 @@ label: spark-round-float +version: 1 transformations: - name: roundToZero type: roundNumeric - args: - dtype: - value: Float - precision: - value: 0 -spec: - label: spark-round-float - rules: - - target: records::creditcards.transactions - action: read - effect: allow - transformations: - - field: value - named: roundFloat - version: 1 + dtype: Float + precision: 0 +rules: + - match: + name: value + actions: + - transform: + name: roundFloat diff --git a/examples/tutorials/apply_policy_on_pandas_df.py b/examples/tutorials/apply_policy_on_pandas_df.py index eae7b12..e19cfcb 100644 --- a/examples/tutorials/apply_policy_on_pandas_df.py +++ b/examples/tutorials/apply_policy_on_pandas_df.py @@ -11,7 +11,7 @@ policy = cape_privacy.parse_policy("mask_personal_information.yaml") # Apply the policy to the DataFrame # [NOTE] will be updated to `cape_privacy.apply_policy` #49 is merged -df = cape_privacy.pandas.policy.apply_policies([policy], df) +df = cape_privacy.apply_policy(policy, df) # Output the masked dataset print("Masked Dataset:") print(df.head()) diff --git a/examples/tutorials/apply_policy_on_spark_df.py b/examples/tutorials/apply_policy_on_spark_df.py index 264035f..5cc32d0 100644 --- a/examples/tutorials/apply_policy_on_spark_df.py +++ b/examples/tutorials/apply_policy_on_spark_df.py @@ -10,7 +10,7 @@ policy = cape_privacy.parse_policy("mask_personal_information.yaml") # Apply the policy to the DataFrame # [NOTE] will be updated to `cape_privacy.apply_policy` #49 is merged -df = cape_privacy.spark.policy.apply_policies([policy], df) +df = cape_privacy.apply_policy(policy, df) # Output the masked dataset print("Masked Dataset:") print(df.show()) diff --git a/setup.py b/setup.py index bcfbe1e..910a02e 100644 --- a/setup.py +++ b/setup.py @@ -2,8 +2,8 @@ import setuptools setuptools.setup( - name="cape_privacy", - version="0.0.1", + name="cape-privacy", + version="0.1.0rc0", packages=setuptools.find_packages(), python_requires=">=3.6", license="Apache License 2.0",