Skip to content

Commit 710c5f7

Browse files
committed
refactor: remove special support for ProofWidgets4 cloud releases (#37286)
This PR removes special support for ProofWidgets4 cloud releases. See leanprover-community/ProofWidgets4#165.
1 parent 34f85c5 commit 710c5f7

9 files changed

Lines changed: 17 additions & 79 deletions

File tree

.github/workflows/build_template.yml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ jobs:
327327
328328
# Fail quickly if the cache is completely cold, by checking for Mathlib.Init
329329
echo "Attempting to fetch olean for Mathlib/Init.lean from cache..."
330-
../tools-branch/.lake/build/bin/cache --skip-proofwidgets get Mathlib/Init.lean
330+
../tools-branch/.lake/build/bin/cache get Mathlib/Init.lean
331331
332332
- name: get cache (2/3 - test Mathlib.Init cache)
333333
id: get_cache_part2_test
@@ -381,9 +381,9 @@ jobs:
381381
echo "Warming up cache using previous commit: $PREV_SHA (source: $PREV_SHA_SOURCE)"
382382
if git cat-file -e "$PREV_SHA^{commit}" 2>/dev/null || git fetch --no-tags --depth=1 origin "$PREV_SHA"; then
383383
git checkout "$PREV_SHA"
384-
../tools-branch/.lake/build/bin/cache --skip-proofwidgets get
384+
../tools-branch/.lake/build/bin/cache get
385385
# Run again with --repo, to ensure we actually get the oleans.
386-
../tools-branch/.lake/build/bin/cache --repo="$CACHE_REPO" --skip-proofwidgets get
386+
../tools-branch/.lake/build/bin/cache --repo="$CACHE_REPO" get
387387
388388
echo "Switching back to branch head"
389389
git checkout "$ORIG_SHA"
@@ -396,18 +396,10 @@ jobs:
396396
397397
echo "Fetching all remaining cache..."
398398
399-
../tools-branch/.lake/build/bin/cache --skip-proofwidgets get
399+
../tools-branch/.lake/build/bin/cache get
400400
401401
# Run again with --repo, to ensure we actually get the oleans.
402-
../tools-branch/.lake/build/bin/cache --repo="$CACHE_REPO" --skip-proofwidgets get
403-
404-
- name: fetch ProofWidgets release
405-
# We need network access for ProofWidgets frontend assets.
406-
# Run inside landrun so PR-controlled code remains sandboxed.
407-
shell: landrun --unrestricted-network --rox /etc --rox /usr --rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rw pr-branch/.lake/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
408-
run: |
409-
cd pr-branch
410-
lake build proofwidgets:release
402+
../tools-branch/.lake/build/bin/cache --repo="$CACHE_REPO" get
411403
412404
- name: update {Mathlib, Tactic, Counterexamples, Archive}.lean
413405
id: mk_all
@@ -462,8 +454,8 @@ jobs:
462454
shell: bash
463455
run: |
464456
cd pr-branch
465-
../tools-branch/.lake/build/bin/cache --skip-proofwidgets get Archive.lean
466-
../tools-branch/.lake/build/bin/cache --skip-proofwidgets get Counterexamples.lean
457+
../tools-branch/.lake/build/bin/cache get Archive.lean
458+
../tools-branch/.lake/build/bin/cache get Counterexamples.lean
467459
468460
- name: build archive
469461
id: archive

Cache/IO.lean

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,12 @@ def rootHashGeneration : UInt64 := 4
122122
folders are located. However, `lake` has multiple options to customise these paths, like
123123
setting `srcDir` in a `lean_lib`. See `mkBuildPaths` below which currently assumes
124124
that no such options are set in any mathlib dependency)
125-
* the build directory for proofwidgets
126125
-/
127126
structure CacheM.Context where
128127
/-- source directory for mathlib files -/
129128
mathlibDepPath : FilePath
130129
/-- the Lean source search path -/
131130
srcSearchPath : SearchPath
132-
/-- build directory for proofwidgets -/
133-
proofWidgetsBuildDir : FilePath
134131

135132
@[inherit_doc CacheM.Context]
136133
abbrev CacheM := ReaderT CacheM.Context IO
@@ -158,8 +155,7 @@ private def CacheM.getContext : IO CacheM.Context := do
158155
let mathlibSource ← CacheM.mathlibDepPath sp
159156
return {
160157
mathlibDepPath := mathlibSource,
161-
srcSearchPath := sp,
162-
proofWidgetsBuildDir := LAKEPACKAGESDIR / "proofwidgets" / ".lake" / "build"}
158+
srcSearchPath := sp}
163159

164160
/-- Run a `CacheM` in `IO` by loading the context from `LEAN_SRC_PATH`. -/
165161
def CacheM.run (f : CacheM α) : IO α := do ReaderT.run f (← getContext)

Cache/Main.lean

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Commands:
3939
Options:
4040
--repo=OWNER/REPO Override the repository to fetch/push cache from
4141
--staging-dir=<output-directory> Required for 'stage', 'stage!', 'unstage' and 'put-staged': staging directory.
42-
--skip-proofwidgets Skip fetching/building ProofWidgets release assets during 'get'
4342
4443
* Linked files refer to local cache files with corresponding Lean sources
4544
* Commands ending with '!' should be used manually, when hot-fixes are needed
@@ -101,7 +100,6 @@ def main (args : List String) : IO Unit := do
101100
-- parse relevant options, ignore the rest
102101
let repo? ← parseNamedOpt "repo" options
103102
let stagingDir? ← parseNamedOpt "staging-dir" options
104-
let skipProofWidgets := parseFlagOpt "skip-proofwidgets" options
105103

106104
let mut roots : Std.HashMap Lean.Name FilePath ← parseArgs args
107105
if roots.isEmpty then do
@@ -118,7 +116,7 @@ def main (args : List String) : IO Unit := do
118116
if leanTarArgs.contains (args.headD "") then validateLeanTar
119117
let get (args : List String) (force := false) (decompress := true) := do
120118
let hashMap ← if args.isEmpty then pure hashMap else hashMemo.filterByRootModules roots.keys
121-
getFiles repo? hashMap force force goodCurl decompress skipProofWidgets
119+
getFiles repo? hashMap force force goodCurl decompress
122120
let pack (overwrite verbose unpackedOnly := false) := do
123121
packCache hashMap overwrite verbose unpackedOnly (← getGitCommitHash)
124122
let put (overwrite unpackedOnly := false) := do

Cache/Requests.lean

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -641,61 +641,15 @@ def checkForManifestMismatch : IO.CacheM Unit := do
641641
precedence, then run `lake update`."
642642
IO.Process.exit 1
643643

