Skip to content

Commit

Permalink
Change from metasynth to metasyn
Browse files Browse the repository at this point in the history
  • Loading branch information
qubixes committed Jan 19, 2024
1 parent be6e95d commit 6974541
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 59 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
python -m pip install cookiecutter
- name: Try to install the template
run: |
printf "\n\n\n\n" | cookiecutter https://github.com/sodascience/metasynth-plugin-template
printf "\n\n\n\n" | cookiecutter https://github.com/sodascience/metasyn-plugin-template
- name: Check installation
run: |
test -d metasynth-differential-privacy
cd metasynth-differential-privacy
test -d metasyn-differential-privacy
cd metasyn-differential-privacy
pip install .
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# MetaSynth plugin template
# metasyn plugin template

Template for creating plugins for the MetaSynth library. Follow these steps to create a new plugin from this template:
Template for creating plugins for the metasyn library. Follow these steps to create a new plugin from this template:

- Install cookiecutter: `pip install cookiecutter` on the command line.
- Use the template: `cookiecutter https://github.com/sodascience/metasynth-plugin-template`
- Use the template: `cookiecutter https://github.com/sodascience/metasyn-plugin-template`

The template is now ready to use. To finish your plugin, edit the following modules:

- `metasynthcontrib.{plugin_name}.privacy`: If you are writing a new privacy plugin, edit the `__init__` and `to_dict` methods. Otherwise delete this file.
- `metasynthcontrib.{plugin_name}.base`: Change the `privacy` class variable if necessary.
- `metasynthcontrib.{plugin_name}.categorical/continuous/datetime/string/discrete`: Implement distributions here.
- `metasynthcontrib.{plugin_name}.provider`: Add the newly implemented distributions.
- `metasyncontrib.{plugin_name}.privacy`: If you are writing a new privacy plugin, edit the `__init__` and `to_dict` methods. Otherwise delete this file.
- `metasyncontrib.{plugin_name}.base`: Change the `privacy` class variable if necessary.
- `metasyncontrib.{plugin_name}.categorical/continuous/datetime/string/discrete`: Implement distributions here.
- `metasyncontrib.{plugin_name}.provider`: Add the newly implemented distributions.

