Repository navigation
Cache function result across builds #827
|
Hi. I'm using clerk notebooks to solve and share AoC puzzles, https://alirezaalavi87.github.io/advent-of-code/src/aoc/2025/day3/main/. in the visualization part of this question, I have done computations on the full input data, and plotted them with plotly. On my local env, I have the full input, and it works. but when I publish, since the input file isn't available, it doesn't work. How can I cache the result of |
Replies: 1 comment 1 reply
|
Clerk's cache won't carry this to the published build. It lives in The simplest fix is to save the computed numbers next to the notebook when the input exists, commit that file, and read it back when the input is missing. The derived numbers aren't your puzzle input, so this is fine to publish. (require '[clojure.edn :as edn]
'[clojure.java.io :as io])
(def ^:private input-file "src/aoc/2025/day3/input.txt")
(def ^:private full-range-file "src/aoc/2025/day3/full-range.edn")
(def ^:private total-max-joltage-per-full-range
(if (.exists (io/file input-file))
(let [result (vec (pmap #(sum-bank-joltages (parse-input! input-file)
(partial bank-max-joltage %))
batteries-full-range))]
(spit full-range-file (pr-str result))
result)
(edn/read-string (slurp full-range-file))))Run the notebook once locally, commit I checked this with Clerk 0.18.1158: built once with the input present, then removed the input and |
Clerk's cache won't carry this to the published build. It lives in
.clerk/cache, which you gitignore, and your Pages workflow caches.cache, so the CI build always has to runparse-input!on a file that isn't there.The simplest fix is to save the computed numbers next to the notebook when the input exists, commit that file, and read it back when the input is missing. The derived numbers aren't your puzzle input, so this is fine to publish.