Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/mobius/integrations/ort_genai/auto_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def _copy_tokenizer_files(
"added_tokens.json",
"merges.txt", # BPE
"vocab.json", # BPE
"chat_template.jinja", # Chat template for ORT GenAI
Comment thread
justinchuby marked this conversation as resolved.
]
copied: list[str] = []
for filename in tokenizer_files:
Expand Down Expand Up @@ -127,6 +128,7 @@ def _copy_tokenizer_files_from_local(
"added_tokens.json",
"merges.txt", # BPE
"vocab.json", # BPE
"chat_template.jinja", # Chat template for ORT GenAI
Comment thread
justinchuby marked this conversation as resolved.
]
copied: list[str] = []
for filename in tokenizer_files:
Expand Down
12 changes: 10 additions & 2 deletions src/mobius/integrations/ort_genai/auto_export_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def test_copies_available_files(self, tmp_path):
fake_src = tmp_path / "src"
fake_src.mkdir()
(fake_src / "tokenizer.json").write_text('{"test": true}')
(fake_src / "chat_template.jinja").write_text("{{ messages }}")

with mock.patch("huggingface_hub.hf_hub_download") as mock_dl:
mock_dl.side_effect = lambda model_id, filename: (
Expand All @@ -77,6 +78,8 @@ def test_copies_available_files(self, tmp_path):

assert "tokenizer.json" in copied
assert (dst / "tokenizer.json").exists()
assert "chat_template.jinja" in copied
assert (dst / "chat_template.jinja").exists()


class TestCopyTokenizerFilesFromLocal:
Expand All @@ -88,14 +91,19 @@ def test_copies_present_files(self, tmp_path):
src.mkdir()
(src / "tokenizer.json").write_text('{"test": true}')
(src / "tokenizer_config.json").write_text('{"model_type": "llama"}')
(src / "chat_template.jinja").write_text("{{ messages }}")

dst = tmp_path / "output"
dst.mkdir()
copied = _copy_tokenizer_files_from_local(str(src), str(dst))

assert set(copied) == {"tokenizer.json", "tokenizer_config.json"}
assert set(copied) == {
"tokenizer.json",
"tokenizer_config.json",
"chat_template.jinja",
}
assert (dst / "tokenizer.json").read_text() == '{"test": true}'
assert (dst / "tokenizer_config.json").read_text() == '{"model_type": "llama"}'
assert (dst / "chat_template.jinja").read_text() == "{{ messages }}"

def test_skips_absent_files(self, tmp_path):
"""Files not present in the source directory are silently skipped."""
Expand Down
Loading