644-
/-- Fetches the ProofWidgets cloud release and prunes non-JS files. -/
645-
def getProofWidgets (buildDir : FilePath) : IO Unit := do
646-
if (← buildDir.pathExists) then
647-
-- Check if the ProofWidgets build is out-of-date via `lake`.
648-
-- This is done through Lake as cache has no simple heuristic
649-
-- to determine whether the ProofWidgets JS is out-of-date.
650-
let out ← IO.Process.output
651-
{cmd := "lake", args := #["-v", "build", "--no-build", "proofwidgets:release"]}
652-
if out.exitCode == 0 then -- up-to-date
653-
return
654-
else if out.exitCode == 3 then -- needs fetch (`--no-build` triggered)
655-
pure ()
656-
else
657-
printLakeOutput out
658-
throw <| IO.userError s!"Failed to validate ProofWidgets cloud release: \
659-
lake failed with error code {out.exitCode}"
660-
-- Download and unpack the ProofWidgets cloud release (for its `.js` files)
661-
IO.print "Fetching ProofWidgets cloud release..."
662-
let out ← IO.Process.output
663-
{cmd := "lake", args := #["-v", "build", "proofwidgets:release"]}
664-
if out.exitCode == 0 then
665-
IO.println " done!"
666-
else
667-
IO.print "\n"
668-
printLakeOutput out
669-
throw <| IO.userError s!"Failed to fetch ProofWidgets cloud release: \
670-
lake failed with error code {out.exitCode}"
671-
-- Prune non-JS ProofWidgets files (e.g., `olean`, `.c`)
672-
try
673-
IO.FS.removeDirAll (buildDir / "lib")
674-
IO.FS.removeDirAll (buildDir / "ir")
675-
catch e =>
676-
throw <| IO.userError s!"Failed to prune ProofWidgets cloud release: {e}"
677-
where
678-
printLakeOutput out := do
679-
unless out.stdout.isEmpty do
680-
IO.eprintln "lake stdout:"
681-
IO.eprint out.stdout
682-
unless out.stderr.isEmpty do
683-
IO.eprintln "lake stderr:"
684-
IO.eprint out.stderr
685-
686644
/-- Downloads missing files, and unpacks files. -/
687645
def getFiles
688646
(repo? : Option String) (hashMap : IO.ModuleHashMap)
689-
(forceDownload forceUnpack parallel decompress skipProofWidgets : Bool)
647+
(forceDownload forceUnpack parallel decompress : Bool)
690648
: IO.CacheM Unit := do
691649
let isMathlibRoot ← IO.isMathlibRoot
692650
unless isMathlibRoot do
693651
checkForToolchainMismatch
694652
checkForManifestMismatch
695-
if skipProofWidgets then
696-
IO.println "Skipping ProofWidgets release fetch"
697-
else
698-
getProofWidgets (← read).proofWidgetsBuildDir
699653

700654
let mathlibDepPath := (← read).mathlibDepPath
701655

Mathlib/Tactic/CategoryTheory/Coherence/Normalize.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ the concept of strict monoidal categories due to the feature of dependent type t
3737
normalization tactic can remove associators and unitors from the expression, extracting the
3838
necessary data for drawing string diagrams.
3939
40-
The string diagrams widget is to use Penrose (https://github.com/penrose) via ProofWidget.
40+
The string diagrams widget is to use Penrose (https://github.com/penrose) via ProofWidgets.
4141
However, it should be noted that the normalization procedure in this file does not rely on specific
4242
settings, allowing for broader application. Future plans include the following. At least I (Yuma)
4343
would like to work on these in the future, but it might not be immediate. If anyone is interested,

Mathlib/Tactic/Widget/Conv.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public meta import Lean.PrettyPrinter.Delaborator.Builtins
1515
/-! # Conv widget
1616
1717
This is a slightly improved version of one of the examples that used to be
18-
in the ProofWidget library. It defines a `conv?` tactic that displays a widget panel
18+
in the ProofWidgets library. It defines a `conv?` tactic that displays a widget panel
1919
allowing to generate a `conv` call zooming to the subexpression selected in the goal.
2020
-/
2121

lake-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
"type": "git",
3636
"subDir": null,
3737
"scope": "leanprover-community",
38-
"rev": "136730b5a40dc633967f5433cb7668df5c3bf9a3",
38+
"rev": "1d1093b4c97f85a198d4dcb4cdb97b333866adb7",
3939
"name": "proofwidgets",
4040
"manifestFile": "lake-manifest.json",
41-
"inputRev": "v0.0.94",
41+
"inputRev": "v0.0.95-pre1",
4242
"inherited": false,
4343
"configFile": "lakefile.lean"},
4444
{"url": "https://github.com/leanprover-community/aesop",

lakefile.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ open Lake DSL
99
require "leanprover-community" / "batteries" @ git "main"
1010
require "leanprover-community" / "Qq" @ git "master"
1111
require "leanprover-community" / "aesop" @ git "master"
12-
require "leanprover-community" / "proofwidgets" @ git "v0.0.94" -- ProofWidgets should always be pinned to a specific version
12+
require "leanprover-community" / "proofwidgets" @ git "v0.0.95-pre1"
1313
with NameMap.empty.insert `errorOnBuild
14-
"ProofWidgets not up-to-date. \
15-
Please run `lake exe cache get` to fetch the latest ProofWidgets. \
14+
"ProofWidgets failed to reuse pre-built JS code. \
15+
Please remove the `.lake/` directory and try again. \
1616
If this does not work, report your issue on the Lean Zulip."
1717
require "leanprover-community" / "importGraph" @ git "main"
1818
require "leanprover-community" / "LeanSearchClient" @ git "main"

scripts/bench/build/run

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ set -euxo pipefail
44
BENCH="scripts/bench"
55

66
# Prepare build
7-
# Use build cache for proofwidgets, but not for anything else.
87
lake clean
9-
LEAN_PATH=$(lean --print-libdir) lake build proofwidgets
108
rm -f .lake/packages/batteries/.lake/build/bin/runLinter
119

1210
# Run build

0 commit comments

Comments
 (0)