diff --git a/dandi/utils.py b/dandi/utils.py index 23ec7e4c1..be6d3986f 100644 --- a/dandi/utils.py +++ b/dandi/utils.py @@ -408,14 +408,20 @@ def find_parent_directory_containing( ) -> Optional[Path]: """Find a directory, on the path to 'path' containing filename - if no 'path' - path from cwd - Returns None if no such found, pathlib's Path to the directory if found + if no 'path' - path from cwd. If 'path' is not absolute, absolute path + is taken assuming relative to cwd. + + Returns None if no such found, pathlib's Path (absolute) to the directory + if found. """ if not path: path = Path.cwd() else: # assure pathlib object path = Path(path) + if not path.is_absolute(): + path = path.absolute() + while True: if (path / filename).exists(): return path