agentleFS
Hugging FaceKnown publisherhuggingface/datatrove/AGENTS.md

datatrove

AGENTS.md3.4k starsChanged 9 months agoApache-2.0View on GitHub

DataTrove is a library to process, filter, and deduplicate text data at very large scale. It provides prebuilt pipeline blocks with a framework to add custom functionality. Pipelines are platform-agnostic, running locally, on Slurm, or on Ray clusters. See README.md for detailed documentation on terminology, pipeline blocks, executors, and usage examples.

Trending

Less talk lately.about the whole repository

Dec 2025: 2 mentionsJan 2026: 1 mentionFeb 2026: 0 mentionsMar 2026: 1 mentionApr 2026: 1 mentionMay 2026: 1 mentionJun 2026: 1 mentionJul 2026: 1 mentionAug 2026: 2 mentionsSep 2026: 1 mentionOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the huggingface/datatrove repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about huggingface/datatrove

The biggest 5 of 27 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 27

Talked about on GitHub, Bluesky and Hacker News (27 times).

On GitHub · 22

17 more on GitHub
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

19 rules. About 1 is common, 6 are distinctive, and 12 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 12

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always add tests for new functionality

    line 76
  2. Very specific:

    Run make quality before pushing

    line 77
  3. Very specific:

    Add optional dependency checks via _requires_dependencies

    line 84
  4. Very specific:

    Use self.stat_update() and self.track_time() for metrics

    line 85
  5. Very specific:

    Add tests in tests/pipeline/

    line 86
  6. Very specific:

    Run: pytest -sv ./tests/ or pytest -sv ./tests/pipeline/test_filters.py for specific tests

    line 108
  7. Very specific:

    Relaunch sharding: Never change tasks count when relaunching a partially completed job

    line 114
  8. Very specific:

    Output filename collisions: Always include ${rank} in writer output filenames to avoid tasks overwriting each other

    line 115
  9. Very specific:

    Logging dir reuse: Don't reuse logging_dir across different pipelines — it overwrites stats and completions

    line 116
  10. Very specific:

    Optional deps: Use _requires_dependencies to declare optional dependencies.

    line 118
  11. Very specific:

    Run make quality before commits

    line 123
  12. Very specific:

    Add tests in tests/pipeline/ for new blocks

    line 124
  13. Distinctive:

    Follow existing patterns when adding pipeline steps

    line 125
  14. Distinctive:

    Use type hints on all function signatures

    line 126
  15. Very specific:

    Use loguru logger, not print()

    line 127
  16. Common:

    Commit secrets, API keys, or credentials

    line 136
  17. Distinctive:

    Delete or disable tests to fix CI

    line 137
  18. Distinctive:

    Use deprecated APIs without migration plan

    line 138
  19. Distinctive:

    After every interaction, check whether:

    line 143

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

DataTrove

DataTrove is a library to process, filter, and deduplicate text data at very large scale. It provides prebuilt pipeline blocks with a framework to add custom functionality. Pipelines are platform-agnostic, running locally, on Slurm, or on Ray clusters.

See README.md for detailed documentation on terminology, pipeline blocks, executors, and usage examples.

Python Environment

  • Python Version: 3.10+
  • Package Manager: uv for dependency management
  • Virtual Environment: .venv/ (created via uv venv)

Core Commands

uv venv --python 3.12
uv sync --all-extras          # install all optional dependencies
make quality                  # lint changed files (ruff check + format)
make style                    # auto-fix changed files
make quality-full             # lint entire repo
make style-full               # auto-fix entire repo
make test                     # run tests

Project Structure

├── src/datatrove/
│   ├── data.py                   # Document, Media dataclasses
│   ├── io.py                     # DataFolder, fsspec I/O helpers
│   ├── pipeline/
│   │   ├── base.py               # PipelineStep base class
│   │   ├── readers/              # JsonlReader, ParquetReader, CsvReader, WarcReader, HuggingFaceDatasetReader, IpcReader
│   │   ├── writers/              # JsonlWriter, ParquetWriter, HuggingFaceDatasetWriter
│   │   ├── extractors/           # Trafilatura, ReadabilityInscriptis
│   │   ├── filters/              # Gopher, FineWeb, C4, Language, URL, Regex, Sampler, FastText, UnigramLogProb, Lambda
│   │   ├── formatters/           # FTFYFormatter, PIIFormatter, SymbolLinesFormatter
│   │   ├── dedup/                # Exact, MinHash, Sentence, BloomFilter, ExactSubstrings
│   │   ├── stats/                # Doc, Word, Line, Paragraph, Sentence, Lang, Token, Perplexity, Contamination stats + StatsMerger
│   │   ├── tokens/               # DocumentTokenizer, MegatronDocumentTokenizer, TokensCounter, Merger, ContextShuffler
│   │   ├── decont/               # NGramsDecontIndexer, NGramsDecontFilter
│   │   ├── inference/            # InferenceRunner, servers (VLLM, SGLang, Endpoint, Custom, Dummy), progress monitor, dataset cards
│   │   └── media/                # Binary/WARC/Zstd readers, writers, MIME filters, HTTP fetch
│   ├── executor/
│   │   ├── base.py               # PipelineExecutor base
│   │   ├── local.py              # LocalPipelineExecutor
│   │   ├── slurm.py              # SlurmPipelineExecutor
│   │   └── ray.py                # RayPipelineExecutor
│   ├── tools/                    # CLI: check_dataset, merge_stats, launch_pickled_pipeline, failed_logs, inspect_data, jobs_status, track_jobs
│   └── utils/                    # Hashing, tokenization, text processing, LID, perplexity, logging, stats, batching, jobs
├── tests/
│   ├── pipeline/                 # Tests for filters, readers, writers, dedup, extractors, stats, tokens, inference
│   └── executor/                 # Tests for local, ray executors
├── examples/                     # FineWeb, CommonCrawl, C4 tokenization, dedup, stats, inference
│   └── inference/                # Synthetic data generation, benchmarking, progress monitoring
├── pyproject.toml
├── Makefile
└── README.md

