dp_wizard_templates 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dp_wizard_templates might be problematic. Click here for more details.

Files changed (32) hide show
  1. dp_wizard_templates-0.1.0/.coveragerc +17 -0
  2. dp_wizard_templates-0.1.0/.flake8 +14 -0
  3. dp_wizard_templates-0.1.0/.github/workflows/test.yml +40 -0
  4. dp_wizard_templates-0.1.0/.gitignore +209 -0
  5. dp_wizard_templates-0.1.0/.pre-commit-config.yaml +17 -0
  6. dp_wizard_templates-0.1.0/.pytest.ini +14 -0
  7. dp_wizard_templates-0.1.0/CHANGELOG.md +5 -0
  8. dp_wizard_templates-0.1.0/LICENSE +21 -0
  9. dp_wizard_templates-0.1.0/PKG-INFO +65 -0
  10. dp_wizard_templates-0.1.0/README.md +50 -0
  11. dp_wizard_templates-0.1.0/README_examples/_block_demo.py +5 -0
  12. dp_wizard_templates-0.1.0/README_examples/hello-world.html +7564 -0
  13. dp_wizard_templates-0.1.0/README_examples/hello-world.ipynb +67 -0
  14. dp_wizard_templates-0.1.0/README_test.py +139 -0
  15. dp_wizard_templates-0.1.0/dp_wizard_templates/VERSION +1 -0
  16. dp_wizard_templates-0.1.0/dp_wizard_templates/__init__.py +6 -0
  17. dp_wizard_templates-0.1.0/dp_wizard_templates/code_template.py +127 -0
  18. dp_wizard_templates-0.1.0/dp_wizard_templates/converters.py +119 -0
  19. dp_wizard_templates-0.1.0/pyproject.toml +23 -0
  20. dp_wizard_templates-0.1.0/requirements-dev.in +17 -0
  21. dp_wizard_templates-0.1.0/requirements-dev.txt +275 -0
  22. dp_wizard_templates-0.1.0/requirements.in +7 -0
  23. dp_wizard_templates-0.1.0/requirements.txt +181 -0
  24. dp_wizard_templates-0.1.0/scripts/changelog.py +70 -0
  25. dp_wizard_templates-0.1.0/scripts/ci.sh +6 -0
  26. dp_wizard_templates-0.1.0/scripts/requirements.py +100 -0
  27. dp_wizard_templates-0.1.0/tests/fixtures/fake-executed.ipynb +72 -0
  28. dp_wizard_templates-0.1.0/tests/fixtures/fake.ipynb +45 -0
  29. dp_wizard_templates-0.1.0/tests/fixtures/fake.py +12 -0
  30. dp_wizard_templates-0.1.0/tests/test_code_template.py +150 -0
  31. dp_wizard_templates-0.1.0/tests/test_converters.py +73 -0
  32. dp_wizard_templates-0.1.0/tests/test_misc.py +22 -0
