Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#6940] fix(gvfs): fix python gvfs missing auto-create fileset dir (#7006)

mchades18668449e854
diff --git a/clients/client-python/gravitino/filesystem/gvfs_base_operations.py b/clients/client-python/gravitino/filesystem/gvfs_base_operations.py
index 62cc40934c..82280a87ac 100644
--- a/clients/client-python/gravitino/filesystem/gvfs_base_operations.py
+++ b/clients/client-python/gravitino/filesystem/gvfs_base_operations.py
@@ -378,8 +378,30 @@ class BaseGVFSOperations(ABC):
actual_fs = self._get_filesystem(
actual_location, catalog, fileset_ident, target_location_name
)
+ self._create_fileset_location_if_needed(
+ catalog.properties(), actual_fs, actual_location
+ )
return actual_fs
+ def _create_fileset_location_if_needed(
+ self,
+ catalog_props: Dict[str, str],
+ actual_fs: AbstractFileSystem,
+ fileset_path: str,
+ ):
+ # If the server-side filesystem ops are disabled, the fileset directory may not exist. In
+ # such case the operations like create, open, list files under this directory will fail.
+ # So we need to check the existence of the fileset directory beforehand.
+ fs_ops_disabled = catalog_props.get("disable-filesystem-ops", "false")
+ if fs_ops_disabled.lower() == "true":
+ if not actual_fs.exists(fileset_path):
+ actual_fs.makedir(fileset_path, create_parents=True)
+ logger.info(
+ "Automatically created a directory for fileset path: %s when "
+ "disable-filesystem-ops sets to true in the server side",
+ fileset_path,
+ )
+
def _get_actual_file_path(
self, gvfs_path: str, location_name: str, operation: FilesetDataOperation
) -> str: