Parses each jsonl line and yields it as a dictionary
(filename: str)
| 72 | |
| 73 | |
| 74 | def stream_jsonl(filename: str) -> Iterable[Dict]: |
| 75 | """ |
| 76 | Parses each jsonl line and yields it as a dictionary |
| 77 | """ |
| 78 | if filename.endswith(".gz"): |
| 79 | with open(filename, "rb") as gzfp: |
| 80 | with gzip.open(gzfp, "rt") as fp: |
| 81 | for line in fp: |
| 82 | if any(not x.isspace() for x in line): |
| 83 | yield json.loads(line) |
| 84 | else: |
| 85 | with open(filename, "r") as fp: |
| 86 | for line in fp: |
| 87 | if any(not x.isspace() for x in line): |
| 88 | yield json.loads(line) |
| 89 | |
| 90 | |
| 91 | def load_solutions(sample_path: PathLike) -> Iterable[Dict]: |
no outgoing calls
no test coverage detected