Skip to content

Commit

Permalink
add function to relink kantodata data
Browse files Browse the repository at this point in the history
  • Loading branch information
nilomr committed May 21, 2022
1 parent f2be19e commit 034dd35
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/scratchpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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])

Expand Down

0 comments on commit 034dd35

Please sign in to comment.