Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions fsspec/asyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from glob import has_magic
from typing import TYPE_CHECKING, Iterable

from .callbacks import _DEFAULT_CALLBACK
from .callbacks import DEFAULT_CALLBACK
from .exceptions import FSTimeoutError
from .implementations.local import LocalFileSystem, make_path_posix, trailing_sep
from .spec import AbstractBufferedFile, AbstractFileSystem
Expand Down Expand Up @@ -205,7 +205,7 @@ def running_async() -> bool:
async def _run_coros_in_chunks(
coros,
batch_size=None,
callback=_DEFAULT_CALLBACK,
callback=DEFAULT_CALLBACK,
timeout=None,
return_exceptions=False,
nofiles=False,
Expand Down Expand Up @@ -245,7 +245,7 @@ async def _run_coros_in_chunks(
asyncio.Task(asyncio.wait_for(c, timeout=timeout))
for c in coros[start : start + batch_size]
]
if callback is not _DEFAULT_CALLBACK:
if callback is not DEFAULT_CALLBACK:
[
t.add_done_callback(lambda *_, **__: callback.relative_update(1))
for t in chunk
Expand Down Expand Up @@ -506,7 +506,7 @@ async def _put(
lpath,
rpath,
recursive=False,
callback=_DEFAULT_CALLBACK,
callback=DEFAULT_CALLBACK,
batch_size=None,
maxdepth=None,
**kwargs,
Expand Down Expand Up @@ -583,7 +583,7 @@ async def _get(
rpath,
lpath,
recursive=False,
callback=_DEFAULT_CALLBACK,
callback=DEFAULT_CALLBACK,
maxdepth=None,
**kwargs,
):
Expand Down
8 changes: 4 additions & 4 deletions fsspec/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def branched(self, path_1, path_2, kwargs):
"""
self.branch(path_1, path_2, kwargs)
# mutate kwargs so that we can force the caller to pass "callback=" explicitly
return kwargs.pop("callback", _DEFAULT_CALLBACK)
return kwargs.pop("callback", DEFAULT_CALLBACK)

def branch_coro(self, fn):
"""
Expand Down Expand Up @@ -197,10 +197,10 @@ def as_callback(cls, maybe_callback=None):

For the special value of ``None``, return the global instance of
``NoOpCallback``. This is an alternative to including
``callback=_DEFAULT_CALLBACK`` directly in a method signature.
``callback=DEFAULT_CALLBACK`` directly in a method signature.
"""
if maybe_callback is None:
return _DEFAULT_CALLBACK
return DEFAULT_CALLBACK
return maybe_callback


Expand Down Expand Up @@ -297,4 +297,4 @@ def __del__(self):
return self.close()


_DEFAULT_CALLBACK = NoOpCallback()
DEFAULT_CALLBACK = _DEFAULT_CALLBACK = NoOpCallback()
4 changes: 2 additions & 2 deletions fsspec/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Optional

from .asyn import AsyncFileSystem, _run_coros_in_chunks, sync_wrapper
from .callbacks import _DEFAULT_CALLBACK
from .callbacks import DEFAULT_CALLBACK
from .core import filesystem, get_filesystem_class, split_protocol, url_to_fs

_generic_fs = {}
Expand Down Expand Up @@ -279,7 +279,7 @@ async def _cp_file(
url,
url2,
blocksize=2**20,
callback=_DEFAULT_CALLBACK,
callback=DEFAULT_CALLBACK,
**kwargs,
):
fs = _resolve_fs(url, self.method)
Expand Down
4 changes: 2 additions & 2 deletions fsspec/implementations/cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from typing import TYPE_CHECKING, Any, Callable, ClassVar

from fsspec import AbstractFileSystem, filesystem
from fsspec.callbacks import _DEFAULT_CALLBACK
from fsspec.callbacks import DEFAULT_CALLBACK
from fsspec.compression import compr
from fsspec.core import BaseCache, MMapCache
from fsspec.exceptions import BlocksizeMismatchError
Expand Down Expand Up @@ -607,7 +607,7 @@ def cat(
path,
recursive=False,
on_error="raise",
callback=_DEFAULT_CALLBACK,
callback=DEFAULT_CALLBACK,
**kwargs,
):
paths = self.expand_path(
Expand Down
6 changes: 3 additions & 3 deletions fsspec/implementations/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import yarl

from fsspec.asyn import AbstractAsyncStreamedFile, AsyncFileSystem, sync, sync_wrapper
from fsspec.callbacks import _DEFAULT_CALLBACK
from fsspec.callbacks import DEFAULT_CALLBACK
from fsspec.exceptions import FSTimeoutError
from fsspec.spec import AbstractBufferedFile
from fsspec.utils import (
Expand Down Expand Up @@ -234,7 +234,7 @@ async def _cat_file(self, url, start=None, end=None, **kwargs):
return out

async def _get_file(
self, rpath, lpath, chunk_size=5 * 2**20, callback=_DEFAULT_CALLBACK, **kwargs
self, rpath, lpath, chunk_size=5 * 2**20, callback=DEFAULT_CALLBACK, **kwargs
):
kw = self.kwargs.copy()
kw.update(kwargs)
Expand Down Expand Up @@ -268,7 +268,7 @@ async def _put_file(
lpath,
rpath,
chunk_size=5 * 2**20,
callback=_DEFAULT_CALLBACK,
callback=DEFAULT_CALLBACK,
method="post",
**kwargs,
):
Expand Down
4 changes: 2 additions & 2 deletions fsspec/implementations/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import json

from ..asyn import AsyncFileSystem
from ..callbacks import _DEFAULT_CALLBACK
from ..callbacks import DEFAULT_CALLBACK
from ..core import filesystem, open, split_protocol
from ..utils import isfilelike, merge_offset_ranges, other_paths

Expand Down Expand Up @@ -784,7 +784,7 @@ async def _get_file(self, rpath, lpath, **kwargs):
with open(lpath, "wb") as f:
f.write(data)

def get_file(self, rpath, lpath, callback=_DEFAULT_CALLBACK, **kwargs):
def get_file(self, rpath, lpath, callback=DEFAULT_CALLBACK, **kwargs):
if self.isdir(rpath):
return os.makedirs(lpath, exist_ok=True)
data = self.cat_file(rpath, **kwargs)
Expand Down
12 changes: 5 additions & 7 deletions fsspec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from hashlib import sha256
from typing import ClassVar

from .callbacks import _DEFAULT_CALLBACK
from .callbacks import DEFAULT_CALLBACK
from .config import apply_config, conf
from .dircache import DirCache
from .transaction import Transaction
Expand Down Expand Up @@ -876,9 +876,7 @@ def cat(self, path, recursive=False, on_error="raise", **kwargs):
else:
return self.cat_file(paths[0], **kwargs)

def get_file(
self, rpath, lpath, callback=_DEFAULT_CALLBACK, outfile=None, **kwargs
):
def get_file(self, rpath, lpath, callback=DEFAULT_CALLBACK, outfile=None, **kwargs):
"""Copy single remote file to local"""
from .implementations.local import LocalFileSystem

Expand Down Expand Up @@ -913,7 +911,7 @@ def get(
rpath,
lpath,
recursive=False,
callback=_DEFAULT_CALLBACK,
callback=DEFAULT_CALLBACK,
maxdepth=None,
**kwargs,
):
Expand Down Expand Up @@ -970,7 +968,7 @@ def get(
with callback.branched(rpath, lpath, kwargs) as child:
self.get_file(rpath, lpath, callback=child, **kwargs)

def put_file(self, lpath, rpath, callback=_DEFAULT_CALLBACK, **kwargs):
def put_file(self, lpath, rpath, callback=DEFAULT_CALLBACK, **kwargs):
"""Copy single file to remote"""
if os.path.isdir(lpath):
self.makedirs(rpath, exist_ok=True)
Expand All @@ -995,7 +993,7 @@ def put(
lpath,
rpath,
recursive=False,
callback=_DEFAULT_CALLBACK,
callback=DEFAULT_CALLBACK,
maxdepth=None,
**kwargs,
):
Expand Down