MCPcopy Create free account
hub / github.com/Pints-AI/1.5-Pints / check_valid_checkpoint_dir

Function check_valid_checkpoint_dir

lit_gpt/utils_old.py:233–264  ·  view source on GitHub ↗
(checkpoint_dir: Path)

Source from the content-addressed store, hash-verified

231
232
233def check_valid_checkpoint_dir(checkpoint_dir: Path) -> None:
234 files = {
235 "lit_model.pth": (checkpoint_dir / "lit_model.pth").is_file(),
236 "lit_config.json": (checkpoint_dir / "lit_config.json").is_file(),
237 "tokenizer.json OR tokenizer.model": (checkpoint_dir / "tokenizer.json").is_file() or (
238 checkpoint_dir / "tokenizer.model"
239 ).is_file(),
240 "tokenizer_config.json": (checkpoint_dir / "tokenizer_config.json").is_file(),
241 }
242 if checkpoint_dir.is_dir():
243 if all(files.values()):
244 # we're good
245 return
246 problem = f" is missing the files: {[f for f, exists in files.items() if not exists]!r}"
247 else:
248 problem = " is not a checkpoint directory"
249
250 # list locally available checkpoints
251 available = list(Path("checkpoints").glob("*/*"))
252 if available:
253 options = "\n --checkpoint_dir ".join([""] + [repr(str(p.resolve())) for p in available])
254 extra = f"\nYou have downloaded locally:{options}\n"
255 else:
256 extra = ""
257
258 error_message = (
259 f"--checkpoint_dir {str(checkpoint_dir.absolute())!r}{problem}."
260 "\nFind download instructions at https://github.com/Lightning-AI/lit-gpt/blob/main/tutorials\n"
261 f"{extra}\nSee all download options by running:\n python scripts/download.py"
262 )
263 print(error_message, file=sys.stderr)
264 raise SystemExit(1)
265
266
267class SavingProxyForStorage:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected