MCPcopy Create free account
hub / github.com/cosdata/cosdata / ensure_dataset_available

Function ensure_dataset_available

tests/test-dataset-streaming.py:276–295  ·  view source on GitHub ↗

Ensure a dataset is downloaded and ready to use

(dataset_name)

Source from the content-addressed store, hash-verified

274 raise
275
276def ensure_dataset_available(dataset_name):
277 """Ensure a dataset is downloaded and ready to use"""
278 # Create datasets directory if it doesn't exist
279 datasets_dir = "datasets"
280 if not os.path.exists(datasets_dir):
281 os.makedirs(datasets_dir)
282 print(f"Created datasets directory at {os.path.abspath(datasets_dir)}")
283
284 # Create dataset-specific directory if it doesn't exist
285 dataset_dir = os.path.join(datasets_dir, dataset_name)
286 if not os.path.exists(dataset_dir):
287 os.makedirs(dataset_dir)
288 print(f"Created dataset directory at {os.path.abspath(dataset_dir)}")
289
290 # Check if dataset files exist
291 if not any(f.endswith('.parquet') for f in os.listdir(dataset_dir)):
292 print(f"Dataset {dataset_name} not found. Downloading...")
293 prepare_dataset(dataset_name)
294 else:
295 print(f"Dataset {dataset_name} is already available at {dataset_dir}")
296
297def prompt_and_get_dataset_metadata():
298 print("\nChoose a dataset to test with:")

Callers 1

Calls 1

prepare_datasetFunction · 0.70

Tested by

no test coverage detected