framework-py 0.1.0.dev20__py3-none-any.whl → 0.1.0.dev22__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/_agents_md.py +43 -36
- framework/_assets/schema/layer.v1.json +26 -1
- framework/_assets/schema/layers.v1.json +26 -1
- framework/_assets/schema/spec.v1.json +26 -1
- framework/_assets/sets/packages/stata-data-tools.json +30 -0
- framework/_assets/sets/packages/stata-fixed-effects.json +38 -0
- framework/_assets/sets/packages/stata-graphs.json +38 -0
- framework/_assets/sets/packages/stata-tables.json +22 -0
- framework/_assets/sets/skills/framework-extras.json +23 -0
- framework/_assets/sets/skills/ggplot2.json +1 -4
- framework/create.py +14 -1
- framework/features.py +4 -1
- framework/scaffold.py +33 -0
- framework/templates/defaults.yml +1 -1
- framework/templates/skill-history.json +15 -1
- framework/templates/skills/framework-cache/.framework-skill.json +5 -0
- framework/templates/skills/framework-cache/SKILL.md +21 -0
- framework/templates/skills/framework-data/.framework-skill.json +2 -2
- framework/templates/skills/framework-data/SKILL.md +22 -26
- framework/templates/skills/framework-databases/.framework-skill.json +5 -0
- framework/templates/skills/framework-databases/SKILL.md +24 -0
- framework/templates/skills/framework-outputs/.framework-skill.json +2 -2
- framework/templates/skills/framework-outputs/SKILL.md +13 -58
- framework/templates/skills/framework-packages/.framework-skill.json +2 -2
- framework/templates/skills/framework-packages/SKILL.md +14 -16
- framework/templates/skills/framework-publishing/.framework-skill.json +5 -0
- framework/templates/skills/framework-publishing/SKILL.md +22 -0
- framework/templates/skills/framework-sensitive-data/.framework-skill.json +2 -2
- framework/templates/skills/framework-sensitive-data/SKILL.md +29 -52
- framework/templates/skills/framework-workflow/.framework-skill.json +2 -2
- framework/templates/skills/framework-workflow/SKILL.md +22 -37
- {framework_py-0.1.0.dev20.dist-info → framework_py-0.1.0.dev22.dist-info}/METADATA +1 -1
- {framework_py-0.1.0.dev20.dist-info → framework_py-0.1.0.dev22.dist-info}/RECORD +35 -24
- {framework_py-0.1.0.dev20.dist-info → framework_py-0.1.0.dev22.dist-info}/WHEEL +0 -0
- {framework_py-0.1.0.dev20.dist-info → framework_py-0.1.0.dev22.dist-info}/licenses/LICENSE +0 -0
framework/_agents_md.py
CHANGED
|
@@ -15,11 +15,14 @@ REGENERATE = "<!-- @framework:regenerate -->"
|
|
|
15
15
|
PACKAGES_HEADING = "Installed Packages"
|
|
16
16
|
|
|
17
17
|
SKILL_DESCRIPTIONS = {
|
|
18
|
-
"framework-workflow": "
|
|
19
|
-
"framework-data": "reading and saving data (
|
|
20
|
-
"framework-packages": "adding and managing Python packages (
|
|
21
|
-
"framework-outputs": "results
|
|
22
|
-
"framework-
|
|
18
|
+
"framework-workflow": "Framework package initialization and notebook or script creation",
|
|
19
|
+
"framework-data": "reading and saving data with data_read() and data_save()",
|
|
20
|
+
"framework-packages": "adding and managing Python packages with package_add()",
|
|
21
|
+
"framework-outputs": "saving results with the Framework package",
|
|
22
|
+
"framework-cache": "caching computations with the Framework package",
|
|
23
|
+
"framework-databases": "querying configured Framework databases",
|
|
24
|
+
"framework-publishing": "publishing artifacts with the Framework package",
|
|
25
|
+
"framework-sensitive-data": "private and public folders in a privacy-sensitive project",
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
_PURPOSES = {
|
|
@@ -30,7 +33,7 @@ _PURPOSES = {
|
|
|
30
33
|
"outputs_figures": "Output figures",
|
|
31
34
|
"outputs_models": "Saved models",
|
|
32
35
|
"outputs_reports": "Reports",
|
|
33
|
-
"inputs_private_raw": "Private raw data
|
|
36
|
+
"inputs_private_raw": "Private raw data",
|
|
34
37
|
"inputs_public_raw": "Public raw data",
|
|
35
38
|
"inputs_private_intermediate": "Private intermediate",
|
|
36
39
|
"inputs_public_intermediate": "Public intermediate",
|
|
@@ -104,42 +107,46 @@ def _environment(spec: dict[str, Any]) -> str:
|
|
|
104
107
|
scaffold = spec.get("scaffold") or {}
|
|
105
108
|
functions = (spec.get("directories") or {}).get("functions") or "functions"
|
|
106
109
|
steps = [
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
f"
|
|
111
|
-
"
|
|
110
|
+
"Finds the project root and loads `.env` and the settings. The working directory "
|
|
111
|
+
"stays as it is.",
|
|
112
|
+
"Creates framework.db if needed and records the scaffold time",
|
|
113
|
+
f"Puts `{functions}/` on the import path, so its modules import directly",
|
|
114
|
+
"Runs `scaffold.py` from the project root, if there is one",
|
|
112
115
|
]
|
|
113
|
-
|
|
114
|
-
"
|
|
115
|
-
|
|
116
|
-
"",
|
|
117
|
-
f"**DO NOT** copy helpers between notebooks. Put them in `{functions}/` and import them.",
|
|
116
|
+
conventions = [
|
|
117
|
+
'- Prefer `fw.package_add("name")` to `pip install`. It records the package in '
|
|
118
|
+
"pyproject.toml.",
|
|
119
|
+
f"- Put helpers shared between notebooks in `{functions}/` and import them.",
|
|
118
120
|
]
|
|
119
121
|
seed = scaffold.get("seed")
|
|
120
122
|
if scaffold.get("seed_on_scaffold"):
|
|
121
|
-
steps.append(f"
|
|
122
|
-
|
|
123
|
-
""
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
steps.append(f"Sets the random seed to {seed}")
|
|
124
|
+
conventions.append(
|
|
125
|
+
"- Prefer the project's seed. When an operation needs its own seed, say why in a "
|
|
126
|
+
"comment."
|
|
127
|
+
)
|
|
128
|
+
conventions += [
|
|
129
|
+
"- Ask before running a database statement that changes data.",
|
|
130
|
+
"- Ask before publishing anything public. GitHub Pages is public even from a private "
|
|
131
|
+
"repository.",
|
|
132
|
+
]
|
|
127
133
|
return "\n".join(
|
|
128
134
|
[
|
|
129
135
|
f"## Framework Environment {REGENERATE}",
|
|
130
136
|
"",
|
|
131
|
-
"This project uses Framework
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
"
|
|
137
|
+
"This project uses the Framework Python package. Follow its conventions in code that",
|
|
138
|
+
"calls `fw.scaffold()`. Leave existing code as it is unless the user asks you to",
|
|
139
|
+
"change it.",
|
|
140
|
+
"",
|
|
141
|
+
"### scaffold()",
|
|
135
142
|
"",
|
|
136
|
-
"
|
|
143
|
+
"Start each notebook and script with `import framework as fw` and `fw.scaffold()`. It:",
|
|
137
144
|
"",
|
|
138
|
-
*steps,
|
|
145
|
+
*(f"{i}. {step}" for i, step in enumerate(steps, 1)),
|
|
139
146
|
"",
|
|
140
|
-
"###
|
|
147
|
+
"### Conventions",
|
|
141
148
|
"",
|
|
142
|
-
*
|
|
149
|
+
*conventions,
|
|
143
150
|
]
|
|
144
151
|
)
|
|
145
152
|
|
|
@@ -232,8 +239,8 @@ def _data(spec: dict[str, Any]) -> str:
|
|
|
232
239
|
[
|
|
233
240
|
f"## Data Management {REGENERATE}",
|
|
234
241
|
"",
|
|
235
|
-
"
|
|
236
|
-
"
|
|
242
|
+
"Prefer `fw.data_read()` and `fw.data_save()` for project data. They record a hash",
|
|
243
|
+
"of each file. This project's data directories:",
|
|
237
244
|
"",
|
|
238
245
|
*table,
|
|
239
246
|
]
|
|
@@ -246,10 +253,10 @@ def _type_section(spec: dict[str, Any]) -> str:
|
|
|
246
253
|
|
|
247
254
|
if spec_sensitive(spec):
|
|
248
255
|
return (
|
|
249
|
-
"##
|
|
250
|
-
"
|
|
251
|
-
"
|
|
252
|
-
"
|
|
256
|
+
"## Private Folders\n\n"
|
|
257
|
+
"This project was created as privacy sensitive. Private files go in the\n"
|
|
258
|
+
"`private/` folders, which Git ignores. The `framework-sensitive-data` skill\n"
|
|
259
|
+
"describes the folders and the checks Framework runs."
|
|
253
260
|
)
|
|
254
261
|
if spec.get("type") == "course":
|
|
255
262
|
return (
|
|
@@ -154,6 +154,10 @@
|
|
|
154
154
|
"use_renv": {
|
|
155
155
|
"type": "boolean"
|
|
156
156
|
},
|
|
157
|
+
"project_ado": {
|
|
158
|
+
"type": "boolean",
|
|
159
|
+
"description": "Stata: install packages into ado/plus in the project folder."
|
|
160
|
+
},
|
|
157
161
|
"default_packages": {
|
|
158
162
|
"type": "object",
|
|
159
163
|
"additionalProperties": {
|
|
@@ -254,6 +258,14 @@
|
|
|
254
258
|
"ggplot_theme": {
|
|
255
259
|
"type": "string"
|
|
256
260
|
},
|
|
261
|
+
"matplotlib_style": {
|
|
262
|
+
"type": "string",
|
|
263
|
+
"description": "Python: the matplotlib style scaffold() applies when set_theme_on_scaffold is on, such as seaborn-v0_8-whitegrid."
|
|
264
|
+
},
|
|
265
|
+
"stata_scheme": {
|
|
266
|
+
"type": "string",
|
|
267
|
+
"description": "Stata: the graph scheme fw_scaffold sets when set_theme_on_scaffold is on, such as s2color."
|
|
268
|
+
},
|
|
257
269
|
"source_all_functions": {
|
|
258
270
|
"type": "boolean"
|
|
259
271
|
},
|
|
@@ -564,7 +576,9 @@
|
|
|
564
576
|
"cran",
|
|
565
577
|
"github",
|
|
566
578
|
"bioc",
|
|
567
|
-
"pypi"
|
|
579
|
+
"pypi",
|
|
580
|
+
"ssc",
|
|
581
|
+
"net"
|
|
568
582
|
]
|
|
569
583
|
},
|
|
570
584
|
"version": {
|
|
@@ -597,6 +611,17 @@
|
|
|
597
611
|
}
|
|
598
612
|
]
|
|
599
613
|
},
|
|
614
|
+
"url": {
|
|
615
|
+
"anyOf": [
|
|
616
|
+
{
|
|
617
|
+
"type": "string"
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
"type": "null"
|
|
621
|
+
}
|
|
622
|
+
],
|
|
623
|
+
"description": "Stata net packages: the folder or web address that holds the .pkg file."
|
|
624
|
+
},
|
|
600
625
|
"auto_attach": {
|
|
601
626
|
"type": "boolean"
|
|
602
627
|
}
|
|
@@ -199,7 +199,9 @@
|
|
|
199
199
|
"cran",
|
|
200
200
|
"github",
|
|
201
201
|
"bioc",
|
|
202
|
-
"pypi"
|
|
202
|
+
"pypi",
|
|
203
|
+
"ssc",
|
|
204
|
+
"net"
|
|
203
205
|
]
|
|
204
206
|
},
|
|
205
207
|
"version": {
|
|
@@ -232,6 +234,17 @@
|
|
|
232
234
|
}
|
|
233
235
|
]
|
|
234
236
|
},
|
|
237
|
+
"url": {
|
|
238
|
+
"anyOf": [
|
|
239
|
+
{
|
|
240
|
+
"type": "string"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"type": "null"
|
|
244
|
+
}
|
|
245
|
+
],
|
|
246
|
+
"description": "Stata net packages: the folder or web address that holds the .pkg file."
|
|
247
|
+
},
|
|
235
248
|
"auto_attach": {
|
|
236
249
|
"type": "boolean"
|
|
237
250
|
}
|
|
@@ -602,6 +615,10 @@
|
|
|
602
615
|
"use_renv": {
|
|
603
616
|
"type": "boolean"
|
|
604
617
|
},
|
|
618
|
+
"project_ado": {
|
|
619
|
+
"type": "boolean",
|
|
620
|
+
"description": "Stata: install packages into ado/plus in the project folder."
|
|
621
|
+
},
|
|
605
622
|
"default_packages": {
|
|
606
623
|
"type": "object",
|
|
607
624
|
"additionalProperties": {
|
|
@@ -702,6 +719,14 @@
|
|
|
702
719
|
"ggplot_theme": {
|
|
703
720
|
"type": "string"
|
|
704
721
|
},
|
|
722
|
+
"matplotlib_style": {
|
|
723
|
+
"type": "string",
|
|
724
|
+
"description": "Python: the matplotlib style scaffold() applies when set_theme_on_scaffold is on, such as seaborn-v0_8-whitegrid."
|
|
725
|
+
},
|
|
726
|
+
"stata_scheme": {
|
|
727
|
+
"type": "string",
|
|
728
|
+
"description": "Stata: the graph scheme fw_scaffold sets when set_theme_on_scaffold is on, such as s2color."
|
|
729
|
+
},
|
|
705
730
|
"source_all_functions": {
|
|
706
731
|
"type": "boolean"
|
|
707
732
|
},
|
|
@@ -134,6 +134,10 @@
|
|
|
134
134
|
"use_renv": {
|
|
135
135
|
"type": "boolean"
|
|
136
136
|
},
|
|
137
|
+
"project_ado": {
|
|
138
|
+
"type": "boolean",
|
|
139
|
+
"description": "Stata: install packages into ado/plus in the project folder."
|
|
140
|
+
},
|
|
137
141
|
"default_packages": {
|
|
138
142
|
"type": "object",
|
|
139
143
|
"additionalProperties": {
|
|
@@ -226,6 +230,14 @@
|
|
|
226
230
|
"ggplot_theme": {
|
|
227
231
|
"type": "string"
|
|
228
232
|
},
|
|
233
|
+
"matplotlib_style": {
|
|
234
|
+
"type": "string",
|
|
235
|
+
"description": "Python: the matplotlib style scaffold() applies when set_theme_on_scaffold is on, such as seaborn-v0_8-whitegrid."
|
|
236
|
+
},
|
|
237
|
+
"stata_scheme": {
|
|
238
|
+
"type": "string",
|
|
239
|
+
"description": "Stata: the graph scheme fw_scaffold sets when set_theme_on_scaffold is on, such as s2color."
|
|
240
|
+
},
|
|
229
241
|
"source_all_functions": {
|
|
230
242
|
"type": "boolean"
|
|
231
243
|
},
|
|
@@ -545,7 +557,9 @@
|
|
|
545
557
|
"cran",
|
|
546
558
|
"github",
|
|
547
559
|
"bioc",
|
|
548
|
-
"pypi"
|
|
560
|
+
"pypi",
|
|
561
|
+
"ssc",
|
|
562
|
+
"net"
|
|
549
563
|
]
|
|
550
564
|
},
|
|
551
565
|
"version": {
|
|
@@ -578,6 +592,17 @@
|
|
|
578
592
|
}
|
|
579
593
|
]
|
|
580
594
|
},
|
|
595
|
+
"url": {
|
|
596
|
+
"anyOf": [
|
|
597
|
+
{
|
|
598
|
+
"type": "string"
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
"type": "null"
|
|
602
|
+
}
|
|
603
|
+
],
|
|
604
|
+
"description": "Stata net packages: the folder or web address that holds the .pkg file."
|
|
605
|
+
},
|
|
581
606
|
"auto_attach": {
|
|
582
607
|
"type": "boolean"
|
|
583
608
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "stata-data-tools",
|
|
3
|
+
"name": "Stata data tools",
|
|
4
|
+
"description": "gtools for fast collapse, egen, and reshape on large data, and missings, distinct, and labutil to check and label data.",
|
|
5
|
+
"language": [
|
|
6
|
+
"stata"
|
|
7
|
+
],
|
|
8
|
+
"layer": {
|
|
9
|
+
"packages": {
|
|
10
|
+
"default_packages": {
|
|
11
|
+
"gtools": {
|
|
12
|
+
"source": "ssc",
|
|
13
|
+
"auto_attach": false
|
|
14
|
+
},
|
|
15
|
+
"missings": {
|
|
16
|
+
"source": "ssc",
|
|
17
|
+
"auto_attach": false
|
|
18
|
+
},
|
|
19
|
+
"distinct": {
|
|
20
|
+
"source": "ssc",
|
|
21
|
+
"auto_attach": false
|
|
22
|
+
},
|
|
23
|
+
"labutil": {
|
|
24
|
+
"source": "ssc",
|
|
25
|
+
"auto_attach": false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "stata-fixed-effects",
|
|
3
|
+
"name": "Stata fixed effects",
|
|
4
|
+
"description": "reghdfe and ftools for regressions with many fixed effects, ppmlhdfe for Poisson models, and ivreghdfe with ivreg2 and ranktest for instrumental variables.",
|
|
5
|
+
"language": [
|
|
6
|
+
"stata"
|
|
7
|
+
],
|
|
8
|
+
"layer": {
|
|
9
|
+
"packages": {
|
|
10
|
+
"default_packages": {
|
|
11
|
+
"reghdfe": {
|
|
12
|
+
"source": "ssc",
|
|
13
|
+
"auto_attach": false
|
|
14
|
+
},
|
|
15
|
+
"ftools": {
|
|
16
|
+
"source": "ssc",
|
|
17
|
+
"auto_attach": false
|
|
18
|
+
},
|
|
19
|
+
"ppmlhdfe": {
|
|
20
|
+
"source": "ssc",
|
|
21
|
+
"auto_attach": false
|
|
22
|
+
},
|
|
23
|
+
"ivreghdfe": {
|
|
24
|
+
"source": "ssc",
|
|
25
|
+
"auto_attach": false
|
|
26
|
+
},
|
|
27
|
+
"ivreg2": {
|
|
28
|
+
"source": "ssc",
|
|
29
|
+
"auto_attach": false
|
|
30
|
+
},
|
|
31
|
+
"ranktest": {
|
|
32
|
+
"source": "ssc",
|
|
33
|
+
"auto_attach": false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "stata-graphs",
|
|
3
|
+
"name": "Stata graphs",
|
|
4
|
+
"description": "coefplot for coefficient plots, binscatter for binned scatterplots, and grstyle, palettes, colrspace, and schemepack for graph styles and colors.",
|
|
5
|
+
"language": [
|
|
6
|
+
"stata"
|
|
7
|
+
],
|
|
8
|
+
"layer": {
|
|
9
|
+
"packages": {
|
|
10
|
+
"default_packages": {
|
|
11
|
+
"coefplot": {
|
|
12
|
+
"source": "ssc",
|
|
13
|
+
"auto_attach": false
|
|
14
|
+
},
|
|
15
|
+
"binscatter": {
|
|
16
|
+
"source": "ssc",
|
|
17
|
+
"auto_attach": false
|
|
18
|
+
},
|
|
19
|
+
"grstyle": {
|
|
20
|
+
"source": "ssc",
|
|
21
|
+
"auto_attach": false
|
|
22
|
+
},
|
|
23
|
+
"palettes": {
|
|
24
|
+
"source": "ssc",
|
|
25
|
+
"auto_attach": false
|
|
26
|
+
},
|
|
27
|
+
"colrspace": {
|
|
28
|
+
"source": "ssc",
|
|
29
|
+
"auto_attach": false
|
|
30
|
+
},
|
|
31
|
+
"schemepack": {
|
|
32
|
+
"source": "ssc",
|
|
33
|
+
"auto_attach": false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "stata-tables",
|
|
3
|
+
"name": "Stata regression tables",
|
|
4
|
+
"description": "estout for esttab and estpost tables, and outreg2 for Word and Excel tables of estimates.",
|
|
5
|
+
"language": [
|
|
6
|
+
"stata"
|
|
7
|
+
],
|
|
8
|
+
"layer": {
|
|
9
|
+
"packages": {
|
|
10
|
+
"default_packages": {
|
|
11
|
+
"estout": {
|
|
12
|
+
"source": "ssc",
|
|
13
|
+
"auto_attach": false
|
|
14
|
+
},
|
|
15
|
+
"outreg2": {
|
|
16
|
+
"source": "ssc",
|
|
17
|
+
"auto_attach": false
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "framework-extras",
|
|
3
|
+
"name": "Framework extras",
|
|
4
|
+
"description": "Caching, database queries, and artifact publication with Framework packages.",
|
|
5
|
+
"category": "framework",
|
|
6
|
+
"language": [
|
|
7
|
+
"r",
|
|
8
|
+
"python"
|
|
9
|
+
],
|
|
10
|
+
"layer": {
|
|
11
|
+
"skills": {
|
|
12
|
+
"framework-cache": {
|
|
13
|
+
"package": true
|
|
14
|
+
},
|
|
15
|
+
"framework-databases": {
|
|
16
|
+
"package": true
|
|
17
|
+
},
|
|
18
|
+
"framework-publishing": {
|
|
19
|
+
"package": true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
framework/create.py
CHANGED
|
@@ -138,6 +138,12 @@ def _sections(spec: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
138
138
|
"seed_on_scaffold": scaffold.get("seed_on_scaffold", False),
|
|
139
139
|
"seed": scaffold.get("seed", ""),
|
|
140
140
|
"source_all_functions": scaffold.get("source_all_functions", True),
|
|
141
|
+
# The plot style scaffold() applies, as R's ggplot2 theme
|
|
142
|
+
**{
|
|
143
|
+
k: scaffold[k]
|
|
144
|
+
for k in ("set_theme_on_scaffold", "matplotlib_style")
|
|
145
|
+
if scaffold.get(k) is not None
|
|
146
|
+
},
|
|
141
147
|
**({"workflow": scaffold["workflow"]} if scaffold.get("workflow") else {}),
|
|
142
148
|
"notebook_format": scaffold.get("notebook_format")
|
|
143
149
|
or ("quarto" if spec_tool_on(spec, "quarto") else "jupyter"),
|
|
@@ -593,7 +599,14 @@ def _defaults_layer(settings: Mapping[str, Any], type: str) -> dict[str, Any]:
|
|
|
593
599
|
layer["author"] = author_normalize(settings["author"])
|
|
594
600
|
scaffold = defaults.get("scaffold")
|
|
595
601
|
if isinstance(scaffold, dict):
|
|
596
|
-
keys = (
|
|
602
|
+
keys = (
|
|
603
|
+
"seed_on_scaffold",
|
|
604
|
+
"seed",
|
|
605
|
+
"set_theme_on_scaffold",
|
|
606
|
+
"matplotlib_style",
|
|
607
|
+
"source_all_functions",
|
|
608
|
+
"ide",
|
|
609
|
+
)
|
|
597
610
|
layer["scaffold"] = {k: scaffold[k] for k in keys if k in scaffold}
|
|
598
611
|
if "seed" in layer["scaffold"]:
|
|
599
612
|
layer["scaffold"]["seed"] = str(layer["scaffold"]["seed"])
|
framework/features.py
CHANGED
|
@@ -147,7 +147,10 @@ def _pick(ids: Iterable[str], kind: str, label: str) -> list[dict[str, Any]]:
|
|
|
147
147
|
definition = sets.get(set_id)
|
|
148
148
|
if definition is None:
|
|
149
149
|
available = ", ".join(i for i, d in sets.items() if _for_python(d))
|
|
150
|
-
raise FrameworkError(
|
|
150
|
+
raise FrameworkError(
|
|
151
|
+
f"Unknown {label}: {set_id}. Available offline: {available}. "
|
|
152
|
+
"Other sets require Framework Cloud; sign in and resolve the project online."
|
|
153
|
+
)
|
|
151
154
|
if not _for_python(definition):
|
|
152
155
|
raise FrameworkError(f"The {definition['name']} {label} isn't available for Python.")
|
|
153
156
|
prefix = "packages-" if kind == "packages" else "skills-"
|
framework/scaffold.py
CHANGED
|
@@ -120,6 +120,37 @@ def _set_seed(config: dict[str, Any]) -> int | None:
|
|
|
120
120
|
return value
|
|
121
121
|
|
|
122
122
|
|
|
123
|
+
def _set_theme(config: dict[str, Any]) -> str | None:
|
|
124
|
+
"""Apply the matplotlib style when ``set_theme_on_scaffold`` is on, as R sets
|
|
125
|
+
its ggplot2 theme: ``matplotlib_style`` from ``scaffold:``, then ``options:``,
|
|
126
|
+
then the top level. A missing style or matplotlib warns and changes nothing.
|
|
127
|
+
"""
|
|
128
|
+
if _first(config, "set_theme_on_scaffold") is not True:
|
|
129
|
+
return None
|
|
130
|
+
style = str(_first(config, "matplotlib_style") or "").strip()
|
|
131
|
+
if not style:
|
|
132
|
+
return None
|
|
133
|
+
try:
|
|
134
|
+
import matplotlib.style
|
|
135
|
+
except ImportError:
|
|
136
|
+
warnings.warn(
|
|
137
|
+
"set_theme_on_scaffold is on, but matplotlib is not installed.",
|
|
138
|
+
FrameworkWarning,
|
|
139
|
+
stacklevel=3,
|
|
140
|
+
)
|
|
141
|
+
return None
|
|
142
|
+
if style != "default" and style not in matplotlib.style.available:
|
|
143
|
+
warnings.warn(
|
|
144
|
+
f"matplotlib style '{style}' not found, so scaffold() left the style alone.",
|
|
145
|
+
FrameworkWarning,
|
|
146
|
+
stacklevel=3,
|
|
147
|
+
)
|
|
148
|
+
return None
|
|
149
|
+
matplotlib.style.use(style)
|
|
150
|
+
inform(f"matplotlib style set to {style}.")
|
|
151
|
+
return style
|
|
152
|
+
|
|
153
|
+
|
|
123
154
|
def _top_level_modules(folder: Path) -> list[tuple[str, str]]:
|
|
124
155
|
"""The modules a folder provides, as (module name, entry name) pairs."""
|
|
125
156
|
found = []
|
|
@@ -196,6 +227,7 @@ def scaffold(settings_file: str | Path | None = None) -> Path:
|
|
|
196
227
|
- creates the settings' private folders that are missing (a fresh checkout has
|
|
197
228
|
none, since git ignores them),
|
|
198
229
|
- sets the random seed when ``seed_on_scaffold`` is on (or ``FW_SEED`` is set),
|
|
230
|
+
- applies ``matplotlib_style`` when ``set_theme_on_scaffold`` is on,
|
|
199
231
|
- puts the project's ``functions`` folder on the import path, and
|
|
200
232
|
- runs ``scaffold.py`` from the project root, if there is one.
|
|
201
233
|
|
|
@@ -232,6 +264,7 @@ def scaffold(settings_file: str | Path | None = None) -> Path:
|
|
|
232
264
|
# code that saves into them works
|
|
233
265
|
_create_private_folders(root, config)
|
|
234
266
|
_set_seed(config)
|
|
267
|
+
_set_theme(config)
|
|
235
268
|
_add_function_folders(config, root)
|
|
236
269
|
|
|
237
270
|
script = root / "scaffold.py"
|
framework/templates/defaults.yml
CHANGED
|
@@ -66,7 +66,7 @@ env:
|
|
|
66
66
|
S3_ENDPOINT: ""
|
|
67
67
|
S3_SESSION_TOKEN: ""
|
|
68
68
|
|
|
69
|
-
skills: [framework-workflow, framework-data, framework-packages, framework-outputs]
|
|
69
|
+
skills: [framework-workflow, framework-data, framework-packages, framework-outputs, framework-cache, framework-databases, framework-publishing]
|
|
70
70
|
sensitive_skills: [framework-sensitive-data]
|
|
71
71
|
|
|
72
72
|
types:
|
|
@@ -1,27 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "SHA-256 of every SKILL.md framework-py has shipped, per skill. Generated by scripts/skill_history.py.",
|
|
3
3
|
"skills": {
|
|
4
|
+
"framework-cache": [
|
|
5
|
+
"1cc1673c3e55a286abcc1a3d1d4f930a874aec080a7aceabcfa9014a382c52ab"
|
|
6
|
+
],
|
|
4
7
|
"framework-data": [
|
|
8
|
+
"0cdf0d8c885825802fee7688344ed2d607ad40df5dae99c4905b275d861a3f0b",
|
|
5
9
|
"223a88db5e55b0d7ef9d85a68dddd5d4515b7522217f08d0ff52ea91bc3e99dc",
|
|
6
10
|
"75d663831d581fbb5d30d12068b44f521bbeb42022df1cdc3c9acae9267bff28",
|
|
7
11
|
"8ddcbd6f43a011612fc928014c457012bea16921d8a91802451693f5777dceca"
|
|
8
12
|
],
|
|
13
|
+
"framework-databases": [
|
|
14
|
+
"b151906ffa9a8c886de99a9dbefd8c975b45cade5af8f7d1654dac9ba2596f38"
|
|
15
|
+
],
|
|
9
16
|
"framework-outputs": [
|
|
10
17
|
"4cfc6bf26afc5e67f771db00f20b1dd84eaa9c00eb683cfc4cc973d8968cc95c",
|
|
18
|
+
"596b1e56afc0051225d54bde8766b5de19d40f2c61ed6ea7988280ec81ed7cca",
|
|
11
19
|
"7c1793f7b25fa94a2865e6e8d311747c32cf7e1684ac754a579c6dd70efea537",
|
|
12
20
|
"e62a569bc1814e673448befd23d1d0f1ecda89ba64d73c2e1c96dda7d65ae537"
|
|
13
21
|
],
|
|
14
22
|
"framework-packages": [
|
|
15
23
|
"180b5f2c0dd58cf07d96b41501e60438753d5c5ca22aff554bb0b2572c112be3",
|
|
16
|
-
"85179875db4c4caf5dcea2e218ead2c5b13c600e8e1626bf13cb6a6e44a03712"
|
|
24
|
+
"85179875db4c4caf5dcea2e218ead2c5b13c600e8e1626bf13cb6a6e44a03712",
|
|
25
|
+
"a328f03828f3fb5ac2d85da217b3496fdda67f5aee393211c7b7b961565178ed"
|
|
26
|
+
],
|
|
27
|
+
"framework-publishing": [
|
|
28
|
+
"ced5c3b0c66f6f0877f916c1152484091366c01fcad5a08ece75a36b0790b305"
|
|
17
29
|
],
|
|
18
30
|
"framework-sensitive-data": [
|
|
19
31
|
"5322499fef5afe4276f5afec95f1477189c1a89cdef1ba43bfdbf2de54f4e9d0",
|
|
20
32
|
"a374d8e37b792e7eb009469c67baef3b056e4600e5db255481272cb9f9f01739",
|
|
33
|
+
"d4708404be9735aebf44255a6a5419f7bcf55a8647ad65efb45d25d82377e454",
|
|
21
34
|
"d5089de39e36095d2c72dcd46845c2b4dc6497997c24cb99b3a854c249864cf7",
|
|
22
35
|
"ea27f48ee2bd1b34aed933f8a45ca278d6ef284d5ec385e87e183911f4baf77a"
|
|
23
36
|
],
|
|
24
37
|
"framework-workflow": [
|
|
38
|
+
"85d69dc7f0cd538bf80b034f58cb3b790d1e469365d4507352644d17ebb76535",
|
|
25
39
|
"bc4c8efaf59256e1e5c1637437cb1d9903671736b2595da22140ecd8a51be1ab",
|
|
26
40
|
"f9421cf35cc9acefb415f2a5b7640ae597e1d18cea6ea37304fb240695deff54"
|
|
27
41
|
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: framework-cache
|
|
3
|
+
description: Use when caching expensive computations in a project that uses the Framework package. Covers cache_remember(), cache(), cache_get(), and cache_forget().
|
|
4
|
+
metadata:
|
|
5
|
+
title: "Framework: caching computations"
|
|
6
|
+
summary: Cache computed values with explicit names and expiry.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Framework: caching computations
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
# Computes once, then reuses the result until it expires
|
|
13
|
+
model = fw.cache_remember("fitted_model", lambda: fit(training), expire_after="7 days")
|
|
14
|
+
|
|
15
|
+
fw.cache("processed", frame) # write
|
|
16
|
+
frame = fw.cache_get("processed") # read (None if missing)
|
|
17
|
+
fw.cache_forget("processed") # remove
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Cache entries are recorded in `framework.db` with a hash and an expiry. Use
|
|
21
|
+
names that say what the value is.
|