Skip to content

Commit bb2c2b7

Browse files
committed
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. Made-with: Cursor
1 parent 474f305 commit bb2c2b7

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

dagshub/streaming/filesystem.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,15 @@ def __init__(
123123
try:
124124
self.project_root = get_project_root(Path(os.path.abspath(".")))
125125
except ValueError:
126-
raise ValueError(
127-
"Could not find a git repo. Either run the function inside of a git repo, "
128-
"specify `project_root` with the path to a cloned DagsHub repository, "
129-
"or specify `repo_url` (url of repo on DagsHub) and "
130-
"`project_root` (path to the folder where to mount the filesystem) arguments"
131-
)
126+
if repo_url:
127+
self.project_root = Path(os.path.abspath("."))
128+
else:
129+
raise ValueError(
130+
"Could not find a git repo. Either run the function inside of a git repo, "
131+
"specify `project_root` with the path to a cloned DagsHub repository, "
132+
"or specify `repo_url` (url of repo on DagsHub) and "
133+
"`project_root` (path to the folder where to mount the filesystem) arguments"
134+
)
132135

133136
else:
134137
self.project_root = Path(os.path.abspath(project_root))

0 commit comments

Comments
 (0)