home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

8 rows where issue = 894125618 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: reactions, created_at (date), updated_at (date)

user 6

  • shoyer 2
  • pont-us 2
  • alexamici 1
  • ryan-williams 1
  • mathause 1
  • aurghs 1

author_association 3

  • MEMBER 4
  • NONE 3
  • COLLABORATOR 1

issue 1

  • xarray 0.18.0 raises ValueError, not FileNotFoundError, when opening a non-existent file · 8 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
1254067180 https://github.com/pydata/xarray/issues/5329#issuecomment-1254067180 https://api.github.com/repos/pydata/xarray/issues/5329 IC_kwDOAMm_X85Kv4vs ryan-williams 465045 2022-09-21T18:19:57Z 2022-09-21T18:19:57Z NONE

I just accidentally tried to open myfile.h5.h5 (I meant to open myfile.h5) and was confused about the ValueError.

  • Should .h5 be added to the list of extensions that map to the NetCDF engine?
  • Could the error message for the ValueError (or any of the alternate exception classes discussed above) include text suggesting that an incorrect file path (or other URL?) could be the culprit?
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray 0.18.0 raises ValueError, not FileNotFoundError, when opening a non-existent file 894125618
843895606 https://github.com/pydata/xarray/issues/5329#issuecomment-843895606 https://api.github.com/repos/pydata/xarray/issues/5329 MDEyOklzc3VlQ29tbWVudDg0Mzg5NTYwNg== pont-us 9010180 2021-05-19T08:54:57Z 2021-05-19T08:54:57Z NONE

I think it is OK to add a dedicated xarray.EngineGuessingError, but I'd not try anything more complex and in general invite users to pass engine explicitly.

I'm reluctantly inclined to agree. (But "reluctantly" only because this means that we may have a lot of xcube code to check and update now.) If the engine is explicitly specified, the question of which exceptions to expect becomes a lot easier to handle, since it's now just between the caller and the engine.

Probably the open_dataset documentation should actively discourage reliance on engine guessing for anything but interactive use, and point out that callers need to check the documentation for the selected engine to determine which exceptions (other than EngineGuessingError) might be thrown.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray 0.18.0 raises ValueError, not FileNotFoundError, when opening a non-existent file 894125618
843824599 https://github.com/pydata/xarray/issues/5329#issuecomment-843824599 https://api.github.com/repos/pydata/xarray/issues/5329 MDEyOklzc3VlQ29tbWVudDg0MzgyNDU5OQ== alexamici 226037 2021-05-19T07:28:03Z 2021-05-19T07:28:03Z MEMBER

@shoyer and @pont-us my take is that engine=None is mostly and feature to help new users experiment with xarray. The logic for autodetecting the engine has always been extremely fragile and the result depends on what packages are installed on the system.

I think it is OK to add a dedicated xarray.EngineGuessingError, but I'd not try anything more complex and in general invite users to pass engine explicitly.

Examples of strings that identify a dataset when the right backend is installed, but are not paths and the FileNotFoundError would sound confusing: - /vsizip/my.zip/my.tif with rioxarray - https://myhost/myfile.nc with netcdf4 and others

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray 0.18.0 raises ValueError, not FileNotFoundError, when opening a non-existent file 894125618
843757305 https://github.com/pydata/xarray/issues/5329#issuecomment-843757305 https://api.github.com/repos/pydata/xarray/issues/5329 MDEyOklzc3VlQ29tbWVudDg0Mzc1NzMwNQ== shoyer 1217238 2021-05-19T05:28:04Z 2021-05-19T05:28:04Z MEMBER

Actually, thinking about this a little more, you should get NoMatchingEngineError if you try to open a text file with Xarray.

But if you pass in a local filesystem path and try to open an entirely non-existent file, then FileNotFoundError would be appropriate.

In theory, one could write an open_dataset backend that interprets a local path in an arbitrary way, but that is not the intent of open_dataset, which is intended to handle things like files/directories, other URIs and file contents. If you want to interpret strings very differently you should write a new function for opening.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray 0.18.0 raises ValueError, not FileNotFoundError, when opening a non-existent file 894125618
843752655 https://github.com/pydata/xarray/issues/5329#issuecomment-843752655 https://api.github.com/repos/pydata/xarray/issues/5329 MDEyOklzc3VlQ29tbWVudDg0Mzc1MjY1NQ== shoyer 1217238 2021-05-19T05:15:39Z 2021-05-19T05:15:39Z MEMBER

Ouch! I agree this is annoying. And yes, the open_dataset docs definitely need updating.

The general rule is that ValueError is too generic of an exception for it to be appropriate to catch in user code. So indeed, if you need to catch that error something has gone wrong :).

Given this use case, perhaps we should have a special exception type here, something like xarray.NoMatchingEngineError.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray 0.18.0 raises ValueError, not FileNotFoundError, when opening a non-existent file 894125618
843138842 https://github.com/pydata/xarray/issues/5329#issuecomment-843138842 https://api.github.com/repos/pydata/xarray/issues/5329 MDEyOklzc3VlQ29tbWVudDg0MzEzODg0Mg== pont-us 9010180 2021-05-18T12:43:55Z 2021-05-18T13:40:41Z NONE

@aurghs Point taken, but in that case the xarray.open_dataset documentation probably needs updating: currently it says ‘Strings and Path objects are interpreted as a path to a netCDF file or an OpenDAP URL and opened with python-netCDF4, unless the filename ends with .gz…’. In particular I find the behaviour with Path confusing: this type is unambiguously a filesystem path, but still results in a ValueError rather than FileNotFoundError. And in Python 3, str and bytes are distinct (though I suppose a str might still be a URL rather than a file).

In principle, though, I'd be OK with any selection of potential exceptions, as long as they're documented. The current practical problem for us (the xcube developers) is that the behaviour change from 0.17 to 0.18 means that we now have to audit our existing codebases for potential uncaught ValueErrors.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray 0.18.0 raises ValueError, not FileNotFoundError, when opening a non-existent file 894125618
843101733 https://github.com/pydata/xarray/issues/5329#issuecomment-843101733 https://api.github.com/repos/pydata/xarray/issues/5329 MDEyOklzc3VlQ29tbWVudDg0MzEwMTczMw== aurghs 35919497 2021-05-18T11:48:37Z 2021-05-18T12:24:21Z COLLABORATOR

I think that It's not a bug: filename_or_obj in open_dataset can be a file, file-like, bytes, URL. The accepted inputs depend on the engine. So it doesn't make sense to raise a FileNotFoundError if the engine is not defined by the user or not automatically detected by xarray.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray 0.18.0 raises ValueError, not FileNotFoundError, when opening a non-existent file 894125618
843032959 https://github.com/pydata/xarray/issues/5329#issuecomment-843032959 https://api.github.com/repos/pydata/xarray/issues/5329 MDEyOklzc3VlQ29tbWVudDg0MzAzMjk1OQ== mathause 10194086 2021-05-18T09:59:51Z 2021-05-18T09:59:51Z MEMBER

Thanks for the report - I added that to the list of todos for the 0.18.1 patch release.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray 0.18.0 raises ValueError, not FileNotFoundError, when opening a non-existent file 894125618

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 12.563ms · About: xarray-datasette