[BUG] hub.copy does not support pathlib.Path arguments
See original GitHub issue🐛🐛 Bug Report
hub.copy does not seem to play well with pathlib.Path. Since pathlib.Path seems to be the up and coming new standard for Python3 paths, I think it would greatly reduce friction and increase compatibility if it was supported.
⚗️ Current Behavior
Currently, the hub.copy method’s signature looks like:
@staticmethod
def copy(
src: Union[str, Dataset],
dest: str,
overwrite: bool = False,
src_creds=None,
src_token=None,
dest_creds=None,
dest_token=None,
num_workers: int = 0,
scheduler="threaded",
progressbar=True,
):
For src and dest we should include pathlib.Path as a potential type. One can easily convert a pathlib.Path to a string path if necessary by using
path_to_string = lambda x: os.fspath(x.resolve())
⚙️ Environment
Python
version(s): python 3.8.12 ha38a3c6_3_cpython conda-forgOS
: [e.g. Ubuntu 20.04]IDE
: [PyCharm]Packages
: [Pytorch-latest
]
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Parents objects in pathlib.Path don't support slices as __ ...
If it is deemed a bug which needs to be fixed, I've gone ahead and attached the PR to fix it. CLA signage...
Read more >Copy file with pathlib in Python - Stack Overflow
copy () not working is that you are not using the latest Python, Python 3.6 shutil.copy() can handle Path objects (or subclasses thereof)....
Read more >pathlib — Object-oriented filesystem paths — Python 3.11.1 ...
Source code: Lib/pathlib.py This module offers classes representing filesystem paths with semantics appropriate for different operating systems.
Read more >Why Python Pathlib Excels at Handling Files - Built In
The Python Pathlib module offers better performance over the OS module when it comes to handling files. Here's why.
Read more >Python pathlib Cookbook: 57+ Examples to Master It (2022)
A mega tutorial to learn by example the idiomatic way to work with paths in Python 3 using the pathlib module.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@dhiganthrao we have a PR up: https://github.com/activeloopai/Hub/pull/1651
Hi @AntreasAntoniou thanks for raising the issue. Will let you know as soon as this is fixed.