Return parsed rows from a JSON-Lines file, or `[]` if the file does not exist yet. Blank lines are skipped. The missing-file branch matters for streaming-pipeline tests that may poll for output before the first row lands on disk.
(path: str | pathlib.Path)
| 805 | |
| 806 | |
| 807 | def read_jsonlines(path: str | pathlib.Path) -> list[dict]: |
| 808 | """Return parsed rows from a JSON-Lines file, or `[]` if the file does not |
| 809 | exist yet. Blank lines are skipped. The missing-file branch matters for |
| 810 | streaming-pipeline tests that may poll for output before the first row |
| 811 | lands on disk.""" |
| 812 | path = pathlib.Path(path) |
| 813 | if not path.exists(): |
| 814 | return [] |
| 815 | rows: list[dict] = [] |
| 816 | with open(path) as f: |
| 817 | for line in f: |
| 818 | line = line.strip() |
| 819 | if line: |
| 820 | rows.append(json.loads(line)) |
| 821 | return rows |
| 822 | |
| 823 | |
| 824 | def get_aws_s3_settings(): |