fix: remove erroneous lstrip("/") in FileLock path construction#2187
Open
yangrq1018 wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: remove erroneous lstrip("/") in FileLock path construction#2187yangrq1018 wants to merge 1 commit intomicrosoft:mainfrom
yangrq1018 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
The lstrip("/") on pr.path was introduced in a0cef03 as part of a bulk
lint/CI cleanup and inadvertently turned absolute file:// URIs into
relative paths, causing mlruns/filelock to be created under a spurious
home/<user>/... directory tree relative to cwd.
Restoring the original behavior where os.path.join with an empty netloc
and an absolute pr.path naturally produces the correct absolute path.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lstrip("/")onpr.pathinMLflowExpManager._get_or_create_expturns absolutefile://URIs into relative paths, causingmlruns/filelockto be created under a spurioushome/<user>/<cwd>/...directory tree relative to the working directory.qlib/workflow/expm.py(line 236),urlparseon a localfile:///...URI producesnetloc=""andpath="/home/.../mlruns". The.lstrip("/")strips the leading/, soos.path.join("", "home/.../mlruns", "filelock")yields a relative path instead of the correct absolute path.pr.pathwithout stripping.Fix
Remove the
.lstrip("/")call.os.path.join("", "/absolute/path", "filelock")already produces the correct absolute path whennetlocis empty.Related note
A similar misuse of
lstripexists inqlib/workflow/recorder.py(lines 321–323), where.lstrip("file:")is used to strip a URI prefix. Sincestr.lstripstrips characters (not a prefix), this can over-strip in edge cases. The correct approach would bestr.removeprefix("file:")(Python 3.9+). This is not addressed in this PR.🤖 Generated with Claude Code