calkit-python 0.50.7__py3-none-any.whl → 0.52.0__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.
Files changed (122) hide show
  1. calkit/__init__.py +0 -1
  2. calkit/agent_skills/add-pipeline-stage/SKILL.md +6 -0
  3. calkit/agent_skills/build-paper-pipeline/SKILL.md +40 -9
  4. calkit/agent_skills/check-questions/SKILL.md +8 -1
  5. calkit/agent_skills/check-reproducibility/SKILL.md +18 -18
  6. calkit/agent_skills/conventions/SKILL.md +31 -3
  7. calkit/agent_skills/create-pipeline/SKILL.md +15 -6
  8. calkit/browser_link.py +1897 -0
  9. calkit/cli/browser_link.py +85 -0
  10. calkit/cli/check.py +350 -25
  11. calkit/cli/core.py +2 -10
  12. calkit/cli/fix.py +2 -2
  13. calkit/cli/hub/__init__.py +2 -0
  14. calkit/cli/{hub.py → hub/core.py} +6 -0
  15. calkit/cli/hub/link.py +468 -0
  16. calkit/cli/import_.py +122 -67
  17. calkit/cli/latex.py +242 -86
  18. calkit/cli/main/core.py +731 -108
  19. calkit/cli/new.py +234 -53
  20. calkit/cli/open_.py +141 -81
  21. calkit/cli/overleaf.py +52 -26
  22. calkit/cli/show.py +10 -2
  23. calkit/cli/sync.py +8 -6
  24. calkit/cli/update.py +150 -32
  25. calkit/config.py +111 -7
  26. calkit/core.py +540 -50
  27. calkit/docker.py +24 -6
  28. calkit/docx.py +17 -0
  29. calkit/dvc/core.py +759 -69
  30. calkit/dvc/zip.py +40 -1
  31. calkit/environments/core.py +176 -80
  32. calkit/environments/texlive.py +1494 -0
  33. calkit/git.py +112 -10
  34. calkit/hub/__init__.py +8 -0
  35. calkit/{hub.py → hub/core.py} +118 -16
  36. calkit/hub/link.py +4831 -0
  37. calkit/install.py +120 -18
  38. calkit/invenio.py +206 -3
  39. calkit/latex.py +215 -24
  40. calkit/markdown.py +454 -50
  41. calkit/models/core.py +141 -37
  42. calkit/models/io.py +133 -54
  43. calkit/models/iteration.py +216 -13
  44. calkit/models/pipeline.py +431 -34
  45. calkit/models/requirements.py +6 -3
  46. calkit/overleaf.py +89 -7
  47. calkit/pipeline.py +471 -42
  48. calkit/provenance.py +481 -17
  49. calkit/questions.py +195 -32
  50. calkit/references.py +2053 -0
  51. calkit/releases.py +100 -2
  52. calkit/reproducibility.py +138 -48
  53. calkit/tests/cli/hub/__init__.py +0 -0
  54. calkit/tests/cli/{test_hub.py → hub/test_core.py} +21 -18
  55. calkit/tests/cli/hub/test_link.py +249 -0
  56. calkit/tests/cli/main/test_core.py +799 -51
  57. calkit/tests/cli/main/test_xr.py +1 -0
  58. calkit/tests/cli/test_browser_link.py +39 -0
  59. calkit/tests/cli/test_check.py +330 -0
  60. calkit/tests/cli/test_fix.py +3 -1
  61. calkit/tests/cli/test_import.py +140 -5
  62. calkit/tests/cli/test_latex.py +254 -32
  63. calkit/tests/cli/test_new.py +335 -5
  64. calkit/tests/cli/test_notebooks.py +3 -2
  65. calkit/tests/cli/test_open.py +67 -2
  66. calkit/tests/cli/test_overleaf.py +45 -4
  67. calkit/tests/cli/test_show.py +7 -0
  68. calkit/tests/cli/test_update.py +202 -6
  69. calkit/tests/conftest.py +95 -0
  70. calkit/tests/dvc/test_core.py +503 -4
  71. calkit/tests/dvc/test_zip.py +42 -0
  72. calkit/tests/environments/test_core.py +90 -3
  73. calkit/tests/environments/test_texlive.py +551 -0
  74. calkit/tests/hub/__init__.py +0 -0
  75. calkit/tests/{test_hub.py → hub/test_core.py} +136 -12
  76. calkit/tests/hub/test_link.py +3023 -0
  77. calkit/tests/models/test_core.py +57 -0
  78. calkit/tests/models/test_io.py +32 -1
  79. calkit/tests/models/test_iteration.py +113 -10
  80. calkit/tests/models/test_pipeline.py +328 -8
  81. calkit/tests/test_browser_link.py +1052 -0
  82. calkit/tests/test_conda.py +8 -8
  83. calkit/tests/test_config.py +54 -0
  84. calkit/tests/test_core.py +259 -0
  85. calkit/tests/test_docker.py +26 -0
  86. calkit/tests/test_docx.py +21 -0
  87. calkit/tests/test_git.py +62 -0
  88. calkit/tests/test_install.py +68 -0
  89. calkit/tests/test_invenio.py +160 -1
  90. calkit/tests/test_latex.py +120 -0
  91. calkit/tests/test_magics.py +1 -0
  92. calkit/tests/test_markdown.py +262 -1
  93. calkit/tests/test_overleaf.py +109 -0
  94. calkit/tests/test_pipeline.py +512 -2
  95. calkit/tests/test_provenance.py +434 -8
  96. calkit/tests/test_questions.py +214 -2
  97. calkit/tests/test_references.py +1127 -0
  98. calkit/tests/test_releases.py +89 -0
  99. calkit/tests/test_reproducibility.py +110 -1
  100. calkit/tests/test_upgrade.py +46 -0
  101. calkit/tests/test_workspace.py +5 -0
  102. calkit/upgrade.py +32 -7
  103. calkit/workspace.py +6 -3
  104. {calkit_python-0.50.7.dist-info → calkit_python-0.52.0.dist-info}/METADATA +31 -5
  105. {calkit_python-0.50.7.dist-info → calkit_python-0.52.0.dist-info}/RECORD +121 -105
  106. calkit/server.py +0 -652
  107. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/etc/jupyter/jupyter_server_config.d/calkit.json +0 -0
  108. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/share/jupyter/labextensions/calkit/package.json +0 -0
  109. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/share/jupyter/labextensions/calkit/schemas/calkit/package.json.orig +0 -0
  110. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/share/jupyter/labextensions/calkit/schemas/calkit/plugin.json +0 -0
  111. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/share/jupyter/labextensions/calkit/static/506.c34b070098184e33.js +0 -0
  112. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/share/jupyter/labextensions/calkit/static/57d13a7399cec3c5.png +0 -0
  113. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/share/jupyter/labextensions/calkit/static/616.528427eb54a4a0c0.js +0 -0
  114. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/share/jupyter/labextensions/calkit/static/740.6bf87276e9e5788a.js +0 -0
  115. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/share/jupyter/labextensions/calkit/static/899.f9b9f9bf705a6493.js +0 -0
  116. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/share/jupyter/labextensions/calkit/static/935.46ecc6bf99aa593a.js +0 -0
  117. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/share/jupyter/labextensions/calkit/static/remoteEntry.109a3a8379365e59.js +0 -0
  118. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/share/jupyter/labextensions/calkit/static/style.js +0 -0
  119. {calkit_python-0.50.7.data → calkit_python-0.52.0.data}/data/share/jupyter/labextensions/calkit/static/third-party-licenses.json +0 -0
  120. {calkit_python-0.50.7.dist-info → calkit_python-0.52.0.dist-info}/WHEEL +0 -0
  121. {calkit_python-0.50.7.dist-info → calkit_python-0.52.0.dist-info}/entry_points.txt +0 -0
  122. {calkit_python-0.50.7.dist-info → calkit_python-0.52.0.dist-info}/licenses/LICENSE +0 -0
calkit/__init__.py CHANGED
@@ -93,7 +93,6 @@ _SUBMODULES = {
93
93
  "requirements",
94
94
  "resources",
95
95
  "schema",
96
- "server",
97
96
  "templates",
98
97
  "upgrade",
99
98
  "workspace",
@@ -40,6 +40,12 @@ calkit xr scripts/new-stage.py \
40
40
  After running, inspect the new stage in `calkit.yaml` to confirm I/O is
41
41
  correct.
42
42
 
43
+ <!-- TODO: needs human review -->
44
+
45
+ For a `.tex` file in a project with no `texlive` environment, create one
46
+ with `calkit new texlive-env` first, so `xr` uses it. Older versions of
47
+ Calkit otherwise create a Docker one with Calkit's LaTeX image.
48
+
43
49
  ## Option B: Write the stage manually
44
50
 
45
51
  Write YAML directly when the stage is a shell command, or when you need
@@ -6,7 +6,7 @@ description: Build the pipeline stages a manuscript's TODO comments ask for,
6
6
  invokes `/calkit:build-paper-pipeline`, leaves TODO comments in a manuscript
7
7
  for an agent to address, or asks to work backwards from the writing to the
8
8
  project behind it. Only for TODOs in a manuscript, and only in a Calkit
9
- project: not TODO comments in source code, not GitHub issues, not a task
9
+ project; not TODO comments in source code, not GitHub issues, not a task
10
10
  list in someone's notes.
11
11
  ---
12
12
 
@@ -31,13 +31,17 @@ number into the sentence.
31
31
 
32
32
  ## The rule that makes this safe
33
33
 
34
+ <!-- TODO: needs human review -->
35
+
34
36
  **Never type a computed value into the manuscript.** A number you typed is
35
37
  a number nobody can check, and it goes stale the moment a stage reruns. The
36
38
  number reaches the page through the pipeline: a stage computes it and
37
- writes it to a results file, a `json-to-latex` stage turns that file into
38
- LaTeX commands, and the manuscript says `\result[Speedup]`. The same
39
- applies to figures (`\ckfigure{...}` over a pipeline output) and to the
40
- answers in `calkit.yaml` (`{name}` placeholders over `value` evidence).
39
+ writes it to a results file, and the manuscript, which loads the `calkit`
40
+ LaTeX package, reads it from that file with
41
+ `\ckvalue[.2f]{results/speedup.json}{mean_speedup}`. The same applies to
42
+ figures (`\ckfigure{...}`) and tables (`\cktable{...}`) over pipeline
43
+ outputs, and to the answers in `calkit.yaml` (`{name}` placeholders over
44
+ `value` evidence).
41
45
 
42
46
  If you find yourself about to write `2.4x` into a `.tex` file, stop: that
43
47
  is the hole, not the fix. The `check-reproducibility` skill covers finding
@@ -74,10 +78,37 @@ building a pipeline from scratch.
74
78
  headlessly. Write the results to a JSON file under `results/` with keys
75
79
  named the way the paper will refer to them.
76
80
 
77
- 4. **Inject, don't copy.** Add a `json-to-latex` stage over the results
78
- file and reference the values from the manuscript with the generated
79
- command. Replace the TODO with the sentence the user wrote, now with
80
- `\result[...]` where the hole was.
81
+ <!-- TODO: needs human review -->
82
+
83
+ 4. **Inject, don't copy.** Load the package with `\usepackage{calkit}` if
84
+ the document doesn't already, and replace the TODO with the sentence the
85
+ user wrote, now with `\ckvalue[format]{results/<file>.json}{<key>}` where
86
+ the hole was:
87
+
88
+ ```latex
89
+ \usepackage{calkit}
90
+ ...
91
+ Our method is faster than the baseline by
92
+ \ckvalue[.2f]{results/speedup.json}{mean_speedup}$\times$.
93
+ \ckfigure[width=0.7\linewidth]{figures/speedup-distribution.png}
94
+ \cktable{tables/speedup-by-case.tex}
95
+ ```
96
+
97
+ Paths are relative to the project, not the document. The document's
98
+ LaTeX stage depends on everything it includes this way, so there's no
99
+ `json-to-latex` or `map-paths` stage to add, and nothing to list in its
100
+ `inputs`. Pick the format for how the paper should read, e.g., `.2f`
101
+ for two decimal places or `.3g` for three significant figures; keys
102
+ reach into nested values with dots, e.g., `fit.slope`. `\ckvalue` can't
103
+ go inside siunitx commands, so write a unit after it, e.g.,
104
+ `\ckvalue[.1f]{results/flow.json}{speed}~\unit{\metre\per\second}`.
105
+ If the document already uses commands a `json-to-latex` stage
106
+ generates, they keep working; use `\ckvalue` for new values, and ask
107
+ before converting the old ones.
108
+
109
+ If no LaTeX stage builds the document yet, add one in a `texlive`
110
+ environment, which needs no Docker: `calkit new texlive-env`, if the
111
+ project has none, then `calkit xr paper/main.tex`.
81
112
 
82
113
  5. **Make the question match the paper.** A claim in the paper is an answer
83
114
  to a question. Add or update the entry under `questions` in
@@ -38,6 +38,8 @@ Deterministic, done by `calkit check questions` — never re-derive by hand:
38
38
  - every clause of a conditional answer parses, names only evidence, and
39
39
  renders, including the clauses the current values don't select;
40
40
  - every publication `label` still exists in the LaTeX source;
41
+ - every `lines` range on a plain file entry, one with no `kind`, is still
42
+ within the file;
41
43
  - no evidence has changed (Git history for Git-tracked outputs, `dvc.lock`
42
44
  for DVC-tracked ones) since the commit that last edited the question;
43
45
  - no verification is stale, i.e., neither the approach nor any of the
@@ -54,7 +56,8 @@ Deterministic, done by `calkit check questions` — never re-derive by hand:
54
56
  nothing computes is a magic number;
55
57
  - each other evidence path is produced by a pipeline stage, or declared
56
58
  with `imported_from` or `created_by`. This one is advisory: it is
57
- reported as `unattributed` and does not fail the check.
59
+ reported as `unattributed` and does not fail the check. A file inside a
60
+ directory a stage lists as an output is produced by that stage.
58
61
 
59
62
  Judgment, done here — the check reads paths and hashes, and cannot read a
60
63
  sentence:
@@ -194,6 +197,10 @@ that is a false statement about the project, not a tidy-up.
194
197
  precision the claim needs: `{ratio:.1f}x`, `{error:.0%}`. When several
195
198
  come from one file, e.g., the outputs of one calculation, name them
196
199
  together in one `result` entry's `values`, a map of name to key.
200
+ - To cite a file as it is, e.g., a log, a transcript excerpt, or a
201
+ script, give just its `path`, with no `kind`, and the `lines` that
202
+ matter, e.g., `lines: 8` or `lines: 12-20`. Don't use `document` for
203
+ these; that is for write-ups a Markdown stage builds.
197
204
  - A `value` entry must read a file a pipeline stage writes. A placeholder
198
205
  over a results file written by hand, including one you write, is a
199
206
  retyped number with extra steps, and the check fails it. If no stage
@@ -49,7 +49,7 @@ Judgment, done here:
49
49
  3. **Every `retyped_values` finding is worth fixing.** Each is a number
50
50
  the pipeline already computes, typed into the document: right today and
51
51
  wrong the next time that stage runs. The finding names the results file
52
- and key, so the fix is mechanical.
52
+ and key, so the fix is mechanical: `\ckvalue{<file>}{<key>}`.
53
53
 
54
54
  4. **`unattributed_numbers` is a list to read, not a list to fix.** Most
55
55
  numbers in a paper are not results. A quantity quoted from a reference
@@ -61,8 +61,11 @@ Judgment, done here:
61
61
  rewrite a sentence to make a check pass, and never invent a stage to
62
62
  compute a number somebody else measured.
63
63
 
64
+ <!-- TODO: needs human review -->
65
+
64
66
  For a number that is this project's result, it must reach the page
65
- through the pipeline rather than through the author's fingers:
67
+ through the pipeline rather than through the author's fingers. A stage
68
+ writes it to a results file:
66
69
 
67
70
  ```yaml
68
71
  pipeline:
@@ -72,29 +75,26 @@ Judgment, done here:
72
75
  environment: py
73
76
  script_path: scripts/compute-drag.py
74
77
  outputs: [results/drag.json]
75
- drag-to-latex:
76
- kind: json-to-latex
77
- command_name: result
78
- inputs: [results/drag.json]
79
- outputs:
80
- - path: paper/generated-drag.tex
81
- storage: git
82
78
  ```
83
79
 
84
- The script writes `{"DragCoefficient": 0.42}`. The document inputs the
85
- generated file and refers to the value by key:
80
+ The script writes `{"DragCoefficient": 0.42}`. The document loads the
81
+ `calkit` LaTeX package and reads the value from that file by its path
82
+ in the project and its key:
86
83
 
87
84
  ```latex
88
- \input{generated-drag}
85
+ \usepackage{calkit}
89
86
  ...
90
- The drag coefficient is \result[DragCoefficient].
87
+ The drag coefficient is \ckvalue[.2f]{results/drag.json}{DragCoefficient}.
91
88
  ```
92
89
 
93
- `json-to-latex` generates one _keyed_ command per file, named by
94
- `command_name` (or the output file's stem), so the reference is
95
- `\result[DragCoefficient]` --- not a separate macro per key. Never write
96
- a raw `stages:` block with `cmd: calkit latex from-json`; the stage kind
97
- is what keeps `calkit.yaml` the single source of truth.
90
+ The document's LaTeX stage depends on what it includes this way, so no
91
+ `json-to-latex` stage or added `inputs` are needed. A `retyped_values`
92
+ finding's `source` names the file and key to use. If the document
93
+ already uses commands a `json-to-latex` stage generates, e.g.,
94
+ `\result[DragCoefficient]`, they keep working, so referencing the
95
+ existing command is fine there too. Never define a macro that holds the
96
+ number, or edit a generated file by hand: either one is a typed value
97
+ with extra steps.
98
98
 
99
99
  5. **Run the pipeline** (`calkit run`) and check again. Do not run the
100
100
  script yourself and paste the number in: that is the failure this whole
@@ -66,6 +66,7 @@ kinds:
66
66
  | `conda` | `environment.yml` |
67
67
  | `pixi` | `pixi.toml` |
68
68
  | `docker` | (image name, no local spec file needed) |
69
+ | `texlive` | (TeX Live packages, listed in the env) |
69
70
  | `renv` | `renv.lock` |
70
71
  | `julia` | `Project.toml` |
71
72
  | `matlab` | (no spec file) |
@@ -78,6 +79,12 @@ For Python, default to a `uv` project environment, created with
78
79
  `requires-python`. Use `uv-venv` only for a project that already has a
79
80
  `requirements.txt` it should keep.
80
81
 
82
+ <!-- TODO: needs human review -->
83
+
84
+ For LaTeX, default to a `texlive` environment, created with
85
+ `calkit new texlive-env`, which needs no Docker. A build adds the packages
86
+ a document needs to the environment's lock.
87
+
81
88
  Example environment definitions:
82
89
 
83
90
  ```yaml
@@ -86,9 +93,9 @@ environments:
86
93
  kind: uv
87
94
  path: pyproject.toml
88
95
 
89
- texlive:
90
- kind: docker
91
- image: texlive/texlive:latest-full
96
+ tex:
97
+ kind: texlive
98
+ release: 2025
92
99
 
93
100
  r-env:
94
101
  kind: renv
@@ -123,6 +130,24 @@ See the `calkit.yaml` schema for details.
123
130
  The most common stage kinds are `python-script`, `shell-script`, `shell-command`,
124
131
  `jupyter-notebook`.
125
132
 
133
+ <!-- TODO: needs human review -->
134
+
135
+ ### LaTeX documents
136
+
137
+ A document built by a `latex` stage includes pipeline outputs by their
138
+ path in the project with the `calkit` package:
139
+
140
+ ```latex
141
+ \usepackage{calkit}
142
+ ...
143
+ The error falls to \ckvalue[.2f]{results/metrics.json}{rmse}.
144
+ \ckfigure[width=0.7\linewidth]{figures/plot.png}
145
+ \cktable{tables/summary.tex}
146
+ ```
147
+
148
+ The stage depends on everything included this way, so don't add
149
+ `json-to-latex` or `map-paths` stages, or list those files in `inputs`.
150
+
126
151
  ### Outputs: Git vs. DVC storage
127
152
 
128
153
  By default, outputs are stored with DVC (large file storage). Use
@@ -136,6 +161,9 @@ outputs:
136
161
  - path: results/summary.txt
137
162
  storage: git
138
163
  delete_before_run: false # don't delete before re-running
164
+ - path: results/runs
165
+ storage: git
166
+ ignore: ["*.log"] # neither stored nor part of the output
139
167
  ```
140
168
 
141
169
  ### Declaring dependencies between stages
@@ -50,7 +50,8 @@ Every stage must reference a named environment. Identify what's needed:
50
50
  keep → `uv-venv`; `environment.yml` → `conda`
51
51
  - **R**: `renv.lock` → `renv`
52
52
  - **Julia**: `Project.toml` → `julia`
53
- - **LaTeX**: `docker` with `texlive/texlive:latest-full`
53
+ - **LaTeX**: `texlive`, created with `calkit new texlive-env`, which
54
+ needs no Docker
54
55
  - **MATLAB**: `matlab`
55
56
 
56
57
  Add environments to `calkit.yaml`:
@@ -85,6 +86,12 @@ calkit xr scripts/train.py \
85
86
  --output models/model.pkl
86
87
  ```
87
88
 
89
+ <!-- TODO: needs human review -->
90
+
91
+ Create the `texlive` environment before running `xr` on a `.tex` file, so
92
+ `xr` uses it. Older versions of Calkit otherwise create a Docker one with
93
+ Calkit's LaTeX image.
94
+
88
95
  `xr` is not magic—sometimes it won't get everything right. But it handles
89
96
  most of the boilerplate, so you can focus on verifying correctness and filling
90
97
  in gaps. Scan through scripts for missing inputs, outputs, environment
@@ -120,13 +127,15 @@ pipeline:
120
127
  build-paper:
121
128
  kind: latex
122
129
  target_path: paper/paper.tex
123
- environment: texlive
124
- inputs:
125
- - figures/fig1.png
126
- - references.bib
127
- outputs: []
130
+ environment: tex
128
131
  ```
129
132
 
133
+ <!-- TODO: needs human review -->
134
+
135
+ The paper includes `figures/fig1.png` with `\ckfigure{figures/fig1.png}`
136
+ and numbers with `\ckvalue`, from the `calkit` LaTeX package (see the
137
+ `conventions` skill), so the stage depends on them without listing them.
138
+
130
139
  Rules:
131
140
 
132
141
  - Stage names should be short, lowercase, hyphenated.