Skip to content

[Merged by Bors] - refactor(Cache): rewrite getFileImports to use search path and return module names and source file location - #21815

Closed
joneugster wants to merge 35 commits into
masterfrom
eugster/cache_FileImports
Closed

joneugster wants to merge 35 commits into
masterfrom
eugster/cache_FileImports

Conversation

@joneugster

@joneugster joneugster commented Feb 13, 2025 •

Copy link
Copy Markdown
Member

Rewrite getFileImports to not use getPackageDirs anymore.

Additionally, getFileImports now returns module names like Mathlib.Data.Set.Basic and resolved .lean file locations instead of non-resolved file names (Mathlib/Data/Set/Basic.lean) like it used to. This is in preparation for #21238.

This PR should not change any behaviour in how cache works.


Open in Gitpod

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

github-actions Bot commented Feb 13, 2025 •

Copy link
Copy Markdown

PR summary a387980404

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ isPartOfMathlibCache
- PackageDirs
- getPackageDirs

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 title refactor(Cache): rewrite getFileImports to use search path and return modul names and source file location refactor(Cache): rewrite getFileImports to use search path and return module names and source file location Feb 13, 2025

@grunweg grunweg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Superficially, this looks fine - but I am really not confident about any intricacies with e.g. searchPath, or findLean subtleties.

Comment thread Cache/Hashing.lean Resolved
Comment thread Cache/IO.lean Resolved
Comment thread Cache/Hashing.lean
def getFileImports (content : String) (fileName : String := "") :
CacheM <| Array (Name × FilePath) := do
let sp := (← read).srcSearchPath
let fileImports : Array Import ← Lean.parseImports' content fileName

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.

One note to explain things: the main line of code in parseImports' is exactly the first line deleted:

def parseImports' (input : String) (fileName : String) : IO (Array Lean.Import) := do
  let s := ParseImports.main input (ParseImports.whitespace input {}) -- this one!
  match s.error? with
  | none => return s.imports
  | some err => throw <| IO.userError s!"{fileName}: {err}"

Comment thread Cache/Hashing.lean Resolved
Comment thread Cache/Hashing.lean Resolved
Comment thread Cache/Hashing.lean Resolved
Comment thread Cache/Hashing.lean Resolved
Comment thread Cache/IO.lean Resolved
@eric-wieser

Copy link
Copy Markdown
Member

bors merge

Thanks!

@ghost ghost added the ready-to-merge This PR has been sent to bors. label Feb 27, 2025
mathlib-bors Bot pushed a commit that referenced this pull request Feb 27, 2025
…rn module names and source file location (#21815)

Rewrite `getFileImports` to not use `getPackageDirs` anymore.

Additionally, `getFileImports` now returns module names like `Mathlib.Data.Set.Basic` and resolved `.lean` file locations instead of non-resolved file names (`Mathlib/Data/Set/Basic.lean`) like it used to. This is in preparation for #21238.

This PR should not change any behaviour in how `cache` works.



Co-authored-by: Jon Eugster <[email protected]>
@mathlib-bors

mathlib-bors Bot commented Feb 27, 2025

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title refactor(Cache): rewrite getFileImports to use search path and return module names and source file location [Merged by Bors] - refactor(Cache): rewrite getFileImports to use search path and return module names and source file location Feb 27, 2025
@mathlib-bors mathlib-bors Bot closed this Feb 27, 2025
@mathlib-bors
mathlib-bors Bot deleted the eugster/cache_FileImports branch February 27, 2025 15:06
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 ready-to-merge This PR has been sent to bors. t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants