A logger wrapper for OpenDP to keep track of, import, export the AST
Project description
OpenDP Logger
The OpenDP logger makes it possible to serialize and deserialize OpenDP Measurements/Transformations to/from JSON.
Serialize
Enable logging (globally) before you build your transformations and/or measurements:
from opendp_logging import enable_logging
enable_logging()
Once this is enabled, Transformations/Measurements have a method .to_json()
that returns a JSON string.
Deserialize
Deserialize a JSON string into a Transformation/Measurement by invoking opendp_logger.make_load_json
.
Example
from opendp_logger import enable_logging
from opendp.mod import enable_features
enable_logging()
enable_features("contrib")
import opendp.transformations as trans
preprocessor = (
# load data into a dataframe where columns are of type Vec<str>
trans.make_split_dataframe(separator=",", col_names=["hello", "world"])
>>
# select a column of the dataframe
trans.make_select_column(key="income", TOA=str)
)
# the ast object maintained in the pipeline
print("ast:", preprocessor.ast)
# serialize the ast to json
json_obj = preprocessor.to_json()
print("json:", json_obj)
from opendp_logger import make_load_json
# reconstruct the obj from the json string
test = make_load_json(json_obj)
print(test.ast)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
opendp-logger-0.1.5.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for opendp_logger-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d41b31f0d274fe991d12a582e8ae26d75b532749e5d2948f055d1b4dcadba298 |
|
MD5 | 063afe1905678d8ac3def9db1f820570 |
|
BLAKE2b-256 | aaef3a640bf88bf8bac0a2bf9eda38bd76d14df261dac2cf3e28967a28715569 |