Code Style

  • Formatter/linter: Ruff (line length 119)
  • Naming: snake_case functions/variables, PascalCase classes, UPPER_SNAKE_CASE constants
  • Imports: stdlib → third-party → local, absolute imports (from datatrove.pipeline.filters import ...). Two blank lines after imports (isort config).
  • Type hints: Required on all function signatures
  • Docstrings: Google style for public functions and classes
  • Logging: Uses loguru — import via from loguru import logger
  • Dependencies: Optional deps checked at runtime via _requires_dependencies on PipelineStep

Git Workflow

  • Atomic, focused commits
  • Conventional commit messages: <type>(<scope>): <summary> (types: feat, fix, docs, style, refactor, test, chore)
  • Rebase branches, not merge
  • Always add tests for new functionality
  • Run make quality before pushing

Development Guidelines

Adding a new pipeline block:

  1. Inherit from the appropriate base class (see pipeline/base.py and subclass bases in each subdirectory)
  2. Implement the required method (run, filter, extract, format, extract_stats)
  3. Add optional dependency checks via _requires_dependencies
  4. Use self.stat_update() and self.track_time() for metrics
  5. Add tests in tests/pipeline/
  6. Export in the relevant __init__.py

Key base classes — always inherit from the appropriate one:

  • PipelineStep → general blocks (pipeline/base.py)
  • BaseFilter → filters returning bool (pipeline/filters/base_filter.py)
  • BaseReader / BaseDiskReader → data readers (pipeline/readers/base.py)
  • DiskWriter → data writers (pipeline/writers/disk_base.py)
  • BaseExtractor → HTML extraction (pipeline/extractors/base.py)
  • BaseFormatter → text formatting (pipeline/formatters/base.py)
  • BaseStats → statistics collection (pipeline/stats/base.py)

Adding a new reader: Inherit BaseDiskReader, implement read_file(filepath, file_doc_idx) → yield Document. Respect text_key, id_key, adapter, limit.

Adding a new filter: Inherit BaseFilter, implement filter(doc) -> bool (True=keep). Support exclusion_writer for rejected docs. Support batch_filter(batch) for batched processing.

Adding a new writer: Inherit DiskWriter, implement _write(document, output_file). Use output_filename template with ${rank}, ${id}, ${metadata_field}.

Testing

  • Framework: pytest with pytest-timeout (120s default), pytest-xdist, pytest-rerunfailures
  • S3 mocking: moto[s3,server] for S3 tests
  • Run: pytest -sv ./tests/ or pytest -sv ./tests/pipeline/test_filters.py for specific tests
  • Tests live alongside pipeline structure: tests/pipeline/test_*.py, tests/executor/test_*.py

Common Pitfalls

  • Task/file mismatch: Setting tasks > files wastes resources — tasks without files do nothing
  • Relaunch sharding: Never change tasks count when relaunching a partially completed job
  • Output filename collisions: Always include ${rank} in writer output filenames to avoid tasks overwriting each other
  • Logging dir reuse: Don't reuse logging_dir across different pipelines — it overwrites stats and completions
  • Pickling: Custom functions in pipelines may have import pickling issues — move imports inside the function body
  • Optional deps: Use _requires_dependencies to declare optional dependencies; don't import them at module level

Boundaries

  • Always do:
    • Run make quality before commits
    • Add tests in tests/pipeline/ for new blocks
    • Follow existing patterns when adding pipeline steps
    • Use type hints on all function signatures
    • Use loguru logger, not print()
  • Ask first:
    • Adding new dependencies to pyproject.toml
    • Changing base class interfaces (PipelineStep, BaseFilter, etc.)
    • Modifying executor logic or completion tracking
    • Changing the Document data model
  • Never do:
    • Commit secrets, API keys, or credentials
    • Delete or disable tests to fix CI
    • Use deprecated APIs without migration plan
    • Ignore ruff errors or type annotations

Post-Interaction Checklist

After every interaction, check whether:

  1. Missing tests — Are there new functions/classes without corresponding tests in tests/? Add them.
  2. Missing docstrings — Do new public functions/classes have Google-style docstrings? Add them.
  3. Missing type hints — Are all function signatures fully annotated? Add them.
  4. README update — Does the README need updating for new features or changed behavior?
  5. Dead code — Did your changes make any existing code obsolete? Remove it.
  6. Lint check — Run make quality to verify no ruff violations were introduced.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.