Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove general toml #261

Merged
merged 4 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/source/usage/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ column is ``data_free``. It is also required to set the number of rows under the

.. code-block:: toml

[general]
n_rows = 100


Expand Down
3 changes: 1 addition & 2 deletions examples/example_config.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Example toml file as input for metasyn

[general]
dist_providers = ["builtin", "metasyn-disclosure"]

[general.privacy]
[privacy]
name = "disclosure"
parameters = {n_avg = 11}

Expand Down
11 changes: 5 additions & 6 deletions metasyn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@ def from_toml(cls, config_fp: Union[str, Path]) -> MetaConfig:
"""
with open(config_fp, "rb") as handle:
config_dict = tomllib.load(handle)
general = config_dict.get("general", {})
var_list = config_dict.pop("var", [])
n_rows = general.pop("n_rows", None)
dist_providers = general.pop("dist_providers", ["builtin"])
privacy = general.pop("privacy", {"name": "none", "parameters": {}})
if len(general) > 0:
n_rows = config_dict.pop("n_rows", None)
dist_providers = config_dict.pop("dist_providers", ["builtin"])
privacy = config_dict.pop("privacy", {"name": "none", "parameters": {}})
if len(config_dict) > 0:
raise ValueError(f"Error parsing configuration file '{config_fp}'."
f" Unknown keys detected: '{list(general)}'")
f" Unknown keys detected: '{list(config_dict)}'")
return cls(var_list, dist_providers, privacy, n_rows=n_rows)

def to_dict(self) -> dict:
Expand Down
2 changes: 0 additions & 2 deletions tests/data/example_config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Example toml file as input for metasyn

[general]
dist_providers = ["builtin"]


Expand Down
2 changes: 0 additions & 2 deletions tests/data/no_data_config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Example toml file as input for metasyn

[general]
n_rows = 100


Expand Down
Loading