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

KeyError exception when trying to open a file that doesn't exist #9

Closed
simonlsk opened this issue Sep 19, 2022 · 0 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@simonlsk
Copy link
Contributor

Example trace for img = Image.open("data/raw/images/199.png")

ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.

ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.

ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.

--- Logging error ---
--- Logging error ---
--- Logging error ---
--- Logging error ---
--- Logging error ---
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/dagshub/streaming/filesystem.py", line 208, in stat
    return self.__stat(relative_path, dir_fd=self.project_root_fd)
FileNotFoundError: [Errno 2] No such file or directory: '<ipython-input-30-4f1112fdef07>'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/linecache.py", line 74, in checkcache
    stat = os.stat(fullname)
  File "/usr/local/lib/python3.7/dist-packages/dagshub/streaming/filesystem.py", line 210, in stat
    if str(relative_path.name) not in self.dirtree[str(relative_path.parent)]:
KeyError: '.'

Original exception was:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/dagshub/streaming/filesystem.py", line 181, in open
    return self.__open(relative_path, mode, *args, **kwargs, opener=project_root_opener)
FileNotFoundError: [Errno 2] No such file or directory: 'data/raw/images/199.png'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py", line 3326, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-30-4f1112fdef07>", line 6, in <module>
  File "/usr/local/lib/python3.7/dist-packages/PIL/Image.py", line 2843, in open
    fp = builtins.open(filename, "rb")
  File "/usr/local/lib/python3.7/dist-packages/dagshub/streaming/filesystem.py", line 193, in open
    raise FileNotFoundError(f'Error finding {relative_path} in repo or on DagsHub')
FileNotFoundError: Error finding data/raw/images/199.png in repo or on DagsHub

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py", line 2040, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'FileNotFoundError' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/dagshub/streaming/filesystem.py", line 208, in stat
    return self.__stat(relative_path, dir_fd=self.project_root_fd)
FileNotFoundError: [Errno 2] No such file or directory: '<ipython-input-30-4f1112fdef07>'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/IPython/core/ultratb.py", line 1101, in get_records
    return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
  File "/usr/local/lib/python3.7/dist-packages/IPython/core/ultratb.py", line 319, in wrapped
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/IPython/core/ultratb.py", line 353, in _fixed_getinnerframes
    records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
  File "/usr/lib/python3.7/inspect.py", line 1502, in getinnerframes
    frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
  File "/usr/lib/python3.7/inspect.py", line 1460, in getframeinfo
    filename = getsourcefile(frame) or getfile(frame)
  File "/usr/lib/python3.7/inspect.py", line 693, in getsourcefile
    if os.path.exists(filename):
  File "/usr/lib/python3.7/genericpath.py", line 19, in exists
    os.stat(path)
  File "/usr/local/lib/python3.7/dist-packages/dagshub/streaming/filesystem.py", line 210, in stat
    if str(relative_path.name) not in self.dirtree[str(relative_path.parent)]:
KeyError: '.'

self.dirtree[str(relative_path.parent)] should probably change to self.dirtree.get(str(relative_path.parent))

@simonlsk simonlsk added the bug Something isn't working label Sep 19, 2022
@simonlsk simonlsk assigned jinensetpal and simonlsk and unassigned jinensetpal Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants