|
65 | 65 | has_sufficient_disk_space, |
66 | 66 | map_nested, |
67 | 67 | memoize, |
| 68 | + nullcontext, |
68 | 69 | size_str, |
69 | 70 | temporary_assignment, |
70 | 71 | ) |
@@ -341,7 +342,7 @@ def __init__( |
341 | 342 | if is_local: |
342 | 343 | os.makedirs(self._cache_dir_root, exist_ok=True) |
343 | 344 | lock_path = os.path.join(self._cache_dir_root, self._cache_dir.replace(os.sep, "_") + ".lock") |
344 | | - with FileLock(lock_path) if is_local else contextlib.nullcontext(): |
| 345 | + with FileLock(lock_path) if is_local else nullcontext(): |
345 | 346 | if self._fs.exists(self._cache_dir): # check if data exist |
346 | 347 | if len(self._fs.listdir(self._cache_dir)) > 0: |
347 | 348 | logger.info("Overwrite dataset info from restored data version.") |
@@ -646,7 +647,7 @@ def download_and_prepare( |
646 | 647 | if is_local: |
647 | 648 | lock_path = os.path.join(self._cache_dir_root, self._cache_dir.replace(os.sep, "_") + ".lock") |
648 | 649 | # File locking only with local paths; no file locking on GCS or S3 |
649 | | - with FileLock(lock_path) if is_local else contextlib.nullcontext(): |
| 650 | + with FileLock(lock_path) if is_local else nullcontext(): |
650 | 651 | data_exists = self._fs.exists(self._cache_dir) |
651 | 652 | if data_exists and download_mode == DownloadMode.REUSE_DATASET_IF_EXISTS: |
652 | 653 | logger.warning(f"Found cached dataset {self.name} ({self._cache_dir})") |
@@ -855,14 +856,14 @@ def _save_info(self): |
855 | 856 | is_local = not is_remote_filesystem(self._fs) |
856 | 857 | if is_local: |
857 | 858 | lock_path = os.path.join(self._cache_dir_root, self._cache_dir.replace(os.sep, "_") + ".lock") |
858 | | - with FileLock(lock_path) if is_local else contextlib.nullcontext(): |
| 859 | + with FileLock(lock_path) if is_local else nullcontext(): |
859 | 860 | self.info.write_to_directory(self._cache_dir, fs=self._fs) |
860 | 861 |
|
861 | 862 | def _save_infos(self): |
862 | 863 | is_local = not is_remote_filesystem(self._fs) |
863 | 864 | if is_local: |
864 | 865 | lock_path = os.path.join(self._cache_dir_root, self._cache_dir.replace(os.sep, "_") + ".lock") |
865 | | - with FileLock(lock_path) if is_local else contextlib.nullcontext(): |
| 866 | + with FileLock(lock_path) if is_local else nullcontext(): |
866 | 867 | DatasetInfosDict(**{self.config.name: self.info}).write_to_directory(self.get_imported_module_dir()) |
867 | 868 |
|
868 | 869 | def _make_split_generators_kwargs(self, prepare_split_kwargs): |
|
0 commit comments