mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-12-03 07:18:28 +01:00
Intermediate PR in removing path_info from our code base. It is completely removed from the main codebase and is still being used in tests, which will be migrated in the followups. For fs-specific simple path manipulation, we've introduced `fs.path` helper (similar to `os.path`). Fixes #6774
34 lines
901 B
Python
34 lines
901 B
Python
import threading
|
|
|
|
from funcy import cached_property, wrap_prop
|
|
|
|
from dvc.scheme import Schemes
|
|
|
|
from .fsspec_wrapper import FSSpecWrapper
|
|
|
|
|
|
class MemoryFileSystem(FSSpecWrapper): # pylint:disable=abstract-method
|
|
scheme = Schemes.MEMORY
|
|
PARAM_CHECKSUM = "md5"
|
|
TRAVERSE_PREFIX_LEN = 2
|
|
DEFAULT_BLOCKSIZE = 4096
|
|
|
|
def __eq__(self, other):
|
|
# NOTE: all fsspec MemoryFileSystem instances are equivalent and use a
|
|
# single global store
|
|
return isinstance(other, type(self))
|
|
|
|
__hash__ = FSSpecWrapper.__hash__
|
|
|
|
@wrap_prop(threading.Lock())
|
|
@cached_property
|
|
def fs(self):
|
|
from fsspec.implementations.memory import MemoryFileSystem as MemFS
|
|
|
|
return MemFS(**self.fs_args)
|
|
|
|
def open(self, *args, **kwargs):
|
|
with super().open(*args, **kwargs) as fobj:
|
|
fobj.blocksize = self.DEFAULT_BLOCKSIZE
|
|
return fobj
|