|
1 | | -^{:kindly/hide-code true |
2 | | - :clay |
3 | | - {:title "Some Civitas notebooks should only be run locally" |
4 | | - :quarto {:author :daslu |
5 | | - :description "A demonstration of our practice with some Civitas notebooks that cannot be run in GitHub Pages." |
6 | | - :image "skip-if-unchanged.jpg" |
7 | | - :type :post |
8 | | - :date "2025-07-25" |
9 | | - :category :clay |
10 | | - :tags [:clay :workflow] |
11 | | - :draft true}}} |
| 1 | +^{:clay {:title "Some Clay notebooks should only be run locally" |
| 2 | + :external-requirements ["my-secret.txt"] |
| 3 | + :quarto {:author :daslu |
| 4 | + :description "How to create notebooks with secrets, large files, and slow processes." |
| 5 | + :image "skip-if-unchanged.jpg" |
| 6 | + :type :post |
| 7 | + :date "2025-07-25" |
| 8 | + :category :clay |
| 9 | + :tags [:clay :workflow] |
| 10 | + :draft true}}} |
12 | 11 | (ns scicloj.clay.skip-if-unchanged-example) |
13 | 12 |
|
14 | | -;; (Work-In-Progress Draft) |
15 | | - |
16 | 13 | ;; Usually, when we wish to create Clojure Civitas posts, we enjoy the fact |
17 | 14 | ;; that Civitas runs our notebooks in the GitHub Actions as it renders the website. |
18 | 15 |
|
|
23 | 20 | ;; This notebook, for example, assumes that you have a local secrets file, |
24 | 21 | ;; and it will not work without it! |
25 | 22 |
|
26 | | -(slurp "/home/daslu/my-secret.txt") |
| 23 | +(slurp "temp/my-secret.txt") |
27 | 24 |
|
28 | 25 | ;; If you are the author of such a notebook, the recommended practice is to |
29 | | -;; render the notebook locally usinc Clay in Quarto `.qmd` format, and include |
| 26 | +;; render the notebook locally using Clay in Quarto `.qmd` format, and include |
30 | 27 | ;; that file in your Pull Request. |
31 | 28 |
|
32 | 29 | ;; The `.qmd` file is all that Civitas needs to include your notebook in the |
|
50 | 47 | (clay/make! {:source-path "scicloj/clay/skip_if_unchanged_example.clj" |
51 | 48 | :aliases [:markdown]})) |
52 | 49 |
|
| 50 | +;; Now, need to `git add` the generated `qmd` file. |
53 | 51 |
|
| 52 | +;; ```sh |
| 53 | +;; git add -f site/scicloj/clay/skip_if_unchanged_example.clj |
| 54 | +;; ``` |
54 | 55 |
|
55 | | -;; Now, need to `git add` the generated `qmd` file. |
56 | | -;; Here is how. |
| 56 | +;; Also we need to add some metadata to this namespace. |
| 57 | +;; Notice in the above namespace form there is: |
| 58 | + |
| 59 | +;; ``` |
| 60 | +;; ^{:clay {:external-requirements ["my-secret.txt"] ...}...} |
| 61 | +;; ``` |
| 62 | + |
| 63 | +;; That tells Clay that it should use the `.qmd` file instead of executing the notebook. |
| 64 | +;; When we commit and push, the site will be built from our `.qmd` file instead of `.clj` file. |
| 65 | + |
| 66 | +;; This approach works for credentials, large files, |
| 67 | +;; and slow processes which would otherwise cause the build process to be slow or fail. |
57 | 68 |
|
58 | | -;; (WIP) |
| 69 | +;; We hope this enables interesting use cases where providing reproducible code is important, |
| 70 | +;; while capturing just one specific execution of the code is valuable... |
| 71 | +;; such as an interactive session calling an LLM API which is saved as a static document. |
0 commit comments