MCPcopy Create free account
hub / github.com/allenai/OLMoASR / prepare_input_files

Function prepare_input_files

scripts/data/processing/text_to_jsonl.py:194–223  ·  view source on GitHub ↗

Prepare list of input files from various input types. Args: input_path: Single file path, directory path, or list of file paths Returns: List of transcript file paths Raises: ValueError: If input is invalid or no files are found

(input_path: Union[str, List[str]])

Source from the content-addressed store, hash-verified

192
193
194def prepare_input_files(input_path: Union[str, List[str]]) -> FileList:
195 """
196 Prepare list of input files from various input types.
197
198 Args:
199 input_path: Single file path, directory path, or list of file paths
200
201 Returns:
202 List of transcript file paths
203
204 Raises:
205 ValueError: If input is invalid or no files are found
206 """
207 if isinstance(input_path, str):
208 if os.path.isdir(input_path):
209 # Directory: discover transcript files
210 return discover_transcript_files(input_path)
211 elif os.path.isfile(input_path):
212 # Single file
213 return [input_path]
214 else:
215 raise ValueError(f"Input path does not exist: {input_path}")
216 elif isinstance(input_path, list):
217 # List of files: validate each exists
218 for file_path in input_path:
219 if not os.path.isfile(file_path):
220 raise ValueError(f"File does not exist: {file_path}")
221 return input_path
222 else:
223 raise ValueError(f"Invalid input_path type: {type(input_path)}")
224
225
226def write_jsonl_output(

Callers 1

text_to_jsonlFunction · 0.85

Calls 1

Tested by

no test coverage detected