Skip to content

Commit 5251d14

Browse files
update skip_if_unchanged_example
1 parent b8ae48b commit 5251d14

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

site/scicloj/clay/skip_if_unchanged_example.qmd

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
description: A demonstration of our practice with some Civitas notebooks that cannot be run in GitHub Pages.
2+
description: How to create notebooks with secrets, large files, and slow processes.
33
category: clay
44
tags: [clay, workflow]
55
format:
6-
html: {title: Some Civitas notebooks should only be run locally}
6+
html: {title: Some Clay notebooks should only be run locally}
77
date: '2025-07-25'
88
type: post
99
author:
@@ -26,8 +26,24 @@ image: skip-if-unchanged.jpg
2626
.clay-side-by-side .sourceCode {margin: 0}
2727
.clay-side-by-side {margin: 1em 0}
2828
</style>
29-
<script src="skip_if_unchanged_example_files/md-default0.js" type="text/javascript"></script><script src="skip_if_unchanged_example_files/md-default1.js" type="text/javascript"></script>
30-
(Work-In-Progress Draft)
29+
<script src="skip_if_unchanged_example.qmd_files/md-default0.js" type="text/javascript"></script><script src="skip_if_unchanged_example.qmd_files/md-default1.js" type="text/javascript"></script>
30+
31+
::: {.sourceClojure}
32+
```clojure
33+
^{:clay {:title "Some Clay notebooks should only be run locally"
34+
:external-requirements ["my-secret.txt"]
35+
:quarto {:author :daslu
36+
:description "How to create notebooks with secrets, large files, and slow processes."
37+
:image "skip-if-unchanged.jpg"
38+
:type :post
39+
:date "2025-07-25"
40+
:category :clay
41+
:tags [:clay :workflow]
42+
:draft true}}}
43+
(ns scicloj.clay.skip-if-unchanged-example)
44+
```
45+
:::
46+
3147

3248
Usually, when we wish to create Clojure Civitas posts, we enjoy the fact
3349
that Civitas runs our notebooks in the GitHub Actions as it renders the website.
@@ -42,22 +58,22 @@ and it will not work without it!
4258

4359
::: {.sourceClojure}
4460
```clojure
45-
(slurp "/home/daslu/my-secret.txt")
61+
(slurp "temp/my-secret.txt")
4662
```
4763
:::
4864

4965

5066

5167
::: {.printedClojure}
5268
```clojure
53-
"this is my secret!!!!!\n"
69+
"this is my secret!\n"
5470

5571
```
5672
:::
5773

5874

5975
If you are the author of such a notebook, the recommended practice is to
60-
render the notebook locally usinc Clay in Quarto `.qmd` format, and include
76+
render the notebook locally using Clay in Quarto `.qmd` format, and include
6177
that file in your Pull Request.
6278

6379
The `.qmd` file is all that Civitas needs to include your notebook in the
@@ -89,9 +105,27 @@ clojure -M:clay -A:markdown scicloj/clay/skip_if_unchanged_example.clj
89105

90106

91107
Now, need to `git add` the generated `qmd` file.
92-
Here is how.
93108

94-
(WIP)
109+
```sh
110+
git add -f site/scicloj/clay/skip_if_unchanged_example.clj
111+
```
112+
113+
Also we need to add some metadata to this namespace.
114+
Notice in the above namespace form there is:
115+
116+
```
117+
^{:clay {:external-requirements ["my-secret.txt"] ...}...}
118+
```
119+
120+
That tells Clay that it should use the `.qmd` file instead of executing the notebook.
121+
When we commit and push, the site will be built from our `.qmd` file instead of `.clj` file.
122+
123+
This approach works for credentials, large files,
124+
and slow processes which would otherwise cause the build process to be slow or fail.
125+
126+
We hope this enables interesting use cases where providing reproducible code is important,
127+
while capturing just one specific execution of the code is valuable...
128+
such as an interactive session calling an LLM API which is saved as a static document.
95129

96130

97131
```{=html}

0 commit comments

Comments
 (0)