MCPcopy Index your code
hub / github.com/evalplus/evalplus / stream_jsonl

Function stream_jsonl

evalplus/data/utils.py:74–88  ·  view source on GitHub ↗

Parses each jsonl line and yields it as a dictionary

(filename: str)

Source from the content-addressed store, hash-verified

72
73
74def 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
91def load_solutions(sample_path: PathLike) -> Iterable[Dict]:

Callers 5

filter_extreme.pyFile · 0.90
scriptFunction · 0.90
get_human_eval_plusFunction · 0.90
get_mbpp_plusFunction · 0.90
load_solutionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected