{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "import os\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "# load the original json filtered list and compare to the new one\n",
    "json_v3 = \"/home/christian/code/christian/metadata/v45_splits/info_tr_ft_v3.json\"\n",
    "json_v4 = \"/home/christian/code/christian/metadata/v45_splits/info_tr_ft_v4.json\"\n",
    "\n",
    "with open(json_v3, \"r\") as f:\n",
    "    data_v3 = json.load(f)\n",
    "\n",
    "with open(json_v4, \"r\") as f:\n",
    "    data_v4 = json.load(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "json_v4 = \"/app/suno/data/chirp_v5_ft/v1/info_tr_ft_v8.json\"\n",
    "json_v4 = \"/home/christian/code/christian/metadata/v45_splits/info_tr_ft_v10.json\"\n",
    "\n",
    "with open(json_v4, \"r\") as f:\n",
    "    data_v4 = json.load(f)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for key, val in data_v4.items():\n",
    "    print(key)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# remove any keys from the dict if the length of idx_list is 0\n",
    "new_data_v4 = {}\n",
    "for key, val in data_v4.items():\n",
    "    if key == \"pond5\":\n",
    "        continue\n",
    "    if \"idx_list\" in val:\n",
    "        if len(val[\"idx_list\"]) > 0:\n",
    "            new_data_v4[key] = val\n",
    "    else:\n",
    "        new_data_v4[key] = val\n",
    "\n",
    "for key, val in new_data_v4.items():\n",
    "    print(key)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# save this back to json\n",
    "new_json_v4 = \"/app/suno/data/chirp_v5_ft/v2/info_tr_ft_v10_f1.json\"\n",
    "with open(new_json_v4, \"w\") as f:\n",
    "    json.dump(new_data_v4, f)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for key, val in new_data_v4.items():\n",
    "    print(key)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "suno_env",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
