Skip to content
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

AbstractFileSystem.exists() catches every exception #1379

Open
tfelbr opened this issue Sep 28, 2023 · 1 comment
Open

AbstractFileSystem.exists() catches every exception #1379

tfelbr opened this issue Sep 28, 2023 · 1 comment

Comments

@tfelbr
Copy link
Contributor

tfelbr commented Sep 28, 2023

Hello,

I would like to kindly request a change in the implementation of AbstractFileSystem.exists(), as it currently catches every exception that might get thrown without any notice. An in my opinion better approach would be something like this:

def exists(self, path, **kwargs):
    try:
        self.info(path, **kwargs)
        return True
    except FileNotFoundError:
        return False
    except Exception as e:
        logging.warning(e)
        return False

This would preserve the current compatibility while still showing thrown exceptions as a warning.

@martindurant
Copy link
Member

Warnings are only really useful if they imply a user can meaningfully act on them - which would not be the case here. Perhaps a logging call would be apropriate.

Note that it is not, in general, possible to know whether a file cannot be reached right now or if indeed it doesn't exist, especially with backends that don't have formal listing capabilities (e.g., HTTP). That means that we must interpret any number of IO and parsing-related exceptions as non-existence, in the sense that the path points to content we cannot read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants