Skip to content

Commit 4d9873c

Browse files
committed
Mock the FileLock in HF datasets during tests
Signed-off-by: Charlie Truong <chtruong@nvidia.com>
1 parent 7bc5fae commit 4d9873c

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

tests/functional_tests/utils/create_ptq_ckpt.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# limitations under the License.
1414

1515
import argparse
16+
from unittest.mock import MagicMock
17+
18+
import datasets
1619

1720
from nemo.collections import llm
1821
from nemo.collections.llm.modelopt import ExportConfig, QuantizationConfig
@@ -66,6 +69,10 @@ def get_args():
6669

6770
def main():
6871
"""Example NeMo 2.0 Post Training Quantization workflow."""
72+
# Mock FileLock to avoid writing to the read-only test directory
73+
# HF Datasets library will always write a lock file even if reading from cache
74+
datasets.builder.FileLock = MagicMock()
75+
6976
args = get_args()
7077

7178
quantization_config = QuantizationConfig(

tests/functional_tests/utils/run_onnx_trt_embedding_export.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
import argparse
1616
import os
1717
from functools import partial
18+
from unittest.mock import MagicMock
1819

20+
import datasets
1921
import tensorrt as trt
2022
import torch
2123
from nemo.collections.llm.gpt.model.hf_llama_embedding import (
@@ -95,6 +97,10 @@ def get_args():
9597

9698

9799
def export_onnx_trt(args):
100+
# Mock FileLock to avoid writing to the read-only test directory
101+
# HF Datasets library will always write a lock file even if reading from cache
102+
datasets.builder.FileLock = MagicMock()
103+
98104
# Base Llama model needs to be adapted to turn it into an embedding model.
99105
model, tokenizer = get_llama_bidirectional_hf_model(
100106
model_name_or_path=args.hf_model_path,

0 commit comments

Comments
 (0)