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

Function generate_sample_data_csv

python/ray/data/tests/test_checkpoint.py:67–85  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

65
66@pytest.fixture
67def generate_sample_data_csv(tmp_path):
68 def _generate(id_type: Literal["int", "str"] = "int"):
69 # Generate a dummy dataset with SAMPLE_DATA_NUM_ROWS rows and columns [ID_COL, "col1"]
70 ids = (
71 [f"id_{i}" for i in range(SAMPLE_DATA_NUM_ROWS)]
72 if id_type == "str"
73 else list(range(SAMPLE_DATA_NUM_ROWS))
74 )
75
76 data = [{ID_COL: id_val, "col1": random.random()} for id_val in ids]
77
78 f_path = os.path.join(tmp_path, "sample_data.csv")
79 with open(f_path, mode="w", newline="") as file:
80 writer = csv.DictWriter(file, fieldnames=data[0].keys())
81 writer.writeheader()
82 writer.writerows(data)
83 return f_path
84
85 return _generate
86
87
88@pytest.fixture

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…