in 3_optimization-design-ptn/03_prompt-optimization/promptwizard/glue/common/utils/file.py [0:0]
def read_jsonl_row(file_path: str):
"""
:param file_path:
:return: Single line from the file. One at a time.
"""
with open(file_path, "r") as fileobj:
while True:
try:
single_row = fileobj.readline()
if not single_row:
break
json_object = json.loads(single_row.strip())
yield json_object
except json.JSONDecodeError as e:
print(f"Error while reading jsonl file at {file_path}. Error: {e}")
continue