MCPcopy Index your code
hub / github.com/zai-org/CodeGeeX2 / stream_jsonl

Function stream_jsonl

evaluation/utils.py:179–193  ·  view source on GitHub ↗

Parses each jsonl line and yields it as a dictionary

(filename: str)

Source from the content-addressed store, hash-verified

177
178
179def stream_jsonl(filename: str) -> Iterable[Dict]:
180 """
181 Parses each jsonl line and yields it as a dictionary
182 """
183 if filename.endswith(".gz"):
184 with open(filename, "rb") as gzfp:
185 with gzip.open(gzfp, "rt") as fp:
186 for line in fp:
187 if any(not x.isspace() for x in line):
188 yield json.loads(line)
189 else:
190 with open(filename, "r") as fp:
191 for line in fp:
192 if any(not x.isspace() for x in line):
193 yield json.loads(line)
194
195
196def stream_jsonl_all(filename: str) -> Iterable[Dict]:

Callers 2

read_datasetFunction · 0.85
read_translation_datasetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected