Skip to content

feat(Cache): add file Cache.Lean with helper functions and cleanup checkForToolchainMismatch - #21663

Closed
joneugster wants to merge 10 commits into
masterfrom
eugster/cache_cleanup_2
Closed

joneugster wants to merge 10 commits into
masterfrom
eugster/cache_cleanup_2

Conversation

@joneugster

@joneugster joneugster commented Feb 10, 2025 •

Copy link
Copy Markdown
Member

Move helper functions to Cache.Lean and add FilePath.clean


Note: a future PR will remove isMathlibRoot completely, so we do the first step here.

Open in Gitpod

@joneugster joneugster added the t-meta Tactics, attributes or user commands label Feb 10, 2025
@github-actions

github-actions Bot commented Feb 10, 2025 •

Copy link
Copy Markdown

PR summary 0030317f89

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ Lean.Name.fromComponents
+ clean
+ withoutParent
- System.FilePath.withoutParent

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 changed the base branch from master to eugster/cache_cleanup_1 February 10, 2025 15:13
@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 Feb 10, 2025
@joneugster joneugster added WIP Work in progress and removed WIP Work in progress labels Feb 10, 2025
Comment thread Cache/Lean.lean Outdated
Comment on lines +69 to +81
-- unit tests for `System.FilePath.clean`
#guard FilePath.clean "" == ""
#guard FilePath.clean "." == ""
#guard FilePath.clean ("." / ".") == ""
#guard FilePath.clean ("." / "") == ""
#guard FilePath.clean ("." / "A") == "A"
#guard FilePath.clean ("." / "..") == ".."
#guard FilePath.clean (".." / "..") == (".." / "..")
#guard FilePath.clean ("A" / ".." / "B") == "B"
#guard FilePath.clean ("A" / "." / "B") == ("A" / "B")
#guard FilePath.clean ("A" / "B" / "C" / ".." / ".." / ".." / "..") == ".."
#guard FilePath.clean ("A" / "B" / "C" / ".." / ".." / "." / ".." / "..") == ".."
#guard FilePath.clean ("A" / "B" / "C" / ".." / ".." / ".." / "D") == "D"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is there a better place to put tests?

@joneugster
joneugster force-pushed the eugster/cache_cleanup_2 branch from a7ade54 to ef94142 Compare February 11, 2025 09:00
@joneugster
joneugster changed the base branch from eugster/cache_cleanup_1 to master February 11, 2025 09:01
@joneugster joneugster removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Feb 11, 2025
@joneugster joneugster changed the title feat(Cache): add helper functions for future refactor feat(Cache): add file Cache.Lean with helper functions Feb 11, 2025
Comment thread Cache/Lean.lean Resolved
@joneugster joneugster changed the title feat(Cache): add file Cache.Lean with helper functions feat(Cache): add file Cache.Lean with helper functions and cleanup checkForToolchainMismatch Feb 11, 2025
Comment thread Cache/Lean.lean Outdated
Comment on lines +55 to +57
#guard FilePath.clean "." == ""
#guard FilePath.clean ("." / ".") == ""
#guard FilePath.clean ("." / "") == ""

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.

These make me unconfortable; I'd expect the first two to return ., and the second one seems nonsensical since "" isn't a legal path component

@joneugster joneugster Feb 11, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

FilePath itself makes me uncomfortable:

#eval mkFilePath [] |>.components    -- result: [""]

But I'll change it, using . is probably the better convention

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

and the second one seems nonsensical since "" isn't a legal path component

As far as I understand the current implementation of FilePath, "" and "." are considered equivalent and "" might appear in a (uncleaned) path like ././A//B/./C//X.lean

Comment thread Cache/Lean.lean
| "" :: path => go path
| c :: path => c :: go path

-- unit tests for `System.FilePath.clean`

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.

Can you add a test for this POSIX spec:

A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash.

That is, //foo/bar///baz should normalize to //foo/bar/baz.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done.

Comment thread Cache/Lean.lean Outdated
#guard FilePath.clean ("." / ".") == "."
#guard FilePath.clean ("." / "") == "."
#guard FilePath.clean ("." / "A") == "A"
#guard FilePath.clean ("" / "..") == ".."

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.

Haven't you incorrectly replaced /.. with .. here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Next attempt. Would you mind having a look if this implementation is better. It should now treat leading / and // better.

I haven't yet thought about whether there is anything windows-specific that needs to be considered...

@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 Feb 13, 2025
@mathlib4-dependent-issues-bot

Copy link
Copy Markdown

This PR/issue depends on:

@joneugster joneugster added WIP Work in progress awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. labels Feb 13, 2025
@joneugster

Copy link
Copy Markdown
Member Author

Update: Now I had an idea to avoid this completely. I'll add awaiting-author and WIP and I'd put this back on the queue if still needed.

@joneugster joneugster closed this Feb 13, 2025
@YaelDillies
YaelDillies deleted the eugster/cache_cleanup_2 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

awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. 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 WIP Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants