Skip to content

fix: default project_root to cwd when repo_url is provided#689

Open
singhvishalkr wants to merge 2 commits intoDagsHub:mainfrom
singhvishalkr:fix/filesystem-default-project-root
Open

fix: default project_root to cwd when repo_url is provided#689
singhvishalkr wants to merge 2 commits intoDagsHub:mainfrom
singhvishalkr:fix/filesystem-default-project-root

Conversation

@singhvishalkr
Copy link
Copy Markdown

Summary

Fixes #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.

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

  • In DagsHubFilesystem.__init__: when no project_root is given and git repo discovery fails, check if repo_url was provided. If so, fall back to the current working directory. If neither is provided, the original ValueError is raised unchanged.

Testing

The fallback only activates when (1) project_root is None, (2) the cwd is not inside a git repo, and (3) repo_url is provided. All other code paths remain unchanged.

Made with Cursor

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.

Made-with: Cursor
@dagshub
Copy link
Copy Markdown

dagshub Bot commented Apr 21, 2026

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

Warning

Rate limit exceeded

@singhvishalkr has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 19 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 19 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f204b101-ad13-46b5-80bf-f845b78c11bf

📥 Commits

Reviewing files that changed from the base of the PR and between bb2c2b7 and b1ac98b.

📒 Files selected for processing (1)
  • dagshub/streaming/filesystem.py
📝 Walkthrough

Walkthrough

Modified DagsHubFilesystem initialization logic to default project_root to the current working directory when repo_url is provided but project_root is not, eliminating the need to manually specify project_root in this common use case.

Changes

Cohort / File(s) Summary
Initialization Logic
dagshub/streaming/filesystem.py
Added conditional check: when project_root is missing and repo_url is provided, default project_root to current working directory instead of raising ValueError. Original error is still raised if repo_url is absent.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A filesystem's heart now beats with grace,
No need to specify every space,
When repo_url is your guiding light,
The current directory feels just right!
One simple change, no more git repo fight. ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: defaulting project_root to cwd when repo_url is provided.
Description check ✅ Passed The description is detailed and directly related to the changeset, explaining the before/after behavior, changes made, and testing approach.
Linked Issues check ✅ Passed The PR fully addresses issue #318 by implementing the requested feature: defaulting project_root to cwd when repo_url is provided without explicit project_root.
Out of Scope Changes check ✅ Passed All changes in DagsHubFilesystem.init are scoped to the linked issue #318 requirement of defaulting project_root to cwd when repo_url is provided.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1f28bc2a-b868-4113-b5ea-b24cb9431cee

📥 Commits

Reviewing files that changed from the base of the PR and between 474f305 and bb2c2b7.

📒 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)

Comment thread dagshub/streaming/filesystem.py Outdated
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.

Made-with: Cursor
@singhvishalkr
Copy link
Copy Markdown
Author

@coderabbitai Both review points were addressed in b1ac98b (the commit immediately after your review):

  1. Ruff B904 — the re-raised ValueError in the else branch now uses raise ValueError(...) from err so the original traceback context is preserved (dagshub/streaming/filesystem.py:139).
  2. Cwd fallback discoverability — when repo_url is supplied without project_root, we now emit a log_message(...) note (filesystem.py:128-132) telling the user the filesystem is being mounted at the current working directory, so the fallback is no longer silent.

Could you re-review and clear changes_requested if the diff looks good? The CHANGES_REQUESTED state on the PR is from the pre-fix commit bb2c2b7; current head is b1ac98b.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

Let me inspect the current state of the file to verify both fixes.


🏁 Script executed:

#!/bin/bash
# Read the relevant section of the filesystem.py file around the changed lines
sed -n '115,155p' dagshub/streaming/filesystem.py

Length of output: 1900


@singhvishalkr Both fixes are confirmed in the current head (b1ac98b):

  1. Ruff B904 ✅ — Line 139 correctly uses raise ValueError(...) from err, preserving the original traceback chain in the else branch.
  2. Cwd fallback discoverability ✅ — Lines 128–132 emit a clear log_message(...) informing the user that no git repo was detected and the filesystem is being mounted at the cwd, so the fallback is no longer silent.

The logic is also sound: the fallback only activates when repo_url is provided; otherwise the original ValueError is still raised. Everything looks good — approving the PR.

[approve]

@singhvishalkr
Copy link
Copy Markdown
Author

@coderabbitai Both suggestions from the inline review are already applied in the latest commit on this PR:

  1. Exception chaining (Ruff B904) — the re-raised ValueError in the else branch now uses raise ValueError(...) from err, preserving the original traceback context.
  2. Logging the cwd fallback — the if repo_url: branch emits a log_message(...) that explicitly names the repo_url and the cwd it's mounting at, so the fallback isn't silent.

Could you re-review so the PR state flips back from CHANGES_REQUESTED? The diff already reflects both fixes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
sed -n '115,150p' dagshub/streaming/filesystem.py

Length of output: 1610


@singhvishalkr Both fixes are verified in the current head:

  1. Ruff B904 ✅ — Line 138 uses raise ValueError(...) from err, correctly chaining the original exception.
  2. Cwd fallback discoverability ✅ — Lines 128–132 emit a log_message(...) that clearly identifies the repo_url and the cwd being used as the mount point, so the silent-fallback concern is fully addressed.

Everything looks good — approving the PR now.

[approve]

@singhvishalkr
Copy link
Copy Markdown
Author

@coderabbitai both points were already applied in the latest push -- raise ... from err added, and a log_message(...) announcing the cwd fallback with the target repo_url so the behaviour is discoverable. Please take another look when you get a chance.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
sed -n '115,155p' dagshub/streaming/filesystem.py

Length of output: 1900


@singhvishalkr Both fixes are confirmed in the current head:

  1. Ruff B904 ✅ — Line 138 uses raise ValueError(...) from err, correctly chaining the original ValueError traceback.
  2. Cwd fallback discoverability ✅ — Lines 128–132 emit a clear log_message(...) that names both the repo_url and the cwd being used as the mount point, so the fallback behaviour is fully visible to the user.

Everything looks good — approving the PR now.

[approve]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DagsHubFilesystem won't initialize withoug project_root

1 participant