From 7b2fecfb2b97c444ae1fc3ab303d3fb23128e3df Mon Sep 17 00:00:00 2001 From: Vishal Kumar Singh Date: Tue, 21 Apr 2026 13:32:07 +0530 Subject: [PATCH 1/3] fix: default project_root to cwd when repo_url is provided 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. --- dagshub/streaming/filesystem.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dagshub/streaming/filesystem.py b/dagshub/streaming/filesystem.py index 636d81c3..572a9f8b 100644 --- a/dagshub/streaming/filesystem.py +++ b/dagshub/streaming/filesystem.py @@ -123,12 +123,15 @@ def __init__( try: self.project_root = get_project_root(Path(os.path.abspath("."))) except ValueError: - raise ValueError( - "Could not find a git repo. Either run the function inside of a git repo, " - "specify `project_root` with the path to a cloned DagsHub repository, " - "or specify `repo_url` (url of repo on DagsHub) and " - "`project_root` (path to the folder where to mount the filesystem) arguments" - ) + if repo_url: + self.project_root = Path(os.path.abspath(".")) + else: + raise ValueError( + "Could not find a git repo. Either run the function inside of a git repo, " + "specify `project_root` with the path to a cloned DagsHub repository, " + "or specify `repo_url` (url of repo on DagsHub) and " + "`project_root` (path to the folder where to mount the filesystem) arguments" + ) else: self.project_root = Path(os.path.abspath(project_root)) From fb426d210a37c6dfdfdab698954d6c6ed9f34e87 Mon Sep 17 00:00:00 2001 From: Vishal Kumar Singh Date: Tue, 21 Apr 2026 14:36:20 +0530 Subject: [PATCH 2/3] fix: chain ValueError and log cwd fallback 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. --- dagshub/streaming/filesystem.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dagshub/streaming/filesystem.py b/dagshub/streaming/filesystem.py index 572a9f8b..822df0df 100644 --- a/dagshub/streaming/filesystem.py +++ b/dagshub/streaming/filesystem.py @@ -122,16 +122,21 @@ def __init__( if not project_root: try: self.project_root = get_project_root(Path(os.path.abspath("."))) - except ValueError: + except ValueError as err: if repo_url: self.project_root = Path(os.path.abspath(".")) + log_message( + f"No git repo detected; mounting DagsHub filesystem for {repo_url} at " + f"current working directory: {self.project_root}", + logger, + ) else: raise ValueError( "Could not find a git repo. Either run the function inside of a git repo, " "specify `project_root` with the path to a cloned DagsHub repository, " "or specify `repo_url` (url of repo on DagsHub) and " "`project_root` (path to the folder where to mount the filesystem) arguments" - ) + ) from err else: self.project_root = Path(os.path.abspath(project_root)) From 604dcbd5592aede088115ba344c4338430f9c091 Mon Sep 17 00:00:00 2001 From: Vishal Kumar Singh Date: Tue, 19 May 2026 21:01:07 +0530 Subject: [PATCH 3/3] fix(filesystem): clarify ValueError when repo_url implies optional project_root Align message with cwd fallback: repo_url alone suffices; project_root defaults to cwd. Keeps raise ... from err for B904. --- dagshub/streaming/filesystem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dagshub/streaming/filesystem.py b/dagshub/streaming/filesystem.py index 822df0df..4c868cf7 100644 --- a/dagshub/streaming/filesystem.py +++ b/dagshub/streaming/filesystem.py @@ -134,8 +134,8 @@ def __init__( raise ValueError( "Could not find a git repo. Either run the function inside of a git repo, " "specify `project_root` with the path to a cloned DagsHub repository, " - "or specify `repo_url` (url of repo on DagsHub) and " - "`project_root` (path to the folder where to mount the filesystem) arguments" + "or specify `repo_url` (url of repo on DagsHub); " + "optionally provide `project_root` (defaults to current working directory)" ) from err else: