gravitino.filesystem.gvfs_base_operations.BaseGVFSOperations¶
- class gravitino.filesystem.gvfs_base_operations.BaseGVFSOperations(server_uri: str | None = None, metalake_name: str | None = None, options: Dict | None = None, **kwargs)¶
Bases:
ABC
Abstract base class for Gravitino Virtual File System operations.
This class provides the core functionality for interacting with the Gravitino Virtual File System, including operations for file manipulation, directory management, and credential handling. It handles the mapping between virtual paths in the Gravitino namespace and actual file paths in underlying storage systems.
Implementations of this class should provide the specific behaviors for each file system operation.
- __init__(server_uri: str | None = None, metalake_name: str | None = None, options: Dict | None = None, **kwargs)¶
Methods
__init__
([server_uri, metalake_name, options])cat_file
(path[, start, end])Get the content of a file.
cp_file
(path1, path2, **kwargs)Copy a file.
created
(path)Return the created timestamp of a file as a datetime.datetime Only supports for fsspec.LocalFileSystem now.
exists
(path, **kwargs)Check if a file or a directory exists.
get_file
(rpath, lpath[, callback, outfile])Copy single remote file to local.
info
(path, **kwargs)Get file info.
ls
(path[, detail])List the files and directories info of the path.
makedirs
(path[, exist_ok])Make a directory recursively.
mkdir
(path[, create_parents])Make a directory.
modified
(path)Returns the modified time of the path file if it exists.
mv
(path1, path2[, recursive, maxdepth])Move a file to another directory.
open
(path[, mode, block_size, ...])Open a file to read/write/append.
rm
(path[, recursive, maxdepth])Remove a file or directory. :param path: Virtual fileset path :param recursive: Whether to remove the directory recursively. When removing a directory, this parameter should be True. :param maxdepth: The maximum depth to remove the directory recursively.
rm_file
(path)Remove a file.
rmdir
(path)Remove a directory.
Attributes
ENABLE_CREDENTIAL_VENDING_DEFAULT
ENV_CURRENT_LOCATION_NAME_ENV_VAR_DEFAULT
SLASH
current_location_name
- abstract cat_file(path, start=None, end=None, **kwargs)¶
Get the content of a file. :param path: Virtual fileset path :param start: The offset in bytes to start reading from. It can be None. :param end: The offset in bytes to end reading at. It can be None. :param kwargs: Extra args :return File content
- abstract cp_file(path1, path2, **kwargs)¶
Copy a file. :param path1: Virtual src fileset path :param path2: Virtual dst fileset path, should be consistent with the src path fileset identifier :param kwargs: Extra args
- abstract created(path)¶
Return the created timestamp of a file as a datetime.datetime Only supports for fsspec.LocalFileSystem now. :param path: Virtual fileset path :return Created time(datetime.datetime)
- abstract exists(path, **kwargs)¶
Check if a file or a directory exists. :param path: Virtual fileset path :param kwargs: Extra args :return If a file or directory exists, it returns True, otherwise False
- abstract get_file(rpath, lpath, callback=None, outfile=None, **kwargs)¶
Copy single remote file to local. :param rpath: Remote file path :param lpath: Local file path :param callback: The callback class :param outfile: The output file path :param kwargs: Extra args
- abstract info(path, **kwargs)¶
Get file info. :param path: Virtual fileset path :param kwargs: Extra args :return A file info dict
- abstract ls(path, detail=True, **kwargs)¶
List the files and directories info of the path. :param path: Virtual fileset path :param detail: Whether to show the details for the files and directories info :param kwargs: Extra args :return If details is true, returns a list of file info dicts, else returns a list of file paths
- abstract makedirs(path, exist_ok=True)¶
Make a directory recursively. :param path: Virtual fileset path :param exist_ok: Continue if a directory already exists
- abstract mkdir(path, create_parents=True, **kwargs)¶
Make a directory. if create_parents=True, this is equivalent to
makedirs
.- Parameters:
path – Virtual fileset path
create_parents – Create parent directories if missing when set to True
kwargs – Extra args
- abstract modified(path)¶
Returns the modified time of the path file if it exists. :param path: Virtual fileset path :return Modified time(datetime.datetime)
- abstract mv(path1, path2, recursive=False, maxdepth=None, **kwargs)¶
- Move a file to another directory.
This can move a file to another existing directory. If the target path directory does not exist, an exception will be thrown.
- Parameters:
path1 – Virtual src fileset path
path2 – Virtual dst fileset path, should be consistent with the src path fileset identifier
recursive – Whether to move recursively
maxdepth – Maximum depth of recursive move
kwargs – Extra args
- abstract open(path, mode='rb', block_size=None, cache_options=None, compression=None, **kwargs)¶
Open a file to read/write/append. :param path: Virtual fileset path :param mode: The mode now supports: rb(read), wb(write), ab(append). See builtin
open()
:param block_size: Some indication of buffering - this is a value in bytes :param cache_options: Extra arguments to pass through to the cache :param compression: If given, open file using compression codec :param kwargs: Extra args :return A file-like object from the filesystem
- abstract rm(path, recursive=False, maxdepth=None)¶
Remove a file or directory. :param path: Virtual fileset path :param recursive: Whether to remove the directory recursively.
When removing a directory, this parameter should be True.
- Parameters:
maxdepth – The maximum depth to remove the directory recursively.
- abstract rm_file(path)¶
Remove a file. :param path: Virtual fileset path
- abstract rmdir(path)¶
Remove a directory. It will delete a directory and all its contents recursively for PyArrow.HadoopFileSystem. And it will throw an exception if delete a directory which is non-empty for LocalFileSystem. :param path: Virtual fileset path