Skip to content

Commit

Permalink
Remove general from toml specification (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
qubixes authored Feb 28, 2024
1 parent 65bd520 commit d7a90d9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
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

0 comments on commit d7a90d9

Please sign in to comment.