From 034dd35d3542a28436b8858abb077b898b306314 Mon Sep 17 00:00:00 2001 From: nilomr Date: Sat, 21 May 2022 14:45:59 +0100 Subject: [PATCH] add function to relink kantodata data --- tests/scratchpad.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/scratchpad.py b/tests/scratchpad.py index 9fc7592..6297971 100644 --- a/tests/scratchpad.py +++ b/tests/scratchpad.py @@ -550,6 +550,7 @@ def from_np_array(array_string): parameters=params, overwrite_dataset=True, overwrite_data=True, + random_subset=10, ) out_dir = DIRS.DATA / "datasets" / DATASET_ID / f"{DATASET_ID}.db" dataset = load_dataset(out_dir) @@ -565,7 +566,22 @@ def from_np_array(array_string): shutil.move(out_dir.parent, move_to) moved_dataset = move_to / f"{DATASET_ID}.db" + + +def relink_kantodata(dataset_location: Path, path: Path): + return Path(*dataset_location.parent.parts) / Path(*path.parts[-3:]) + + dataset = load_dataset(moved_dataset) +if not dataset.vocs["spectrogram_loc"][0].is_file(): + dataset.vocs["spectrogram_loc"] = dataset.vocs["spectrogram_loc"].apply( + lambda x: relink_kantodata(moved_dataset, x) + ) +if not dataset.vocs["spectrogram_loc"][0].is_file(): + raise FileNotFoundError("Failed to reconnect spectrogram data") + +print(dataset.DIRS) + dataset.plot(dataset.vocs.index[0])