cutana_stream_utils
anomaly_match.utils.cutana_stream_utils
¶
Cutana streaming data utilities.
cutana_validate_files_and_count_sources(files, chunk_size=100000)
¶
Validate catalogue files for cutana compatibility and count sources.
Only checks column schema (first chunk of first file). Row counts are read from parquet metadata when possible to avoid scanning every row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
list[Path | str]
|
list of file paths to validate (CSV or Parquet). |
required |
chunk_size
|
int
|
number of rows to read per chunk. |
100000
|
Returns:
| Type | Description |
|---|---|
tuple[list[Path], int, int]
|
valid files, total number of sources, and total number of chunks. |
Source code in anomaly_match/utils/cutana_stream_utils.py
cutana_buffer_generator(files, buffer_path, chunk_size=100000)
¶
Generate temporary buffer files by reading catalogue files in chunks.
Each chunk is written to a distinct <buffer_path>.N.parquet file
so a just-exited prediction subprocess can't race the next chunk's
write on the same inode (previously caused the chunk loop to hang
after chunk 1 on NFS). The index-suffixed files are cleaned up as
later chunks are written so total disk usage stays at one chunk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
list[Path | str]
|
list of file paths to process (CSV or Parquet). |
required |
buffer_path
|
Path
|
base path; per-chunk files are written alongside with an index suffix. |
required |
chunk_size
|
int
|
number of rows to read per chunk. |
100000
|
Yields:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
path to the buffer file containing the current chunk. |