@@ -0,0 +1,17 @@
1
+ [run]
2
+ # All files under source are checked, even if not otherwise referenced.
3
+ source = .
4
+
5
+ # More strict: Check transitions between lines, not just individual lines.
6
+ # TODO: branch = True
7
+
8
+ omit =
9
+ README_examples/*
10
+
11
+
12
+ [report]
13
+ show_missing = True
14
+ skip_covered = True
15
+ fail_under = 100
16
+ exclude_also =
17
+ template
@@ -0,0 +1,14 @@
1
+ [flake8]
2
+ exclude = .git,.venv,.venv-*,__pycache__
3
+
4
+ # Config recommended by black:
5
+ # https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#bugbear
6
+ max-line-length = 80
7
+ extend-select = B950
8
+ extend-ignore = E203,E501,E701
9
+
10
+ per-file-ignores =
11
+ # Ignore undefined names in templates.
12
+ README_examples/*.py:F821,F401,E302
13
+ # Ignore mid-file imports: These are better for exaplanation.
14
+ README_test.py:E402
@@ -0,0 +1,40 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-22.04
12
+ strategy:
13
+ matrix:
14
+ python-version:
15
+ - '3.10'
16
+ - '3.13'
17
+ requirements-file:
18
+ - 'requirements-dev.txt' # pinned, for predictability
19
+ - 'requirements-dev.in' # un-pinned, so we catch problems early
20
+
21
+ steps:
22
+ - name: Checkout repository
23
+ uses: actions/checkout@v4
24
+
25
+ - name: Set up Python ${{ matrix.python-version }}
26
+ uses: actions/setup-python@v5
27
+ with:
28
+ python-version: ${{ matrix.python-version }}
29
+
30
+ - name: Install flit
31
+ run: pip install flit
32
+
33
+ - name: Install package
34
+ run: flit install
35
+
36
+ - name: Install dev dependencies
37
+ run: pip install -r ${{ matrix.requirements-file }}
38
+
39
+ - name: Test
40
+ run: scripts/ci.sh
@@ -0,0 +1,209 @@
1
+ .DS_Store
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[codz]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py.cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # UV
100
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ #uv.lock
104
+
105
+ # poetry
106
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
107
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
108
+ # commonly ignored for libraries.
109
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
110
+ #poetry.lock
111
+ #poetry.toml
112
+
113
+ # pdm
114
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
115
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
116
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
117
+ #pdm.lock
118
+ #pdm.toml
119
+ .pdm-python
120
+ .pdm-build/
121
+
122
+ # pixi
123
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
124
+ #pixi.lock
125
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
126
+ # in the .venv directory. It is recommended not to include this directory in version control.
127
+ .pixi
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule
134
+ celerybeat.pid
135
+
136
+ # SageMath parsed files
137
+ *.sage.py
138
+
139
+ # Environments
140
+ .env
141
+ .envrc
142
+ .venv
143
+ env/
144
+ venv/
145
+ ENV/
146
+ env.bak/
147
+ venv.bak/
148
+
149
+ # Spyder project settings
150
+ .spyderproject
151
+ .spyproject
152
+
153
+ # Rope project settings
154
+ .ropeproject
155
+
156
+ # mkdocs documentation
157
+ /site
158
+
159
+ # mypy
160
+ .mypy_cache/
161
+ .dmypy.json
162
+ dmypy.json
163
+
164
+ # Pyre type checker
165
+ .pyre/
166
+
167
+ # pytype static type analyzer
168
+ .pytype/
169
+
170
+ # Cython debug symbols
171
+ cython_debug/
172
+
173
+ # PyCharm
174
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
175
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
176
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
177
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
178
+ #.idea/
179
+
180
+ # Abstra
181
+ # Abstra is an AI-powered process automation framework.
182
+ # Ignore directories containing user credentials, local state, and settings.
183
+ # Learn more at https://abstra.io/docs
184
+ .abstra/
185
+
186
+ # Visual Studio Code
187
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
188
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
189
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
190
+ # you could uncomment the following to ignore the entire vscode folder
191
+ # .vscode/
192
+
193
+ # Ruff stuff:
194
+ .ruff_cache/
195
+
196
+ # PyPI configuration file
197
+ .pypirc
198
+
199
+ # Cursor
200
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
201
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
202
+ # refer to https://docs.cursor.com/context/ignore-files
203
+ .cursorignore
204
+ .cursorindexingignore
205
+
206
+ # Marimo
207
+ marimo/_static/
208
+ marimo/_lsp/
209
+ __marimo__/
@@ -0,0 +1,17 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v2.3.0
4
+ hooks:
5
+ - id: check-yaml
6
+ - id: end-of-file-fixer
7
+ - id: trailing-whitespace
8
+ # Using this mirror lets us use mypyc-compiled black, which is about 2x faster
9
+ - repo: https://github.com/psf/black-pre-commit-mirror
10
+ rev: 24.8.0
11
+ hooks:
12
+ - id: black
13
+ # It is recommended to specify the latest version of Python
14
+ # supported by your project here, or alternatively use
15
+ # pre-commit's default_language_version, see
16
+ # https://pre-commit.com/#top_level-default_language_version
17
+ language_version: python3.11
@@ -0,0 +1,14 @@
1
+ [pytest]
2
+
3
+
4
+
5
+ filterwarnings =
6
+ # Treat warnings as errors,
7
+ error
8
+ # except for https://github.com/jupyter/jupyter_core/issues/398
9
+ ignore:.*Jupyter is migrating.*:DeprecationWarning
10
+
11
+ addopts = --doctest-glob '*.md' --doctest-modules
12
+
13
+ # If an xfail starts passing unexpectedly, that should count as a failure:
14
+ xfail_strict=true
@@ -0,0 +1,5 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.1.0
4
+
5
+ Initial release
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 OpenDP
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.4
2
+ Name: dp_wizard_templates
3
+ Version: 0.1.0
4
+ Summary: Code templating tools
5
+ Author-email: The OpenDP Project <info@opendp.org>
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: black
9
+ Requires-Dist: ipykernel
10
+ Requires-Dist: jupyter-client
11
+ Requires-Dist: jupytext
12
+ Requires-Dist: nbconvert
13
+ Project-URL: Home, https://github.com/opendp/dp-wizard-templates
14
+
15
+ # DP Wizard Templates
16
+
17
+ [![pypi](https://img.shields.io/pypi/v/dp_wizard_templates)](https://pypi.org/project/dp_wizard_templates/)
18
+
19
+ DP Wizard Templates lets you use syntactically valid Python code as a template.
20
+ Templates can be filled and composed to generate entire notebooks.
21
+
22
+ [`README_test.py`](https://github.com/opendp/dp-wizard-templates/blob/main/README_test.py) provides an example of use,
23
+ and an example [output notebook](https://github.com/opendp/dp-wizard-templates/blob/main/README_examples/hello-world.ipynb)
24
+ is also available.
25
+
26
+ DP Wizard Templates was developed for [DP Wizard](https://github.com/opendp/dp-wizard),
27
+ and that codebase remains a good place to look for further examples.
28
+
29
+
30
+ ## Development
31
+
32
+ ### Getting Started
33
+
34
+ On MacOS:
35
+ ```shell
36
+ $ git clone https://github.com/opendp/dp-wizard-templates.git
37
+ $ cd dp-wizard-templates
38
+ $ brew install python@3.10
39
+ $ python3.10 -m venv .venv
40
+ $ source .venv/bin/activate
41
+ ```
42
+
43
+ You can now install dependencies:
44
+ ```shell
45
+ $ pip install -r requirements-dev.txt
46
+ $ pre-commit install
47
+ $ flit install
48
+ ```
49
+
50
+ Tests should pass, and code coverage should be complete (except blocks we explicitly ignore):
51
+ ```shell
52
+ $ scripts/ci.sh
53
+ ```
54
+
55
+ ### Release
56
+
57
+ - Make sure you're up to date, and have the git-ignored credentials file `.pypirc`.
58
+ - Make one last feature branch with the new version number in the name:
59
+ - Run `scripts/changelog.py` to update the `CHANGELOG.md`.
60
+ - Review the updates and pull a couple highlights to the top.
61
+ - Bump `dp_wizard/VERSION`, and add the new number at the top of the `CHANGELOG.md`.
62
+ - Commit your changes, make a PR, and merge this branch to main.
63
+ - Update `main` with the latest changes: `git checkout main; git pull`
64
+ - Publish: `flit publish --pypirc .pypirc`
65
+
@@ -0,0 +1,50 @@
1
+ # DP Wizard Templates
2
+
3
+ [![pypi](https://img.shields.io/pypi/v/dp_wizard_templates)](https://pypi.org/project/dp_wizard_templates/)
4
+
5
+ DP Wizard Templates lets you use syntactically valid Python code as a template.
6
+ Templates can be filled and composed to generate entire notebooks.
7
+
8
+ [`README_test.py`](https://github.com/opendp/dp-wizard-templates/blob/main/README_test.py) provides an example of use,
9
+ and an example [output notebook](https://github.com/opendp/dp-wizard-templates/blob/main/README_examples/hello-world.ipynb)
10
+ is also available.
11
+
12
+ DP Wizard Templates was developed for [DP Wizard](https://github.com/opendp/dp-wizard),
13
+ and that codebase remains a good place to look for further examples.
14
+
15
+
16
+ ## Development
17
+
18
+ ### Getting Started
19
+
20
+ On MacOS:
21
+ ```shell
22
+ $ git clone https://github.com/opendp/dp-wizard-templates.git
23
+ $ cd dp-wizard-templates
24
+ $ brew install python@3.10
25
+ $ python3.10 -m venv .venv
26
+ $ source .venv/bin/activate
27
+ ```
28
+
29
+ You can now install dependencies:
30
+ ```shell
31
+ $ pip install -r requirements-dev.txt
32
+ $ pre-commit install
33
+ $ flit install
34
+ ```
35
+
36
+ Tests should pass, and code coverage should be complete (except blocks we explicitly ignore):
37
+ ```shell
38
+ $ scripts/ci.sh
39
+ ```
40
+
41
+ ### Release
42
+
43
+ - Make sure you're up to date, and have the git-ignored credentials file `.pypirc`.
44
+ - Make one last feature branch with the new version number in the name:
45
+ - Run `scripts/changelog.py` to update the `CHANGELOG.md`.
46
+ - Review the updates and pull a couple highlights to the top.
47
+ - Bump `dp_wizard/VERSION`, and add the new number at the top of the `CHANGELOG.md`.
48
+ - Commit your changes, make a PR, and merge this branch to main.
49
+ - Update `main` with the latest changes: `git checkout main; git pull`
50
+ - Publish: `flit publish --pypirc .pypirc`
@@ -0,0 +1,5 @@
1
+ def FUNCTION_NAME(PARAMS):
2
+ """
3
+ This demonstrates how larger blocks of code can be built compositionally.
4
+ """
5
+ INNER_BLOCK