MCPcopy
hub / github.com/ray-project/ray / test_json_read

Function test_json_read

python/ray/data/tests/datasource/test_json.py:27–39  ·  view source on GitHub ↗
(
    ray_start_regular_shared, target_max_block_size_infinite_or_default, tmp_path
)

Source from the content-addressed store, hash-verified

25
26
27def test_json_read(
28 ray_start_regular_shared, target_max_block_size_infinite_or_default, tmp_path
29):
30 df1 = pd.DataFrame({"one": [1, 2, 3], "two": ["a", "b", "c"]})
31 path1 = os.path.join(tmp_path, "test1.json")
32 df1.to_json(path1, orient="records", lines=True)
33 ds = ray.data.read_json(path1)
34 dsdf = ds.to_pandas()
35 pd.testing.assert_frame_equal(df1.astype(dsdf.dtypes.to_dict()), dsdf)
36 # Metadata ops.
37 assert ds.count() == 3
38 assert ds.input_files() == [path1]
39 assert ds.schema() == Schema(pa.schema([("one", pa.int64()), ("two", pa.string())]))
40
41
42def test_zipped_json_read(

Callers

nothing calls this directly

Calls 9

SchemaClass · 0.90
to_jsonMethod · 0.80
astypeMethod · 0.80
joinMethod · 0.45
to_pandasMethod · 0.45
to_dictMethod · 0.45
countMethod · 0.45
input_filesMethod · 0.45
schemaMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…