#batch #pattern-matching #identifier #indices #filename #generate #uuid

batch-mode-batch-index

Provides utilities for managing batch indices and generating regex patterns for matching batch file names based on Usize or UUID identifiers

1 unstable release

new 0.2.0 Feb 27, 2025

#62 in #indices


Used in 8 crates (7 directly)

MIT license

54KB
283 lines

batch-mode-batch-index

This crate provides utilities for handling batch indices in a batch processing environment. It defines the BatchIndex type, which can be either a Usize or a Uuid, and provides mechanisms to generate regular expressions (regex) for matching batch-related filenames based on these indices. The crate ensures the consistent handling of batch identifiers and file patterns throughout the batch processing lifecycle.

Key Features

  • Batch Indexing: Define and manage batch indices using either numeric (Usize) or UUID-based identifiers.
  • File Pattern Matching: Generate regex patterns for matching batch file names (input, output, error, metadata) that incorporate the batch index.
  • Batch Index Type Conversion: Easily convert between BatchIndex and BatchIndexType.
  • Edge Case Handling: Robust handling of edge cases for both numeric and UUID-based batch indices.

Usage

Creating a Batch Index

use batch_mode_batch_index::{BatchIndex, BatchIndexType};

let batch_index = BatchIndex::Usize(4);
let regex = batch_index.file_pattern();

Using Regex to Match Batch Filenames

assert!(regex.is_match("batch_input_4.jsonl"));
assert!(!regex.is_match("batch_input_invalid.jsonl"));

Converting Between BatchIndex and BatchIndexType

let index_type = BatchIndexType::from(&batch_index);

Error Handling

The crate defines errors for UUID parsing, ensuring proper validation and handling of batch index values.

License

This crate is licensed under the MIT License. See LICENSE for details.

Dependencies

~24–40MB
~636K SLoC