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.8.tar.gz
(4.4 kB
view details)
Built Distribution
File details
Details for the file opendp-logger-0.1.8.tar.gz
.
File metadata
- Download URL: opendp-logger-0.1.8.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.28.1 setuptools/65.5.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e45b91fa5441e42da84b641a2303129c102f615276c9ac266a8f317e8009e30b |
|
MD5 | 179d1b344a2936fe094b98fe264530a1 |
|
BLAKE2b-256 | 703e60125c8c1df153a7fae41eb9824bcd036dc829f6b4e3d57ffab02f429c93 |
File details
Details for the file opendp_logger-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: opendp_logger-0.1.8-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.28.1 setuptools/65.5.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37f5037afc23ec077ff6410da635181e58b2071c6b241e6b81c6afd2ca241f25 |
|
MD5 | f6fb764d83d8b6ddafbbfd181be4c0f0 |
|
BLAKE2b-256 | eb727afa505f8ba325bb3eda4f2014d917d319c352520dc7a51ad5cf9e23a241 |