Skip to content

Commit 8ca2076

Browse files
authored
os.make_dirs is not a thing; os.makedirs is (#2061)
We were also missing any coverage for this codepath :(
1 parent 63863ab commit 8ca2076

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

keras_hub/src/utils/preset_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def tf_copy_gfile_to_cache(preset, path):
240240
try:
241241
import tensorflow as tf
242242

243-
os.make_dirs(os.path.dirname(local_path), exist_ok=True)
243+
os.makedirs(os.path.dirname(local_path), exist_ok=True)
244244
tf.io.gfile.copy(url, local_path)
245245
except Exception as e:
246246
# gfile.copy will leave an empty file after an error.

keras_hub/src/utils/preset_utils_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ def test_preset_errors(self):
3333
with self.assertRaisesRegex(ValueError, "class keras_hub>BortBackbone"):
3434
BertBackbone.from_preset(preset_dir)
3535

36+
@pytest.mark.large
37+
def test_tf_file_io(self):
38+
# Load a model from Kaggle to use as a test model.
39+
preset = "bert_tiny_en_uncased"
40+
backbone = BertBackbone.from_preset(preset)
41+
# Save the model on a local directory.
42+
temp_dir = self.get_temp_dir()
43+
local_preset_dir = os.path.join(temp_dir, "bert_preset")
44+
backbone.save_to_preset(local_preset_dir)
45+
# Load with "file://" which tf supports.
46+
backbone = BertBackbone.from_preset("file://" + local_preset_dir)
47+
3648
@pytest.mark.large
3749
def test_upload_empty_preset(self):
3850
temp_dir = self.get_temp_dir()

0 commit comments

Comments
 (0)