fsspec / fsspec/filesystem_spec

Error Deleting Cache

Open
#172 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.4k
Forks
490
Avg merge
2d 3h
Merged PRs (30d)
38

Description

At PyData NYC Sprints we ran into this bug using filecache.

---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
<ipython-input-9-d2fe724ed575> in <module>
----> 1 stocks.hvplot.line(x='Date', y='High')

c:\users\afrowell\documents\sage3iss\science\pydata2019\holoviz\hvplot\hvplot\plotting\core.py in line(self, x, y, **kwds)
    146         HoloViews object: Object representing the requested visualization
    147         """
--> 148         return self(x, y, kind='line', **kwds)
    149 
    150     def step(self, x=None, y=None, where='mid', **kwds):

c:\users\afrowell\documents\sage3iss\science\pydata2019\holoviz\hvplot\hvplot\plotting\core.py in __call__(self, x, y, kind, **kwds)
     70                 return pn.panel(plot, **panel_dict)
     71 
---> 72         return self._get_converter(x, y, kind, **kwds)(kind, x, y)
     73 
     74     def _get_converter(self, x=None, y=None, kind=None, **kwds):

c:\users\afrowell\documents\sage3iss\science\pydata2019\holoviz\hvplot\hvplot\plotting\core.py in _get_converter(self, x, y, kind, **kwds)
     78         kind = kind or params.pop('kind', None)
     79         return HoloViewsConverter(
---> 80             self._data, x, y, kind=kind, **params
     81         )
     82 

c:\users\afrowell\documents\sage3iss\science\pydata2019\holoviz\hvplot\hvplot\converter.py in __init__(self, data, x, y, kind, by, use_index, group_label, value_label, backlog, persist, use_dask, crs, fields, groupby, dynamic, grid, legend, rot, title, xlim, ylim, clim, symmetric, logx, logy, loglog, hover, subplots, label, invert, stacked, colorbar, fontsize, datashade, rasterize, row, col, figsize, debug, framewise, aggregator, projection, global_extent, geo, precompute, flip_xaxis, flip_yaxis, dynspread, hover_cols, x_sampling, y_sampling, project, tools, attr_labels, coastline, tiles, sort_date, check_symmetric_max, **kwds)
    309         self._process_data(kind, data, x, y, by, groupby, row, col,
    310                            use_dask, persist, backlog, label, value_label,
--> 311                            hover_cols, attr_labels, kwds)
    312 
    313         self.value_label = value_label

c:\users\afrowell\documents\sage3iss\science\pydata2019\holoviz\hvplot\hvplot\converter.py in _process_data(self, kind, data, x, y, by, groupby, row, col, use_dask, persist, backlog, label, value_label, hover_cols, attr_labels, kwds)
    543             data = data.to_frame()
    544         if is_intake(data):
--> 545             data = process_intake(data, use_dask or persist)
    546 
    547         if groupby is not None and not isinstance(groupby, list):

c:\users\afrowell\documents\sage3iss\science\pydata2019\holoviz\hvplot\hvplot\util.py in process_intake(data, use_dask)
    269         data = data.to_dask()
    270     else:
--> 271         data = data.read()
    272     return data
    273 

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\intake\source\csv.py in read(self)
    141     def read(self):
    142         self._get_schema()
--> 143         return self._dataframe.compute()
    144 
    145     def to_dask(self):

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\base.py in compute(self, **kwargs)
    163         dask.base.compute
    164         """
--> 165         (result,) = compute(self, traverse=False, **kwargs)
    166         return result
    167 

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\base.py in compute(*args, **kwargs)
    434     keys = [x.__dask_keys__() for x in collections]
    435     postcomputes = [x.__dask_postcompute__() for x in collections]
--> 436     results = schedule(dsk, keys, **kwargs)
    437     return repack([f(r, *a) for r, (f, a) in zip(results, postcomputes)])
    438 

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\threaded.py in get(dsk, result, cache, num_workers, pool, **kwargs)
     78         get_id=_thread_get_id,
     79         pack_exception=pack_exception,
---> 80         **kwargs
     81     )
     82 

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\local.py in get_async(apply_async, num_workers, dsk, result, cache, get_id, rerun_exceptions_locally, pack_exception, raise_exception, callbacks, dumps, loads, **kwargs)
    484                         _execute_task(task, data)  # Re-execute locally
    485                     else:
--> 486                         raise_exception(exc, tb)
    487                 res, worker_id = loads(res_info)
    488                 state["cache"][key] = res

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\local.py in reraise(exc, tb)
    314     if exc.__traceback__ is not tb:
    315         raise exc.with_traceback(tb)
--> 316     raise exc
    317 
    318 

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\local.py in execute_task(key, task_info, dumps, loads, get_id, pack_exception)
    220     try:
    221         task, data = loads(task_info)
--> 222         result = _execute_task(task, data)
    223         id = get_id()
    224         result = dumps((result, id))

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\core.py in _execute_task(arg, cache, dsk)
    117         func, args = arg[0], arg[1:]
    118         args2 = [_execute_task(a, cache) for a in args]
