-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infra: allow for multiple install_hooks() running at the same time #448
base: master
Are you sure you want to change the base?
Conversation
…interesting cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review
def parse_path(self, file_path: Union[str, bytes, PathLike, "DagshubPath"]) -> Tuple[Path, Optional[Path], Path]: | ||
if isinstance(file_path, DagshubPath): | ||
self.is_binary_path_requested = file_path.is_binary_path_requested | ||
if file_path.fs != self.fs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the fs is the same, then we're just creating a copy of the input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
dagshub/streaming/dataclasses.py
Outdated
return file_path.absolute_path, file_path.relative_path, file_path.original_path | ||
if isinstance(file_path, bytes): | ||
file_path = os.fsdecode(file_path) | ||
orig_path = Path(file_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't want to save the original bytes representation of the file_path
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to have the og requested path as a Path object because it's more convenient to use.
Having the original path be both a Path object and an additional PathType
would be confusing w.r.t. "which one should I be using", so I kept just the single thing I actually care about in it, which is whether the requested path was bytes or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the usages, and it's probably alright to actually just carry over the original path, because I'm not working with it that much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to carry over as-is
if isinstance(file_path, bytes): | ||
file_path = os.fsdecode(file_path) | ||
orig_path = Path(file_path) | ||
abspath = Path(os.path.abspath(file_path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should always be relative to PWD ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on the question? Didn't understand it
abspath = Path(os.path.abspath(file_path)) | ||
try: | ||
relpath = abspath.relative_to(os.path.abspath(self.fs.project_root)) | ||
if str(relpath).startswith("<"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this condition mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly don't remember.
Maybe something relating to a different drive, but the docs say that relative_to
will throw an error if they are on different drives altogether.
Probably an old leftover, so maybe should delete it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a commit where it got added: 9174106
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's some IPython magic, then it's probably better to leave it, but could be useful to know how to trigger it at least 🤔
# Conflicts: # requirements-dev.txt
Infra changes:
DagsHubFilesystem
into two classes:DagsHubFilesystem
that does the file access stuff, andHookRouter
that runs the hook infra + routes the functions to the correct DHFilesystem.Functional changes:
install_hooks()
can be running at the same time and any file access function will be routed to the correct filesystem.uninstall_hooks()
now hasfs
andpath
arguments that remove specific filesystems. By default all filesystems will be removedget_mounted_filesystems
function that returns a list of tuples of(<full mount path>, <fs object>)
Shouldn't be anything backwards-incompatible from a user API perspective