Skip to content

Commit

Permalink
Ignore Pandas DeprecationWarning from cachey.nbytes()
Browse files Browse the repository at this point in the history
  • Loading branch information
padraic-shafer committed Mar 7, 2024
1 parent 63b583b commit 31c306f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tiled/server/object_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import contextlib
import time
from timeit import default_timer
from warnings import catch_warnings

import cachey
from dask.callbacks import Callback
Expand Down Expand Up @@ -129,7 +130,10 @@ def put(self, key, value, cost, nbytes=None):
Computed (with best effort) if not provided.
"""
if nbytes is None:
nbytes = self._cache.get_nbytes(value)
# See https://github.com/bluesky/tiled/issues/675#issuecomment-1983581882
# Note that catch_warnings() is not thread-safe
with catch_warnings(action="ignore", category=DeprecationWarning):
nbytes = self._cache.get_nbytes(value)
logger.debug("Store %r (cost=%.3f, nbytes=%d)", key, cost, nbytes)
self._cache.put(key, value, cost, nbytes=nbytes)

Expand Down Expand Up @@ -196,7 +200,10 @@ def _posttask(self, key, value, dsk, state, id):
if deps:
duration += max(self.durations.get(k, 0) for k in deps)
self.durations[key] = duration
nb = self._nbytes(value)
# See https://github.com/bluesky/tiled/issues/675#issuecomment-1983581882
# Note that catch_warnings() is not thread-safe
with catch_warnings(action="ignore", category=DeprecationWarning):
nb = self._nbytes(value)
self.cache.put(("dask", *key), value, cost=duration, nbytes=nb)

def _finish(self, dsk, state, errored):
Expand Down

0 comments on commit 31c306f

Please sign in to comment.