utils.py 276 B

12345678910
  1. import functools
  2. # use cache to avoid loading the same file multiple times
  3. # which can leads to too many open files error
  4. @functools.lru_cache(maxsize=128)
  5. def load_file(filepath: str) -> str:
  6. with open(filepath, 'r') as f:
  7. content = f.read()
  8. return content