Your plugin should now be ready to go. GitHub actions is part of the template, so after pushing your new plugin to GitHub it should automatically start testing your code.
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"plugin_name": "Differential Privacy",
"user_name": "Raoul Schram",
"email": "[email protected]",
"__plugin_slug": "metasynth-{{ cookiecutter.plugin_name|lower|replace(' ', '-') }}",
"__plugin_slug": "metasyn-{{ cookiecutter.plugin_name|lower|replace(' ', '-') }}",
"__package_name": "{{ cookiecutter.plugin_name|lower|replace(' ', '_') }}",
"__plugin_camel": "{{ cookiecutter.plugin_name|replace(' ', '') }}",
"privacy": "{{ cookiecutter.__package_name }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ jobs:
python -m pip install .[test]
- name: Lint with pylint
run: |
pylint metasynthcontrib/{{ cookiecutter.__package_name }}
pylint metasyncontrib/{{ cookiecutter.__package_name }}
- name: Check docstrings with pydocstyle
run: |
pydocstyle metasynthcontrib/{{ cookiecutter.__package_name }} --convention=numpy --add-select=D417 --add-ignore="D102,D105"
pydocstyle metasyncontrib/{{ cookiecutter.__package_name }} --convention=numpy --add-select=D417 --add-ignore="D102,D105"
- name: Check types with MyPy
run: |
mypy metasynthcontrib/{{ cookiecutter.__package_name }}
mypy metasyncontrib/{{ cookiecutter.__package_name }}
- name: Test with pytest
run: |
pytest tests
Expand Down
2 changes: 1 addition & 1 deletion {{ cookiecutter.__plugin_slug }}/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include metasynthcontrib/{{ cookiecutter.__package_name }}/py.typed
include metasyncontrib/{{ cookiecutter.__package_name }}/py.typed
22 changes: 11 additions & 11 deletions {{ cookiecutter.__plugin_slug }}/examples/tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"id": "f5c6597b",
"metadata": {},
"source": [
"# Tutorial on MetaSynth-disclosure\n",
"# Tutorial on metasyn-disclosure\n",
"\n",
"In this tutorial, we will show how to use the MetaSynth disclosure control plugin. It uses the same procedure as the base MetaSynth [package](https://github.com/sodascience/metasynth/blob/main/examples/advanced_tutorial.ipynb). The output format will be the same: a GMF file will be created with the same parameter types as with the base package. One difference is that not all distributions are implemented by the disclosure plugin. The missing distributions will not be fit by default, but they can be manually set."
"In this tutorial, we will show how to use the metasyn disclosure control plugin. It uses the same procedure as the base metasyn [package](https://github.com/sodascience/metasyn/blob/main/examples/advanced_tutorial.ipynb). The output format will be the same: a GMF file will be created with the same parameter types as with the base package. One difference is that not all distributions are implemented by the disclosure plugin. The missing distributions will not be fit by default, but they can be manually set."
]
},
{
Expand All @@ -25,9 +25,9 @@
"import polars as pl\n",
"from matplotlib import pyplot as plt\n",
"\n",
"from metasynth import MetaDataset\n",
"from metasynthcontrib.disclosure import DisclosurePrivacy\n",
"from metasynth.provider import DistributionProviderList\n",
"from metasyn import MetaDataset\n",
"from metasyncontrib.disclosure import DisclosurePrivacy\n",
"from metasyn.provider import DistributionProviderList\n",
"from utils import get_demonstration_fp"
]
},
Expand Down Expand Up @@ -103,7 +103,7 @@
"source": [
"### A full example with the base package\n",
"\n",
"Below we have the synthesis that uses the base MetaSynth package so that we can see potential problems with it. For a more detailed explanation of the base package, see our base [tutorial](https://github.com/sodascience/metasynth/blob/main/examples/advanced_tutorial.ipynb)."
"Below we have the synthesis that uses the base metasyn package so that we can see potential problems with it. For a more detailed explanation of the base package, see our base [tutorial](https://github.com/sodascience/metasyn/blob/main/examples/advanced_tutorial.ipynb)."
]
},
{
Expand Down Expand Up @@ -158,8 +158,8 @@
}
],
"source": [
"from metasynth.distribution import RegexDistribution, FakerDistribution\n",
"from metasynth.distribution import DiscreteUniformDistribution\n",
"from metasyn.distribution import RegexDistribution, FakerDistribution\n",
"from metasyn.distribution import DiscreteUniformDistribution\n",
"\n",
"cabin_distribution = RegexDistribution(r\"[ABCDEF]\\d{2,3}\")\n",
"var_spec = {\n",
Expand Down Expand Up @@ -191,7 +191,7 @@
"source": [
"### A full example with disclosure\n",
"\n",
"Below is the same example with the MetaSynth disclosure plugin."
"Below is the same example with the metasyn disclosure plugin."
]
},
{
Expand Down Expand Up @@ -272,7 +272,7 @@
"id": "ea8e0833",
"metadata": {},
"source": [
"As you can see, the disclosure plugin fixes the privacy concern present in the base MetaSynth package: the lower bound of the distribution is no longer equal to the lowest value in the dataframe."
"As you can see, the disclosure plugin fixes the privacy concern present in the base metasyn package: the lower bound of the distribution is no longer equal to the lowest value in the dataframe."
]
},
{
Expand All @@ -282,7 +282,7 @@
"source": [
"## Single outliers\n",
"\n",
"Below we will look at what happens to our parameters if we add a single new value (outlier) to the data. We do this for both the base MetaSynth implementation and the disclosure control implementation. We expect that following the rules of disclosure control, a single outlier should have a smaller (and limited) effect on the results than with the base MetaSynth implementation."
"Below we will look at what happens to our parameters if we add a single new value (outlier) to the data. We do this for both the base metasyn implementation and the disclosure control implementation. We expect that following the rules of disclosure control, a single outlier should have a smaller (and limited) effect on the results than with the base metasyn implementation."
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions {{ cookiecutter.__plugin_slug }}/examples/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pandas as pd
import numpy as np
from metasynth.distribution.datetime import UniformDateTimeDistribution, UniformTimeDistribution
from metasynth.distribution.datetime import UniformDateDistribution
from metasyn.distribution.datetime import UniformDateTimeDistribution, UniformTimeDistribution
from metasyn.distribution.datetime import UniformDateDistribution
import wget
from pathlib import Path
import random
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""{{ cookiecutter.plugin_name|lower }} plugin for metasyn."""
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Base class for all {{ cookiecutter.plugin_name|lower }} distributions."""

from metasynth.distribution.base import BaseDistribution
from metasyn.distribution.base import BaseDistribution


class Base{{ cookiecutter.__plugin_camel }}(BaseDistribution):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import polars as pl

from metasynth.distribution.categorical import MultinoulliDistribution
from metasynthcontrib.{{ cookiecutter.__package_name }}.base import Base{{ cookiecutter.__plugin_camel }}
from metasyn.distribution.categorical import MultinoulliDistribution
from metasyncontrib.{{ cookiecutter.__package_name }}.base import Base{{ cookiecutter.__plugin_camel }}


# class {{ cookiecutter.__plugin_camel }}Multinoulli(Base{{ cookiecutter.__plugin_camel }}, MultinoulliDistribution):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import polars as pl

from metasynth.distribution.continuous import UniformDistribution
from metasynth.distribution.continuous import NormalDistribution, LogNormalDistribution
from metasynth.distribution.continuous import ExponentialDistribution
from metasynth.distribution.continuous import TruncatedNormalDistribution
from metasyn.distribution.continuous import UniformDistribution
from metasyn.distribution.continuous import NormalDistribution, LogNormalDistribution
from metasyn.distribution.continuous import ExponentialDistribution
from metasyn.distribution.continuous import TruncatedNormalDistribution

from metasynthcontrib.{{ cookiecutter.__package_name }}.base import Base{{ cookiecutter.__plugin_camel }}
from metasyncontrib.{{ cookiecutter.__package_name }}.base import Base{{ cookiecutter.__plugin_camel }}


# class {{ cookiecutter.__plugin_camel }}Uniform(Base{{ cookiecutter.__plugin_camel }}, UniformDistribution):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import polars as pl

from metasynth.distribution.datetime import UniformDateTimeDistribution
from metasynth.distribution.datetime import UniformTimeDistribution
from metasynth.distribution.datetime import UniformDateDistribution
from metasyn.distribution.datetime import UniformDateTimeDistribution
from metasyn.distribution.datetime import UniformTimeDistribution
from metasyn.distribution.datetime import UniformDateDistribution

from metasynthcontrib.{{ cookiecutter.__package_name }}.base import Base{{ cookiecutter.__plugin_camel }}
from metasyncontrib.{{ cookiecutter.__package_name }}.base import Base{{ cookiecutter.__plugin_camel }}


# class {{ cookiecutter.__plugin_camel }}UniformDateTime(Base{{ cookiecutter.__plugin_camel }}, UniformDateTimeDistribution):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import polars as pl

from metasynth.distribution.discrete import DiscreteUniformDistribution
from metasynth.distribution.discrete import PoissonDistribution
from metasynth.distribution.discrete import UniqueKeyDistribution
from metasyn.distribution.discrete import DiscreteUniformDistribution
from metasyn.distribution.discrete import PoissonDistribution
from metasyn.distribution.discrete import UniqueKeyDistribution

from metasynthcontrib.{{ cookiecutter.__package_name }}.base import Base{{ cookiecutter.__plugin_camel }}
from metasyncontrib.{{ cookiecutter.__package_name }}.base import Base{{ cookiecutter.__plugin_camel }}


# class {{ cookiecutter.__plugin_camel }}UniqueKey(Base{{ cookiecutter.__plugin_camel }}, UniqueKeyDistribution):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""{{ cookiecutter.plugin_name }} privacy class."""

from metasynth.privacy import BasePrivacy
from metasyn.privacy import BasePrivacy


class {{ cookiecutter.__plugin_camel }}Privacy(BasePrivacy):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Module contains distribution tree for {{ cookiecutter.plugin_name|lower }}."""

from __future__ import annotations
from metasynth.provider import BaseDistributionProvider
from metasynth.distribution.base import BaseDistribution
from metasyn.provider import BaseDistributionProvider
from metasyn.distribution.base import BaseDistribution


class {{ cookiecutter.__plugin_camel }}Provider(BaseDistributionProvider):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""{{ cookiecutter.plugin_name }} classes for string variables."""

from metasynth.distribution.faker import FakerDistribution
from metasynth.distribution.regex import RegexDistribution, UniqueRegexDistribution
from metasyn.distribution.faker import FakerDistribution
from metasyn.distribution.regex import RegexDistribution, UniqueRegexDistribution

from metasynthcontrib.{{ cookiecutter.__package_name }}.base import Base{{ cookiecutter.__plugin_camel }}
from metasyncontrib.{{ cookiecutter.__package_name }}.base import Base{{ cookiecutter.__plugin_camel }}


# class {{ cookiecutter.__plugin_camel }}Faker(Base{{ cookiecutter.__plugin_camel }}, FakerDistribution):
Expand Down

This file was deleted.

12 changes: 6 additions & 6 deletions {{ cookiecutter.__plugin_slug }}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ name = "{{ cookiecutter.__plugin_slug }}"
authors = [
{name = "{{ cookiecutter.user_name }}", email = "{{ cookiecutter.email }}"},
]
description = "Plugin package for MetaSynth with {{ cookiecutter.plugin_name }}."
description = "Plugin package for metasyn with {{ cookiecutter.plugin_name }}."
readme = "README.md"
requires-python = ">=3.8"
keywords = ["metasynth", "{{ cookiecutter.plugin_name }}"]
keywords = ["metasyn", "{{ cookiecutter.plugin_name }}"]
license = {text = "MIT"}
classifiers = [
"Programming Language :: Python :: 3",
]
dependencies = [
"metasynth",
"metasyn",
"polars",
]
dynamic = ["version"]
Expand All @@ -27,7 +27,7 @@ test = [
]

[tool.setuptools]
packages = ["metasynthcontrib"]
packages = ["metasyncontrib"]

[project.entry-points."metasynth.distribution_provider"]
{{cookiecutter.__package_name }} = "metasynthcontrib.{{ cookiecutter.__package_name }}.provider:{{ cookiecutter.__plugin_camel }}Provider"
[project.entry-points."metasyn.distribution_provider"]
{{cookiecutter.__package_name }} = "metasyncontrib.{{ cookiecutter.__package_name }}.provider:{{ cookiecutter.__plugin_camel }}Provider"
4 changes: 2 additions & 2 deletions {{ cookiecutter.__plugin_slug }}/tests/test_provider.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pytest import mark

from metasynth.provider import get_distribution_provider
from metasynth.testutils import check_distribution, check_distribution_provider
from metasyn.provider import get_distribution_provider
from metasyn.testutils import check_distribution, check_distribution_provider


def test_{{ cookiecutter.__package_name }}_provider():
Expand Down

0 comments on commit 6974541

Please sign in to comment.