Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dependencies lid.py, io.py #239 #241

Merged
merged 2 commits into from
Jul 8, 2024
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/datatrove/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from huggingface_hub import HfFileSystem, cached_assets_path

from datatrove.utils.logging import logger
from datatrove.utils._import_utils import check_required_dependencies


class OutputFileManager:
Expand Down Expand Up @@ -319,6 +320,7 @@ def safely_create_file(file_to_lock: str, do_processing: Callable):
file_to_lock: str: lock will be "lock_path.lock" and completed file "lock_path.completed"
do_processing: callback with the code to run to process/create the files
"""
check_required_dependencies("io", ["fasteners"])
from fasteners import InterProcessLock

completed_file = f"{file_to_lock}.completed"
Expand Down
2 changes: 2 additions & 0 deletions src/datatrove/utils/lid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from datatrove.data import Document
from datatrove.io import cached_asset_path_or_download
from datatrove.utils._import_utils import check_required_dependencies


class LID:
Expand Down Expand Up @@ -37,6 +38,7 @@ def __init__(self, languages: list[str] | None = None, k: int = -1) -> None:
@property
def model(self):
if not self._model:
check_required_dependencies("lid", [("fasttext", "fasttext-wheel")])
from fasttext.FastText import _FastText

model_file = cached_asset_path_or_download(
Expand Down