fix: default project_root to cwd when repo_url is provided#689
fix: default project_root to cwd when repo_url is provided#689singhvishalkr wants to merge 3 commits into
Conversation
Fixes DagsHub#318 When DagsHubFilesystem is created with a repo_url but without project_root, and the current directory is not inside a git repo, the constructor now defaults project_root to the current working directory instead of raising a ValueError.
📝 WalkthroughWalkthroughInitializer now uses current working directory as project_root when ChangesInitialization Logic
sequenceDiagram
participant DagsHubFilesystem
participant get_project_root
participant CWD
DagsHubFilesystem->>get_project_root: attempt auto-detect project_root
get_project_root-->>DagsHubFilesystem: raises ValueError
DagsHubFilesystem->>CWD: if repo_url provided -> use os.path.abspath(".") as project_root
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1f28bc2a-b868-4113-b5ea-b24cb9431cee
📒 Files selected for processing (1)
dagshub/streaming/filesystem.py
📜 Review details
🧰 Additional context used
🪛 Ruff (0.15.10)
dagshub/streaming/filesystem.py
[warning] 129-134: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling
(B904)
Address CodeRabbit review: use raise...from err to preserve traceback context (Ruff B904), and log a message when defaulting project_root to cwd so behavior is discoverable.
|
@coderabbitai Both review points were addressed in
Could you re-review and clear |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainLet me inspect the current state of the file to verify both fixes. 🏁 Script executed: Length of output: 1900
The logic is also sound: the fallback only activates when [approve] |
|
Could you re-review so the PR state flips back from |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 1610
Everything looks good — approving the PR now. [approve] |
|
@coderabbitai both points were already applied in the latest push -- |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 1900
Everything looks good — approving the PR now. [approve] |
|
@coderabbitai please re-review; the branch uses |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 1901
Everything looks good — approving the PR now. [approve] |
|
Current head already chains the second @coderabbitai please leave a fresh review when convenient so the stale |
🧩 Analysis chain🏁 Script executed: Length of output: 1901
The logic is also correct end-to-end: the cwd fallback only activates when ✅ Actions performedFull review triggered. |
…oject_root Align message with cwd fallback: repo_url alone suffices; project_root defaults to cwd. Keeps raise ... from err for B904.
|
Applied the suggested wording in Pushed: singhvishalkr@9775fea on branch |
|
I checked the current head and the fallback to cwd when repo_url is provided is already in place. No extra code change is needed here from my side; please take another look at the current branch. |
9775fea to
604dcbd
Compare
Summary
Fixes #318
When
DagsHubFilesystemis created with arepo_urlbut withoutproject_root, and the current directory is not inside a git repo, the constructor now defaultsproject_rootto the current working directory instead of raising aValueError.Before
`python
fs = DagsHubFilesystem(repo_url=url)
ValueError: Could not find a git repo...
``n
After
`python
fs = DagsHubFilesystem(repo_url=url)
Works -- project_root defaults to cwd
``n
Changes
DagsHubFilesystem.__init__: when noproject_rootis given and git repo discovery fails, check ifrepo_urlwas provided. If so, fall back to the current working directory. If neither is provided, the originalValueErroris raised unchanged.Testing
The fallback only activates when (1)
project_rootisNone, (2) the cwd is not inside a git repo, and (3)repo_urlis provided. All other code paths remain unchanged.