Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data] Error when reading JSONL of lists #47693

Open
scottjlee opened this issue Sep 16, 2024 · 0 comments
Open

[Data] Error when reading JSONL of lists #47693

scottjlee opened this issue Sep 16, 2024 · 0 comments
Labels
bug Something that is supposed to be working; but isn't data Ray Data-related issues P1 Issue that should be fixed within a few weeks

Comments

@scottjlee
Copy link
Contributor

What happened + What you expected to happen

For the following sample.jsonl file:

{"messages": [{"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": [{"type": "text", "text": "What is this?"}, {"type": "image", "image": ["data:image/jpeg;base64,aaa"]}]}]}

When we read with ray.data.read_json:

import ray
ray.data.read_json("sample.jsonl")

We get the following error:

File "/home/ray/anaconda3/lib/python3.11/site-packages/ray/anyscale/data/_internal/readers/file_reader.py", line 157, in read_paths
    yield from _read_paths(paths)
  File "/home/ray/anaconda3/lib/python3.11/site-packages/ray/anyscale/data/_internal/readers/file_reader.py", line 143, in _read_paths
    for batch in self.read_stream(file, path):
  File "/home/ray/anaconda3/lib/python3.11/site-packages/ray/anyscale/data/_internal/readers/json_reader.py", line 48, in read_stream
    yield from self._read_with_python_json(buffer)
  File "/home/ray/anaconda3/lib/python3.11/site-packages/ray/anyscale/data/_internal/readers/json_reader.py", line 119, in _read_with_python_json
    for k, v in row.items():
                ^^^^^^^^^
AttributeError: 'str' object has no attribute 'items'

We would expect to be able to read the file successfully, since the following works:

import json
with open("sample.jsonl", "r") as f:
    for line in f:
        json.loads(line)

Versions / Dependencies

ray master

Reproduction script

See above

Issue Severity

Medium: It is a significant difficulty but I can work around it.

@scottjlee scottjlee added bug Something that is supposed to be working; but isn't triage Needs triage (eg: priority, bug/not-bug, and owning component) P1 Issue that should be fixed within a few weeks data Ray Data-related issues and removed triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is supposed to be working; but isn't data Ray Data-related issues P1 Issue that should be fixed within a few weeks
Projects
None yet
Development

No branches or pull requests

1 participant