--> 119         return func(*args2)
    120     elif not ishashable(arg):
    121         return arg

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\optimization.py in __call__(self, *args)
    974         if not len(args) == len(self.inkeys):
    975             raise ValueError("Expected %d args, got %d" % (len(self.inkeys), len(args)))
--> 976         return core.get(self.dsk, self.outkey, dict(zip(self.inkeys, args)))
    977 
    978     def __reduce__(self):

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\core.py in get(dsk, out, cache)
    147     for key in toposort(dsk):
    148         task = dsk[key]
--> 149         result = _execute_task(task, cache)
    150         cache[key] = result
    151     result = _execute_task(out, cache)

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\core.py in _execute_task(arg, cache, dsk)
    116     elif istask(arg):
    117         func, args = arg[0], arg[1:]
--> 118         args2 = [_execute_task(a, cache) for a in args]
    119         return func(*args2)
    120     elif not ishashable(arg):

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\core.py in <listcomp>(.0)
    116     elif istask(arg):
    117         func, args = arg[0], arg[1:]
--> 118         args2 = [_execute_task(a, cache) for a in args]
    119         return func(*args2)
    120     elif not ishashable(arg):

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\core.py in _execute_task(arg, cache, dsk)
    116     elif istask(arg):
    117         func, args = arg[0], arg[1:]
--> 118         args2 = [_execute_task(a, cache) for a in args]
    119         return func(*args2)
    120     elif not ishashable(arg):

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\core.py in <listcomp>(.0)
    116     elif istask(arg):
    117         func, args = arg[0], arg[1:]
--> 118         args2 = [_execute_task(a, cache) for a in args]
    119         return func(*args2)
    120     elif not ishashable(arg):

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\core.py in _execute_task(arg, cache, dsk)
    113     """
    114     if isinstance(arg, list):
--> 115         return [_execute_task(a, cache) for a in arg]
    116     elif istask(arg):
    117         func, args = arg[0], arg[1:]

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\core.py in <listcomp>(.0)
    113     """
    114     if isinstance(arg, list):
--> 115         return [_execute_task(a, cache) for a in arg]
    116     elif istask(arg):
    117         func, args = arg[0], arg[1:]

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\core.py in _execute_task(arg, cache, dsk)
    117         func, args = arg[0], arg[1:]
    118         args2 = [_execute_task(a, cache) for a in args]
--> 119         return func(*args2)
    120     elif not ishashable(arg):
    121         return arg

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\dask\bytes\core.py in read_block_from_file(lazy_file, off, bs, delimiter)
    179 
    180 def read_block_from_file(lazy_file, off, bs, delimiter):
--> 181     with copy.copy(lazy_file) as f:
    182         if off == 0 and bs is None:
    183             return f.read()

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\fsspec\core.py in __enter__(self)
     86         mode = self.mode.replace("t", "").replace("b", "") + "b"
     87 
---> 88         f = self.fs.open(self.path, mode=mode)
     89 
     90         self.fobjects = [f]

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\fsspec\implementations\cached.py in <lambda>(*args, **kw)
    259             # all the methods defined in this class. Note `open` here, since
    260             # it calls `_open`, but is actually in superclass
--> 261             return lambda *args, **kw: getattr(type(self), item)(self, *args, **kw)
    262         if item == "__class__":
    263             return type(self)

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\fsspec\spec.py in open(self, path, mode, block_size, **kwargs)
    706             ac = kwargs.pop("autocommit", not self._intrans)
    707             f = self._open(
--> 708                 path, mode=mode, block_size=block_size, autocommit=ac, **kwargs
    709             )
    710             if not ac:

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\fsspec\implementations\cached.py in <lambda>(*args, **kw)
    259             # all the methods defined in this class. Note `open` here, since
    260             # it calls `_open`, but is actually in superclass
--> 261             return lambda *args, **kw: getattr(type(self), item)(self, *args, **kw)
    262         if item == "__class__":
    263             return type(self)

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\fsspec\implementations\cached.py in _open(self, path, mode, **kwargs)
    344                 # this only applies to HTTP, should instead use streaming
    345                 f2.write(f.read())
--> 346         self.save_cache()
    347         return self._open(path, mode)

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\fsspec\implementations\cached.py in <lambda>(*args, **kw)
    259             # all the methods defined in this class. Note `open` here, since
    260             # it calls `_open`, but is actually in superclass
--> 261             return lambda *args, **kw: getattr(type(self), item)(self, *args, **kw)
    262         if item == "__class__":
    263             return type(self)

c:\users\afrowell\.conda\envs\hvplotpip\lib\site-packages\fsspec\implementations\cached.py in save_cache(self)
    138         if os.path.exists(fn):
    139             os.remove(fn)
--> 140         os.rename(fn + ".temp", fn)
    141 
    142     def _check_cache(self):

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'c:/users/afrowell/documents/sage3iss/science/pydata2019/holoviz/hvplot/hvplot/../examples//data/cache\\cache.temp' -> 'c:/users/afrowell/documents/sage3iss/science/pydata2019/holoviz/hvplot/hvplot/../examples//data/cache\\cache'

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in fsspec/implementations/cached.py, following the save_cache path shown in the traceback and its cache.temp-to-cache rename. Reproduce the failure on Windows with the reported cache usage, then verify that cache updates no longer raise PermissionError when the file is still in use.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.