-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #645 from allenai/shanea/tokenizer-package-data
Move tokenizers to new `olmo_data` package.
- Loading branch information
Showing
8 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .data import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from contextlib import contextmanager | ||
from pathlib import Path | ||
from typing import Generator | ||
|
||
import importlib_resources | ||
from importlib_resources.abc import Traversable | ||
|
||
|
||
def _get_data_traversable(data_rel_path: str) -> Traversable: | ||
return importlib_resources.files("olmo_data").joinpath(data_rel_path) | ||
|
||
|
||
def is_data_dir(data_rel_path: str) -> bool: | ||
return _get_data_traversable(data_rel_path).is_dir() | ||
|
||
|
||
def is_data_file(data_rel_path: str) -> bool: | ||
return _get_data_traversable(data_rel_path).is_file() | ||
|
||
|
||
@contextmanager | ||
def get_data_path(data_rel_path: str) -> Generator[Path, None, None]: | ||
try: | ||
with importlib_resources.as_file(_get_data_traversable(data_rel_path)) as path: | ||
yield path | ||
finally: | ||
pass |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters