question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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-forg
  • OS: [e.g. Ubuntu 20.04]
  • IDE: [PyCharm]
  • Packages: [ Pytorch-latest]

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
farizrahman4ucommented, May 5, 2022
1reaction
tatevikhcommented, Apr 19, 2022

Hi @AntreasAntoniou thanks for raising the issue. Will let you know as soon as this is fixed.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found