Skip to content

feat(Cache): Allow arguments of the form Mathlib.Data.+ which correspond to a folder but not a file#21838

Closed
joneugster wants to merge 2 commits intomasterfrom
eugster/cache_pseudo_module_args
Closed

feat(Cache): Allow arguments of the form Mathlib.Data.+ which correspond to a folder but not a file#21838
joneugster wants to merge 2 commits intomasterfrom
eugster/cache_pseudo_module_args

Conversation

@joneugster
Copy link
Copy Markdown
Contributor

@joneugster joneugster commented Feb 13, 2025

Extend lake exe cache get to get cache for all files inside a specified folder, as well as the dependencies of these files.

his can be used as lake exe cache get Mathlib/Data/ or lake exe cache get Mathlib.Data.+. There is also the syntax lake exe cache get Mathlib.Data.* which means either file or folder.


Open in Gitpod

@mergify
Copy link
Copy Markdown

mergify bot commented Feb 13, 2025

⚠️ The sha of the head commit of this PR conflicts with #21834. Mergify cannot evaluate rules on this PR. ⚠️

@joneugster joneugster changed the base branch from master to eugster/cache_use_mod_instead_of_path February 13, 2025 17:59
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 13, 2025

PR summary 88bb6d226a

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

No declarations were harmed in the making of this PR! 🐙

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 scripts/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 blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) t-meta Tactics, attributes or user commands CI Modifies the continuous integration setup or other automation labels Feb 13, 2025
@joneugster joneugster force-pushed the eugster/cache_pseudo_module_args branch from 8c89c93 to 053bfae Compare February 13, 2025 18:12
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 13, 2025
@github-actions github-actions bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 14, 2025
@joneugster joneugster changed the base branch from eugster/cache_use_mod_instead_of_path to master February 24, 2025 16:23
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 27, 2025
@github-actions github-actions bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 28, 2025
@joneugster
Copy link
Copy Markdown
Contributor Author

Note to myself: check if something like the following is needed:

  -- TODO: This could be `(argₛ : FilePath).normalize` if the comment there got addressed
  -- (which says "TODO: normalize `a/`, `a//b`, etc.")
  let arg : FilePath := System.mkFilePath <| (argₛ : FilePath).components.filter (· != "")

@joneugster joneugster changed the base branch from master to eugster/cache_use_mod_instead_of_path March 7, 2025 09:29
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Mar 31, 2025
Comment thread Cache/IO.lean Outdated
Comment thread Cache/IO.lean Outdated
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Apr 1, 2025
@joneugster joneugster changed the base branch from eugster/cache_use_mod_instead_of_path to master April 1, 2025 10:17
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Apr 3, 2025
@mathlib4-dependent-issues-bot
Copy link
Copy Markdown
Collaborator

@joneugster joneugster added the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 4, 2025
@joneugster
Copy link
Copy Markdown
Contributor Author

I've tested this with two lake new CacheTest math.lean, one setting mathlib to this branch, one setting it to a local copy at ../../mathlib4. In both cases lake exe cache get Mathlib.Data seemed to work just fine.

@joneugster joneugster removed the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 4, 2025
Comment thread Cache/IO.lean Outdated

1. `Mathlib.Algebra.Fields.Basic`: there exists such a Lean file
2. `Mathlib.Algebra.Fields`: no Lean file exists but a folder (TODO)
2. `Mathlib.Algebra.Fields`: no Lean file exists but a folder
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should match lake here, and use .+ syntax. Otherwise we're stuck if both Foo/Bar.lean and Foo/Bar/Baz.lean exist.

We could also support .* syntax, which would mean "load both of the above", though of course the user has to remember to escape it in some shells.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented both your suggestions

@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label May 22, 2025
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 13, 2025
@leanprover-community-bot-assistant
Copy link
Copy Markdown
Collaborator

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jan 31, 2026
@joneugster joneugster removed the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 31, 2026
@joneugster joneugster changed the title feat(Cache): Allow arguments of the form Mathlib.Data which correspond to a folder but not a file feat(Cache): Allow arguments of the form Mathlib.Data.+ which correspond to a folder but not a file Jan 31, 2026
Comment thread Cache/IO.lean
else
-- provided a module
let mod := argₛ.toName
-- user might provide `.*` or `.+` to include folders
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this shoudl be parsed with Lake.Glob.ofString??

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and then use glob.forEachModuleIn)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. However, if I understand things correctly, I cannot import Lake.Glob.ofString? since Cache is not a module yet and Lake.Glob.ofString? is not public.

I could offer to create a follow-up PR (once this PR has been merged) to convert Cache into a module and incorporate this suggestion there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added this as TODO comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use open private from batteries I think,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented your suggestion 👍

@joneugster joneugster force-pushed the eugster/cache_pseudo_module_args branch from 677ebdc to 068bac4 Compare February 15, 2026 00:35
@joneugster
Copy link
Copy Markdown
Contributor Author

This PR has been migrated to a fork-based workflow: #35414

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 migrated-to-fork t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants