Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:416rehman DeepZero FileDiscovery

From Leeroopedia
Knowledge Sources
Domains File_Discovery, Ingest
Last Updated 2026-10-27 00:00 GMT

Overview

Built-in IngestProcessor that discovers files by extension and computes sha256-based sample IDs, serving as the default first stage for file-corpus pipelines.

Description

The FileDiscovery class is a built-in IngestProcessor that discovers files on disk by extension. It is the simplest ingest processor: it walks a target directory (optionally recursive), filters by file extension, computes a sha256 hash for each file, and returns Sample objects keyed by the first 16 characters of the sha256.

Each Sample carries data={"sha256": full_hash, "size_bytes": file_size}, which downstream stages can access via entry.upstream_data("discover", "sha256"). The stage name defaults to "file_discovery" (or whatever the pipeline YAML names it).

Usage

  • Use as the first stage in a pipeline that processes a corpus of files by extension.
  • Configure via YAML: extensions: ["txt"], recursive: true (default).

Code Reference

Source Location

  • Repository: DeepZero
  • File: src/deepzero/stages/ingest.py

Signature

class FileDiscovery(IngestProcessor):
    description = "generic file discovery - finds files by extension, no format parsing"

    def process(self, ctx: ProcessorContext, target: Path) -> list[Sample]: ...

Import

from deepzero.stages.ingest import FileDiscovery

I/O Contract

Inputs

Name Type Required Description
target Path Yes File or directory to scan
extensions list[str] No (config) File extensions to include (e.g., ["txt"])
recursive bool No (config) Walk subdirectories (default True)

Outputs

Name Type Description
returns list[Sample] One Sample per discovered file
Sample.sample_id str sha256[:16]
Sample.data dict {"sha256": full_hash, "size_bytes": int}

Usage Examples

Demo Pipeline YAML

# pipelines/demo/pipeline.yaml
stages:
  - name: file_discovery
    processor: file_discovery
    config:
      extensions: ["txt"]
      recursive: true

  - name: metadata_filter
    processor: metadata_filter
    config:
      max_size_bytes: 1048576

Programmatic Use

from pathlib import Path
from deepzero.engine.stage import StageSpec, ProcessorContext
from deepzero.stages.ingest import FileDiscovery

spec = StageSpec(name="discover", processor="file_discovery",
                 config={"extensions": ["txt"], "recursive": True})
discovery = FileDiscovery(spec)
samples = discovery.process(ctx, Path("./data"))
print(f"Found {len(samples)} files")
for s in samples[:3]:
    print(f"  {s.filename}: {s.data['size_bytes']} bytes")

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment