Skip to content

feat(Cache): enable partial cache in downstream projects - #21195

Closed
joneugster wants to merge 1 commit into
masterfrom
eugster/cache_downstream
Closed

joneugster wants to merge 1 commit into
masterfrom
eugster/cache_downstream

Conversation

@joneugster

@joneugster joneugster commented Jan 28, 2025 •

Copy link
Copy Markdown
Member

NOTE: completely replaced by #21238

Enable lake exe cache get MyProject.lean to get a partial mathlib cache.

Does not alter the functionality of lake exe cache get (no args) in downstream projects, nor lake exe cache get Mathlib/Init.lean for cached files.

Note: This is a bit hacky and will always report "Warning: some files were not found in the cache" for the files coming from the downstream project, but a proper implementation seems to require access to the loaded lake Workspace (not just the manifest), which seems not to be supported at the current time.


Moreover, this assumes the downstream project has a somewhat sane setup, which hopefully applies for a majority of projects. Concretely, lake exe cache get MyProject/Basic.lean assumes that there is a folder ./MyProject/.

TODO: Test for projects requiring a third-party package!

Use case:

I would like to use lake exe cache get Game.lean in NNG and others to automatically only fetch the relevant part of Mathlib.

Open in Gitpod

@joneugster joneugster added t-meta Tactics, attributes or user commands CI Modifies the continuous integration setup or other automation labels Jan 28, 2025
@github-actions

Copy link
Copy Markdown

PR summary e0ae4d44a2

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ getPackageDir!
+ getPackageDir?
- getPackageDir

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@joneugster joneugster added the WIP Work in progress label Jan 28, 2025
@joneugster joneugster changed the title feat: enable partial cache in downstream projects feat(Cache): enable partial cache in downstream projects Jan 28, 2025
@grunweg

grunweg commented Jan 28, 2025

Copy link
Copy Markdown
Contributor

I like the idea! A few weeks ago, I wrote #20568 which does something similar. Maybe we can combine these designs somehow? Or compare them and decide which one is better? (The implementation is certainly different... I haven't thought yet which approach is better.)

With my PR, you could write lake exe cache miniget to download the cache for all .lean in the current directory, excluding .lean. Adding individual files to that wouldn't be hard.

@joneugster

Copy link
Copy Markdown
Member Author

Ah cool, I missed your PR! I like miniget as a concept. I'll see how to combine and make a PR against your PR later/tomorrow.

I'm not sure about traversing the filesystem: I might have scrap files that should not be considered.

@eric-wieser

Copy link
Copy Markdown
Member

I prefer the general approach in this one (we shouldn't need a different spelling for mathlib / non-mathlib), but it would be great if we could make the hacky bits not hacks. Perhaps the path cleanups in #8767 could help remove the hacks here?

@grunweg

grunweg commented Jan 28, 2025

Copy link
Copy Markdown
Contributor

Ah cool, I missed your PR! I like miniget as a concept. I'll see how to combine and make a PR against your PR later/tomorrow.

I'm not sure about traversing the filesystem: I might have scrap files that should not be considered.

I look forward to seeing your PR then!
Scratch files: fair point! Reading a "ProjectName.lean" file and only downloading mathlib imports for these (transitively) could certainly also work... or asking git about the tracked files.

@joneugster

Copy link
Copy Markdown
Member Author

Replaced by #21238

@joneugster joneugster closed this Jan 31, 2025
@YaelDillies
YaelDillies deleted the eugster/cache_downstream branch August 15, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Modifies the continuous integration setup or other automation t-meta Tactics, attributes or user commands WIP Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants