framework-py 0.1.0.dev10__py3-none-any.whl → 0.1.0.dev11__py3-none-any.whl
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.
- framework/__init__.py +2 -1
- framework/_private.py +3 -1
- framework/create.py +10 -5
- framework/outputs.py +5 -3
- framework/project.py +27 -12
- framework/templates/skills/framework-data/.framework-skill.json +1 -1
- framework/templates/skills/framework-data/SKILL.md +5 -2
- framework/templates/skills/framework-sensitive-data/.framework-skill.json +1 -1
- framework/templates/skills/framework-sensitive-data/SKILL.md +23 -2
- {framework_py-0.1.0.dev10.dist-info → framework_py-0.1.0.dev11.dist-info}/METADATA +1 -1
- {framework_py-0.1.0.dev10.dist-info → framework_py-0.1.0.dev11.dist-info}/RECORD +13 -13
- {framework_py-0.1.0.dev10.dist-info → framework_py-0.1.0.dev11.dist-info}/WHEEL +0 -0
- {framework_py-0.1.0.dev10.dist-info → framework_py-0.1.0.dev11.dist-info}/licenses/LICENSE +0 -0
framework/__init__.py
CHANGED
|
@@ -121,7 +121,7 @@ from framework.packages import (
|
|
|
121
121
|
packages_status,
|
|
122
122
|
packages_update,
|
|
123
123
|
)
|
|
124
|
-
from framework.project import path, project_root
|
|
124
|
+
from framework.project import path, project_path, project_root
|
|
125
125
|
from framework.quarto import quarto_generate_all, quarto_regenerate
|
|
126
126
|
from framework.scaffold import project_info, scaffold, status
|
|
127
127
|
from framework.scratch import scratch_capture, scratch_clean
|
|
@@ -234,6 +234,7 @@ __all__ = [
|
|
|
234
234
|
"project_create_from_layers",
|
|
235
235
|
"project_info",
|
|
236
236
|
"project_list",
|
|
237
|
+
"project_path",
|
|
237
238
|
"project_register",
|
|
238
239
|
"project_root",
|
|
239
240
|
"project_unregister",
|
framework/_private.py
CHANGED
|
@@ -139,7 +139,9 @@ def confirm_private_upload(
|
|
|
139
139
|
f"Not uploading {what} without confirmation. "
|
|
140
140
|
"Review it, then pass include_private=True to upload it."
|
|
141
141
|
)
|
|
142
|
-
|
|
142
|
+
# As R asks: "them" when only paths are flagged
|
|
143
|
+
question = "Upload anyway?" if reasons else "Upload them anyway?"
|
|
144
|
+
answer = input(f"{question} [y/N] ").strip().lower()
|
|
143
145
|
if answer not in ("y", "yes"):
|
|
144
146
|
raise FrameworkError("Cancelled. Nothing was uploaded.")
|
|
145
147
|
|
framework/create.py
CHANGED
|
@@ -602,11 +602,16 @@ def _defaults_layer(settings: Mapping[str, Any], type: str) -> dict[str, Any]:
|
|
|
602
602
|
layer["ai"]["assistants"] = assistants
|
|
603
603
|
git = defaults.get("git")
|
|
604
604
|
if isinstance(git, dict):
|
|
605
|
-
layer["git"] = {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
605
|
+
layer["git"] = {} if git.get("initialize") is None else {"use_git": git["initialize"]}
|
|
606
|
+
# As in R, the user's hooks only turn checks on. Global settings hold
|
|
607
|
+
# data_security: false from the shipped defaults for every type, which would
|
|
608
|
+
# otherwise turn off the checks a privacy-sensitive project starts with; the
|
|
609
|
+
# package defaults already have every other check off.
|
|
610
|
+
hooks = git.get("hooks")
|
|
611
|
+
if isinstance(hooks, dict):
|
|
612
|
+
enabled = {name: True for name, value in hooks.items() if value is True}
|
|
613
|
+
if enabled:
|
|
614
|
+
layer["git"]["hooks"] = enabled
|
|
610
615
|
types = settings.get("project_types")
|
|
611
616
|
type_config = types.get(type) if isinstance(types, dict) else None
|
|
612
617
|
if isinstance(type_config, dict) and isinstance(type_config.get("directories"), dict):
|
framework/outputs.py
CHANGED
|
@@ -218,8 +218,9 @@ def _figure_formats(format: str | Sequence[str]) -> list[str]:
|
|
|
218
218
|
)
|
|
219
219
|
if "emf" in formats and not _backend_writes("emf"):
|
|
220
220
|
raise UnsupportedFormatError(
|
|
221
|
-
"emf needs a
|
|
222
|
-
"
|
|
221
|
+
"emf needs a matplotlib backend that writes it, which isn't installed. "
|
|
222
|
+
"Install one that registers emf, or save svg or pdf and convert them "
|
|
223
|
+
"(for example with Inkscape or LibreOffice)."
|
|
223
224
|
)
|
|
224
225
|
return formats
|
|
225
226
|
|
|
@@ -345,7 +346,8 @@ def _data_rows(model: Any) -> int:
|
|
|
345
346
|
if isinstance(frame, pd.DataFrame) and len(frame):
|
|
346
347
|
return len(frame)
|
|
347
348
|
endog = getattr(inner, "endog", None)
|
|
348
|
-
|
|
349
|
+
# As in R, a kept response counts when it has more than one value
|
|
350
|
+
if endog is not None and getattr(endog, "ndim", 0) >= 1 and len(endog) > 1:
|
|
349
351
|
return len(endog)
|
|
350
352
|
attributes = getattr(model, "__dict__", None)
|
|
351
353
|
if isinstance(attributes, dict):
|
framework/project.py
CHANGED
|
@@ -60,15 +60,15 @@ def project_root(start: str | Path | None = None) -> Path:
|
|
|
60
60
|
return found.parent
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
def
|
|
63
|
+
def project_path(*parts: str | PathLike[str]) -> Path:
|
|
64
64
|
"""An absolute path inside the project, from parts relative to its root.
|
|
65
65
|
|
|
66
|
-
Like R's ``here::here()``: the same call gives the same file from a
|
|
67
|
-
``notebooks/``, a script in the root, or a subfolder. Python never changes the
|
|
68
|
-
directory, so ``Path("outputs/tables/x.csv").exists()`` in a notebook looks under
|
|
69
|
-
``notebooks/``; ``fw.
|
|
66
|
+
Like R's ``project_path()`` and ``here::here()``: the same call gives the same file from a
|
|
67
|
+
notebook in ``notebooks/``, a script in the root, or a subfolder. Python never changes the
|
|
68
|
+
working directory, so ``Path("outputs/tables/x.csv").exists()`` in a notebook looks under
|
|
69
|
+
``notebooks/``; ``fw.project_path("outputs/tables/x.csv").exists()`` looks under the root::
|
|
70
70
|
|
|
71
|
-
if not fw.
|
|
71
|
+
if not fw.project_path("outputs", "tables", "incidence.csv").exists():
|
|
72
72
|
...
|
|
73
73
|
|
|
74
74
|
Args:
|
|
@@ -80,13 +80,28 @@ def path(*parts: str | PathLike[str]) -> Path:
|
|
|
80
80
|
|
|
81
81
|
Raises:
|
|
82
82
|
ProjectNotFoundError: Not inside a Framework project.
|
|
83
|
-
ValueError: A part is
|
|
83
|
+
ValueError: A part is absolute or rooted (``"/etc"``, ``"C:\\data"``, ``"~/x"``).
|
|
84
84
|
"""
|
|
85
|
-
root = project_root()
|
|
86
85
|
for part in parts:
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
text = str(part)
|
|
87
|
+
# Rooted on either system: "/etc", "C:\\data", "C:data", "\\data", or "~"
|
|
88
|
+
if Path(part).is_absolute() or PureWindowsPath(part).anchor or text.startswith("~"):
|
|
89
89
|
raise ValueError(
|
|
90
|
-
f"
|
|
90
|
+
f"project_path() parts are relative to the project root, but '{text}' is absolute"
|
|
91
91
|
)
|
|
92
|
-
return
|
|
92
|
+
return project_root().joinpath(*parts)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def path(*parts: str | PathLike[str]) -> Path:
|
|
96
|
+
"""An alias of ``project_path()``, the name R uses.
|
|
97
|
+
|
|
98
|
+
``fw.path(...)`` and ``fw.project_path(...)`` are the same call, and both stay supported.
|
|
99
|
+
New code can use ``project_path()`` so it reads the same in R and Python.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
*parts: Path parts relative to the project root, as for ``project_path()``.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
The absolute path. The file need not exist.
|
|
106
|
+
"""
|
|
107
|
+
return project_path(*parts)
|
|
@@ -30,8 +30,11 @@ or `pyreadstat`.
|
|
|
30
30
|
## Saving
|
|
31
31
|
|
|
32
32
|
```python
|
|
33
|
-
|
|
34
|
-
fw.data_save(final, "inputs/final/analysis_ready.csv"
|
|
33
|
+
# Locked by default: a later read raises an error if the file changed
|
|
34
|
+
fw.data_save(final, "inputs/final/analysis_ready.csv")
|
|
35
|
+
|
|
36
|
+
# Data a pipeline rebuilds on every run: unlocked, so a rebuild doesn't warn
|
|
37
|
+
fw.data_save(clean, "inputs.intermediate.survey_clean", locked=False) # Parquet, in the catalog
|
|
35
38
|
```
|
|
36
39
|
|
|
37
40
|
`data_save()` writes Parquet or CSV, which R can read too. Use it instead of
|
|
@@ -18,10 +18,16 @@ whether something is safe, treat it as private.
|
|
|
18
18
|
2. Raw data with identifiers goes in a `private/` folder.
|
|
19
19
|
3. Only de-identified, aggregated data goes in a `public/` folder.
|
|
20
20
|
4. Review every output before saving it to a public folder.
|
|
21
|
-
5.
|
|
21
|
+
5. Save sensitive data into a private folder:
|
|
22
|
+
`fw.data_save(df, "inputs.private.intermediate.cleaned")`, or a path under
|
|
23
|
+
`inputs/private/` or `outputs/private/`.
|
|
24
|
+
6. Run `fw.git_security_audit()` before commits to scan for data leaks, and
|
|
25
|
+
keep the `data_security` git hook on (`fw.git_hooks_list()`,
|
|
26
|
+
`fw.git_hooks_enable("data_security")`).
|
|
27
|
+
7. Never publish anything from a private folder. Never pass
|
|
22
28
|
`include_private=True` to a publish function or answer its prompt on the
|
|
23
29
|
user's behalf.
|
|
24
|
-
|
|
30
|
+
8. Do not read or print restricted files. Values you print are sent to the
|
|
25
31
|
model provider. Work from the data dictionary and simulated data instead.
|
|
26
32
|
|
|
27
33
|
## Data flow
|
|
@@ -34,6 +40,21 @@ Intermediate -> inputs/private/intermediate/
|
|
|
34
40
|
Public-safe data -> inputs/public/final/
|
|
35
41
|
```
|
|
36
42
|
|
|
43
|
+
## Learning a file's layout
|
|
44
|
+
|
|
45
|
+
To learn what a private or restricted file holds, use
|
|
46
|
+
`fw.data_info(name, columns=True)` instead of reading the file, printing it, or
|
|
47
|
+
calling `.head()`, `.info()`, or `.describe()` on it:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
info = fw.data_info("inputs.private.raw.patients", columns=True)
|
|
51
|
+
info.columns # name, type, and count of missing values for each column
|
|
52
|
+
info.rows # number of rows
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
It never shows values, category levels, ranges, or examples, and it records
|
|
56
|
+
nothing in framework.db.
|
|
57
|
+
|
|
37
58
|
## Writing code
|
|
38
59
|
|
|
39
60
|
- Do not print rows with identifiers in notebook output that will be rendered.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: framework-py
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev11
|
|
4
4
|
Summary: Structured data science projects: a data catalog, integrity tracking, caching, outputs, and AI guardrails
|
|
5
5
|
Project-URL: Homepage, https://framework.pub
|
|
6
6
|
Project-URL: Source, https://github.com/frameworktools/framework-py
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
framework/__init__.py,sha256=
|
|
1
|
+
framework/__init__.py,sha256=P87pGZVH2C171Zuxm1JykpqerlskzhYRzoR3zu_cZcQ,6264
|
|
2
2
|
framework/__main__.py,sha256=CnSGHPB54v3Uqed9020bgseg_2AZzb1lnJFl8nlX8CM,6044
|
|
3
3
|
framework/_agents_md.py,sha256=jSFZZd7QUEj9rP4Dlc9w_optMReyaXw5rikilRX4a48,9804
|
|
4
4
|
framework/_artifacts.py,sha256=cOk2XLqctoqLaQSkksmc7cP4W0_AgqSxYNCTJxyZyik,36068
|
|
@@ -10,7 +10,7 @@ framework/_keychain.py,sha256=9QW8dFDhgy0knWCCu9blttIe_nCG0UhdY77wrVa1h6M,2798
|
|
|
10
10
|
framework/_log.py,sha256=ZgLaWbjiXK7Cybd_mWGURb4OOGaAAYsB6NkR15W3nnk,1160
|
|
11
11
|
framework/_pages.py,sha256=bIUR-eVhrwCF-Jdvs8cL_IpN0FLN2RLAy8AdKctdOF8,12503
|
|
12
12
|
framework/_paths.py,sha256=mjuSD1kz-SwmlaISjas_1XJSo9CGqQ9xe4AkVObzzS8,3479
|
|
13
|
-
framework/_private.py,sha256=
|
|
13
|
+
framework/_private.py,sha256=zlxpjUbOOOlatmePs6TSw3iRQZkQ1xF5ObfeO_NJPgc,9486
|
|
14
14
|
framework/_secretservice.py,sha256=zv5UvEekQic466qRmVpLG_hfEkisikHfab8e6kyzS2k,2450
|
|
15
15
|
framework/_sql.py,sha256=RlehpBg2Oq1W7jyZEoXEtlAs3ovIYbj2pz85TVdsSQc,3954
|
|
16
16
|
framework/_tabular.py,sha256=zaUB83lMCCJql24BKv6CYD8d1s-jjViS0H4lTxeBzzQ,15131
|
|
@@ -26,7 +26,7 @@ framework/cloud.py,sha256=0JjZB3lem8k3nNh_RkNZdv0KhNboyY6ZaP1eUFgiY_o,49551
|
|
|
26
26
|
framework/config_home.py,sha256=iSb0VuENgNOSnsZ_v53xFqjRiGgrB7OzZbHbyDOqKzs,8265
|
|
27
27
|
framework/connections.py,sha256=SHOIIjCv81FSEY2XbjsQkQKQ_vmD9k4ZG7FiM9Ala9E,30986
|
|
28
28
|
framework/console.py,sha256=zQ0LuFDcxe1W1kuc5E1bJ03h8d3cvwFoqDT8dAJQyN0,1267
|
|
29
|
-
framework/create.py,sha256=
|
|
29
|
+
framework/create.py,sha256=sAsLcdxhN3mZdcoO_c17PZNfQZfGuO2SKXvhQeNIjns,45107
|
|
30
30
|
framework/data.py,sha256=qfijeRGMZ7vIspkGZmS_X6-VR0eFWMuoxyJThBrKxOA,30283
|
|
31
31
|
framework/db.py,sha256=Wruez2V352xA3gjk5RcUi_0zncFsDwTs9Gwa2hXBY3Y,8099
|
|
32
32
|
framework/display.py,sha256=0FuKUt67uf5h1WjD4bwzoruc2XAN4y_j3mz_f5FskhE,5334
|
|
@@ -37,9 +37,9 @@ framework/global_config.py,sha256=fYLaxN_6Wc2xrIASn77dWkvGR3uuX-111bvfFPB82A4,11
|
|
|
37
37
|
framework/hooks.py,sha256=BcM9De5i5XINy4Nu68z3TeH6ogFujpgUoY5y1SCYnb8,21073
|
|
38
38
|
framework/integrity.py,sha256=2hXk95tlNGs6HVTFA0AqcPWQg2AiO6Hy0APMIXHpCTU,586
|
|
39
39
|
framework/notebooks.py,sha256=nBPDgZOSPZzTHaYvvXgyC_P2KXo7Zv471h47cvYOirA,21008
|
|
40
|
-
framework/outputs.py,sha256=
|
|
40
|
+
framework/outputs.py,sha256=8CcKKedgR8rrgIgQP96l5x-geEGOoCnGIW3Ywq19oYc,27200
|
|
41
41
|
framework/packages.py,sha256=_ZE_eXDbonl7sNW_mT8MZXbpAhnGYOmBEyAbyQ6qQKo,16100
|
|
42
|
-
framework/project.py,sha256=
|
|
42
|
+
framework/project.py,sha256=EAdc24UxrCHq-sofltFNFqnlZw3KoySMSEUX2W0GeFA,3761
|
|
43
43
|
framework/publish_bundle.py,sha256=inCdo5hfFRscT2oK1GZe-5Czfi7b1_mOW4hzjEl4Q50,28212
|
|
44
44
|
framework/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
45
|
framework/quarto.py,sha256=QpEV7rID4_4j8mbhcrkrprrZL15eOYI_PwL-jvE6dY4,9977
|
|
@@ -104,14 +104,14 @@ framework/templates/gitignore/course,sha256=VbNFPxggk8XlXEOVedO9no6B9W6Ixm_ASWe0
|
|
|
104
104
|
framework/templates/gitignore/presentation,sha256=4HOErO4zm2HEX2q_JS_vH-0lFMxCWAv1H6PKqyKBIQg,2903
|
|
105
105
|
framework/templates/gitignore/project,sha256=kHfqjTvWZ51AsApXipBKSCdOIpaYsE0mG8t5-tK1y-A,2782
|
|
106
106
|
framework/templates/gitignore/sensitive,sha256=8mKH9WUvn3TRc6QtvboLFvcbfQOGGebRQNMKZzGzzy0,3710
|
|
107
|
-
framework/templates/skills/framework-data/.framework-skill.json,sha256=
|
|
108
|
-
framework/templates/skills/framework-data/SKILL.md,sha256=
|
|
107
|
+
framework/templates/skills/framework-data/.framework-skill.json,sha256=zvqsxljDqxJZsC7Yp5_ujk-oVBiCud1zhJfAaNI4PZY,139
|
|
108
|
+
framework/templates/skills/framework-data/SKILL.md,sha256=IjqI215VsNfvnYWmjd3V1FFbdSIhfwjQ_1Lqkbw-mdw,2075
|
|
109
109
|
framework/templates/skills/framework-outputs/.framework-skill.json,sha256=RZN5cYD13n9dEt_sJVO3rXJOL1zG3UXeyvlyoFtIzdU,142
|
|
110
110
|
framework/templates/skills/framework-outputs/SKILL.md,sha256=fBeT97JfqUooZebo0xF0fDLPfhaErHVKV5xt1w7-pTc,2561
|
|
111
111
|
framework/templates/skills/framework-packages/.framework-skill.json,sha256=JhqCI0ZM_F53ZsxEFRkjErDaqc8pCi1KiSrugH6KXJw,143
|
|
112
112
|
framework/templates/skills/framework-packages/SKILL.md,sha256=GAtfLA3VjPB9lrQVAeYEOHU9XFyiKv9VS7CyVywRK-M,1278
|
|
113
|
-
framework/templates/skills/framework-sensitive-data/.framework-skill.json,sha256=
|
|
114
|
-
framework/templates/skills/framework-sensitive-data/SKILL.md,sha256=
|
|
113
|
+
framework/templates/skills/framework-sensitive-data/.framework-skill.json,sha256=wq-N0XXaFFju0Fqdb49QPfiShBThJKEH52ie4o1V5ks,149
|
|
114
|
+
framework/templates/skills/framework-sensitive-data/SKILL.md,sha256=6if0juK9GzSu2TP4pFyieNbvKE1ew4Xofhg5EfS693o,2542
|
|
115
115
|
framework/templates/skills/framework-workflow/.framework-skill.json,sha256=t5VdSo3dTcBjM4y53gv25U8E0gaqXLAd1DKdooGpb-g,143
|
|
116
116
|
framework/templates/skills/framework-workflow/SKILL.md,sha256=vEyO-vWSVuHlwWN0N8sdmQNnFzayWV2iIUDs2KUb4as,2279
|
|
117
117
|
framework/templates/stubs/notebook-default.ipynb,sha256=2p3Zj6bQEHlUL1eEVAbPfTTxqGBs84C67tA3MkCzVQs,685
|
|
@@ -119,7 +119,7 @@ framework/templates/stubs/notebook-default.qmd,sha256=8Js1S2BcHYeQWmJS-kt31gBvIj
|
|
|
119
119
|
framework/templates/stubs/notebook-minimal.qmd,sha256=2U2k8judffhrh_6m6r6OAbQBCYEtViAjeKRBqBYCJTM,178
|
|
120
120
|
framework/templates/stubs/notebook-revealjs.qmd,sha256=_ztT_gHoudpB5DIjlbvtB5zQ8163DeV8xbWcT-HgJrI,409
|
|
121
121
|
framework/templates/stubs/script-default.py,sha256=vbWqgW0_rHot17mQC3tYb92g_9L-cbTOeL3y99BRrSk,216
|
|
122
|
-
framework_py-0.1.0.
|
|
123
|
-
framework_py-0.1.0.
|
|
124
|
-
framework_py-0.1.0.
|
|
125
|
-
framework_py-0.1.0.
|
|
122
|
+
framework_py-0.1.0.dev11.dist-info/METADATA,sha256=Wl8vcd_6Ek9cfu0RQeY68s66Qy1Y8D4U9hnc4Zn_psg,4281
|
|
123
|
+
framework_py-0.1.0.dev11.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
124
|
+
framework_py-0.1.0.dev11.dist-info/licenses/LICENSE,sha256=giOOgSwALkZimC7uhLZQK8Untez641bLW1-2-Cjvmq0,1072
|
|
125
|
+
framework_py-0.1.0.dev11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|