{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "2ab337fd-a432-4da7-9614-cc75a41140f8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The autoreload extension is already loaded. To reload it, use:\n",
      "  %reload_ext autoreload\n"
     ]
    }
   ],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2\n",
    "\n",
    "from suno_utils.labeler.client import SunoAPIClient"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "54267583-f892-4999-a882-f3d9cafab062",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "suno_utils.labeler.client.SunoAPIClient"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "SunoAPIClient"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "74241d62-de14-4630-be35-96f8963e76e6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Token here https://datasets.suno.ai/console/settings\n",
    "# Change url to https://datasets.suno.ai/graphql/\n",
    "api = SunoAPIClient(api_url='http://localhost:8000/graphql/', token='97aacb8c0726411a9cfe6c6f69fe14a7')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "60967111-7ce4-43d5-a0b2-ad6274899f82",
   "metadata": {},
   "outputs": [],
   "source": [
    "p = api.create_project(name='API TEST')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "416e8f22-3b7c-48e3-b572-a43e8b8547e3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': 'ab38272f-6c5d-4203-ac5a-83d65f18f6a2',\n",
       "  'metadata': {'type': 'audio', 'transcriptTest': 'test prefill'},\n",
       "  'externalId': '0a28ae37-968a-4488-b593-d9b83e1c0cd4.mp3',\n",
       "  'storageKey': 'studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/cb405308-9a07-4361-883d-563e1c8e5a54.wav'},\n",
       " {'id': 'a09d8b7b-6bcc-4b89-8ea2-46dcef6d5219',\n",
       "  'metadata': {'type': 'audio', 'transcriptTest2': 'test prefill2'},\n",
       "  'externalId': '0bc0b102-70bf-40d5-908c-5a0089d794a8.mp3',\n",
       "  'storageKey': 'studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/959c6575-f5e8-4806-b702-40967e8ffe08.wav'},\n",
       " {'id': '4e5561b7-e26a-4820-af14-c05ec64d5981',\n",
       "  'metadata': {'type': 'audio'},\n",
       "  'externalId': '00c60b44-6d28-4e94-b779-bf2fed9922a4.mp3',\n",
       "  'storageKey': 'studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/b5a4b8e8-81c0-49c1-9cfe-65e193b5004f.wav'}]"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Create datums (all fields required)\n",
    "# Can prefill fields by using metadata fields.\n",
    "datums = [\n",
    "          {\n",
    "            \"metadata\": {\n",
    "              \"type\": \"audio\",\n",
    "              \"transcriptTest\": \"test prefill\",\n",
    "            },\n",
    "            \"externalId\": \"0a28ae37-968a-4488-b593-d9b83e1c0cd4.mp3\",\n",
    "            \"storageKey\": \"studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/cb405308-9a07-4361-883d-563e1c8e5a54.wav\"\n",
    "          },\n",
    "          {\n",
    "            \"metadata\": {\n",
    "              \"type\": \"audio\",\n",
    "              \"transcriptTest2\": \"test prefill2\",\n",
    "            },\n",
    "            \"externalId\": \"0bc0b102-70bf-40d5-908c-5a0089d794a8.mp3\",\n",
    "            \"storageKey\": \"studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/959c6575-f5e8-4806-b702-40967e8ffe08.wav\"\n",
    "          },\n",
    "          {\n",
    "            \"metadata\": {\n",
    "              \"type\": \"audio\",\n",
    "                \"transcriptTest\": \"test prefill\",\n",
    "                \"transcriptTest2\": \"test prefill2\",\n",
    "            },\n",
    "            \"externalId\": \"00c60b44-6d28-4e94-b779-bf2fed9922a4.mp3\",\n",
    "            \"storageKey\": \"studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/b5a4b8e8-81c0-49c1-9cfe-65e193b5004f.wav\"\n",
    "          },\n",
    "]\n",
    "\n",
    "p.add_data(datums)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "7c089027-4faa-4b21-a53f-6559e7d2b25b",
   "metadata": {},
   "outputs": [],
   "source": [
    "task_config_meta = {\n",
    "    \"blocks\": [\n",
    "        {\"data\": {\"key\": \"url\"}, \"type\": \"audio\", \"props\": {\"complex\": True}}, \n",
    "        {\"data\": {\"key\": \"transcriptTest\"}, \"type\": \"textarea\", \"props\": {\"placeholder\": \"Normalized\"}}, \n",
    "        {\"data\": {\"key\": \"transcriptTest2\"}, \"type\": \"textarea\", \"props\": {\"placeholder\": \"Orthographica\"}}\n",
    "    ]\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "45cf88a3-d677-4288-b2ad-bf9e0afc628c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 'a2452381-b3aa-4e50-999e-0ec0b1d47dba',\n",
       " 'name': 'Test',\n",
       " 'metadata': {'blocks': [{'data': {'key': 'url'},\n",
       "    'type': 'audio',\n",
       "    'props': {'complex': True}},\n",
       "   {'data': {'key': 'transcriptTest'},\n",
       "    'type': 'textarea',\n",
       "    'props': {'placeholder': 'Normalized'}},\n",
       "   {'data': {'key': 'transcriptTest2'},\n",
       "    'type': 'textarea',\n",
       "    'props': {'placeholder': 'Orthographica'}}]}}"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p.create_task_config({'name': 'Test', 'metadata': task_config_meta})\n",
    "# Once created, you can go https://console.suno.ai/ and click on the project and start labeling."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "07173b80-97fc-4836-96d3-a588200ac300",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': 'b09abe9c-b2d7-4e28-adfd-500e184f8fec',\n",
       "  'metadata': {'type': 'audio'},\n",
       "  'externalId': '0a28ae37-968a-4488-b593-d9b83e1c0cd4.mp3',\n",
       "  'storageKey': 'studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/cb405308-9a07-4361-883d-563e1c8e5a54.wav',\n",
       "  'results': [{'id': 'e42d04d2-d6a0-46f7-b1bb-d76d8bf10103',\n",
       "    'updatedAt': '2022-09-22T18:25:06.246776+00:00',\n",
       "    'taskConfig': {'id': 'a2452381-b3aa-4e50-999e-0ec0b1d47dba',\n",
       "     'name': 'Test'},\n",
       "    'data': {'url': 'https://suno-data-uploads.s3.amazonaws.com/studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/cb405308-9a07-4361-883d-563e1c8e5a54.wav?AWSAccessKeyId=AKIA2V4GXGDKHOW5QKPA&Signature=yL9Xgw5aEXmj%2Fyj1z4FUD28v7yA%3D&Expires=1663899903',\n",
       "     'transcriptTest': 'test',\n",
       "     'transcriptTest2': 'test'},\n",
       "    'user': {'email': 'martin@suno.ai'}}]},\n",
       " {'id': 'db1924ed-824c-4ad6-ae69-f5c26f474d6b',\n",
       "  'metadata': {'type': 'audio'},\n",
       "  'externalId': '0bc0b102-70bf-40d5-908c-5a0089d794a8.mp3',\n",
       "  'storageKey': 'studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/959c6575-f5e8-4806-b702-40967e8ffe08.wav',\n",
       "  'results': [{'id': '16f3a562-278c-448d-aca0-37cb7652fd94',\n",
       "    'updatedAt': '2022-09-22T18:25:09.009265+00:00',\n",
       "    'taskConfig': {'id': 'a2452381-b3aa-4e50-999e-0ec0b1d47dba',\n",
       "     'name': 'Test'},\n",
       "    'data': {'url': 'https://suno-data-uploads.s3.amazonaws.com/studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/959c6575-f5e8-4806-b702-40967e8ffe08.wav?AWSAccessKeyId=AKIA2V4GXGDKHOW5QKPA&Signature=idwDitP%2F8uCdNhO%2FbVCdRrZ1Sj0%3D&Expires=1663899906',\n",
       "     'transcriptTest': 'test2',\n",
       "     'transcriptTest2': 'test2'},\n",
       "    'user': {'email': 'martin@suno.ai'}}]},\n",
       " {'id': '4faf1f8c-081e-4483-a5d7-24061ad6e880',\n",
       "  'metadata': {'type': 'audio'},\n",
       "  'externalId': '00c60b44-6d28-4e94-b779-bf2fed9922a4.mp3',\n",
       "  'storageKey': 'studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/b5a4b8e8-81c0-49c1-9cfe-65e193b5004f.wav',\n",
       "  'results': [{'id': 'e1eb10e6-0c9a-428c-8220-15a0c3990228',\n",
       "    'updatedAt': '2022-09-22T18:25:16.739544+00:00',\n",
       "    'taskConfig': {'id': 'a2452381-b3aa-4e50-999e-0ec0b1d47dba',\n",
       "     'name': 'Test'},\n",
       "    'data': {'url': 'https://suno-data-uploads.s3.amazonaws.com/studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/b5a4b8e8-81c0-49c1-9cfe-65e193b5004f.wav?AWSAccessKeyId=AKIA2V4GXGDKHOW5QKPA&Signature=cENtUwni6CNn3mO24Ix0QssTGYc%3D&Expires=1663899909',\n",
       "     'transcriptTest': 'whereas on my end',\n",
       "     'transcriptTest2': 'test3'},\n",
       "    'user': {'email': 'martin@suno.ai'}}]},\n",
       " {'id': 'd763b48b-41fb-486a-8b1f-093b76759aeb',\n",
       "  'metadata': {'type': 'audio'},\n",
       "  'externalId': '0a28ae37-968a-4488-b593-d9b83e1c0cd4.mp3',\n",
       "  'storageKey': 'studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/cb405308-9a07-4361-883d-563e1c8e5a54.wav',\n",
       "  'results': [{'id': '37a43fcb-e47b-43aa-886a-4f906debf8df',\n",
       "    'updatedAt': '2022-09-23T16:04:14.270829+00:00',\n",
       "    'taskConfig': {'id': 'a2452381-b3aa-4e50-999e-0ec0b1d47dba',\n",
       "     'name': 'Test'},\n",
       "    'data': {'url': 'https://suno-data-uploads.s3.amazonaws.com/studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/cb405308-9a07-4361-883d-563e1c8e5a54.wav?AWSAccessKeyId=AKIA2V4GXGDKHOW5QKPA&Signature=x99IkSpnvvcRnN8nfvCBk1ooh5o%3D&Expires=1663977847',\n",
       "     'type': 'audio'},\n",
       "    'user': {'email': 'martin@suno.ai'}}]},\n",
       " {'id': '807d83e1-b26b-4db9-bd53-3ad92af0d7b8',\n",
       "  'metadata': {'type': 'audio'},\n",
       "  'externalId': '0bc0b102-70bf-40d5-908c-5a0089d794a8.mp3',\n",
       "  'storageKey': 'studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/959c6575-f5e8-4806-b702-40967e8ffe08.wav',\n",
       "  'results': [{'id': '5ebea460-7a9f-4b42-979d-4b753b222b89',\n",
       "    'updatedAt': '2022-09-23T16:04:15.437688+00:00',\n",
       "    'taskConfig': {'id': 'a2452381-b3aa-4e50-999e-0ec0b1d47dba',\n",
       "     'name': 'Test'},\n",
       "    'data': {'url': 'https://suno-data-uploads.s3.amazonaws.com/studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/959c6575-f5e8-4806-b702-40967e8ffe08.wav?AWSAccessKeyId=AKIA2V4GXGDKHOW5QKPA&Signature=fFK8rE97%2FqiNYMIbLgHnmpr5RyU%3D&Expires=1663977854',\n",
       "     'type': 'audio'},\n",
       "    'user': {'email': 'martin@suno.ai'}}]},\n",
       " {'id': 'ca38dcbd-e1f7-48a4-8a4e-427d928f4908',\n",
       "  'metadata': {'type': 'audio'},\n",
       "  'externalId': '00c60b44-6d28-4e94-b779-bf2fed9922a4.mp3',\n",
       "  'storageKey': 'studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/b5a4b8e8-81c0-49c1-9cfe-65e193b5004f.wav',\n",
       "  'results': [{'id': '6b28582f-4890-459e-8ced-acd684cdfe14',\n",
       "    'updatedAt': '2022-09-23T16:04:16.201779+00:00',\n",
       "    'taskConfig': {'id': 'a2452381-b3aa-4e50-999e-0ec0b1d47dba',\n",
       "     'name': 'Test'},\n",
       "    'data': {'url': 'https://suno-data-uploads.s3.amazonaws.com/studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/b5a4b8e8-81c0-49c1-9cfe-65e193b5004f.wav?AWSAccessKeyId=AKIA2V4GXGDKHOW5QKPA&Signature=eobwuHt82djb06wG3%2B7wLeYZZBE%3D&Expires=1663977855',\n",
       "     'type': 'audio'},\n",
       "    'user': {'email': 'martin@suno.ai'}}]},\n",
       " {'id': 'ab38272f-6c5d-4203-ac5a-83d65f18f6a2',\n",
       "  'metadata': {'type': 'audio', 'transcriptTest': 'test prefill'},\n",
       "  'externalId': '0a28ae37-968a-4488-b593-d9b83e1c0cd4.mp3',\n",
       "  'storageKey': 'studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/cb405308-9a07-4361-883d-563e1c8e5a54.wav',\n",
       "  'results': [{'id': '9a0dc58b-5b9f-4bcb-a31b-4487685e21c0',\n",
       "    'updatedAt': '2022-09-23T16:04:37.413772+00:00',\n",
       "    'taskConfig': {'id': 'a2452381-b3aa-4e50-999e-0ec0b1d47dba',\n",
       "     'name': 'Test'},\n",
       "    'data': {'url': 'https://suno-data-uploads.s3.amazonaws.com/studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/cb405308-9a07-4361-883d-563e1c8e5a54.wav?AWSAccessKeyId=AKIA2V4GXGDKHOW5QKPA&Signature=K6N660Fbd%2FTJHflQFEkgyA6%2BR18%3D&Expires=1663977856',\n",
       "     'type': 'audio',\n",
       "     'transcriptTest': 'test prefilljkjhasdf',\n",
       "     'transcriptTest2': 'dfasdf'},\n",
       "    'user': {'email': 'martin@suno.ai'}}]},\n",
       " {'id': 'a09d8b7b-6bcc-4b89-8ea2-46dcef6d5219',\n",
       "  'metadata': {'type': 'audio', 'transcriptTest2': 'test prefill2'},\n",
       "  'externalId': '0bc0b102-70bf-40d5-908c-5a0089d794a8.mp3',\n",
       "  'storageKey': 'studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/959c6575-f5e8-4806-b702-40967e8ffe08.wav',\n",
       "  'results': [{'id': '934ea6c5-2eac-4eaf-9716-e1f3b421b75e',\n",
       "    'updatedAt': '2022-09-23T16:04:39.260348+00:00',\n",
       "    'taskConfig': {'id': 'a2452381-b3aa-4e50-999e-0ec0b1d47dba',\n",
       "     'name': 'Test'},\n",
       "    'data': {'url': 'https://suno-data-uploads.s3.amazonaws.com/studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/959c6575-f5e8-4806-b702-40967e8ffe08.wav?AWSAccessKeyId=AKIA2V4GXGDKHOW5QKPA&Signature=F9vkrlZqK%2Ftabw6%2BXQjechzlcjc%3D&Expires=1663977877',\n",
       "     'type': 'audio',\n",
       "     'transcriptTest': '3r32f',\n",
       "     'transcriptTest2': 'test prefill2'},\n",
       "    'user': {'email': 'martin@suno.ai'}}]},\n",
       " {'id': '4e5561b7-e26a-4820-af14-c05ec64d5981',\n",
       "  'metadata': {'type': 'audio'},\n",
       "  'externalId': '00c60b44-6d28-4e94-b779-bf2fed9922a4.mp3',\n",
       "  'storageKey': 'studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/b5a4b8e8-81c0-49c1-9cfe-65e193b5004f.wav',\n",
       "  'results': [{'id': '853cc87c-1db1-4264-b912-4401573b005b',\n",
       "    'updatedAt': '2022-09-23T16:04:40.248482+00:00',\n",
       "    'taskConfig': {'id': 'a2452381-b3aa-4e50-999e-0ec0b1d47dba',\n",
       "     'name': 'Test'},\n",
       "    'data': {'url': 'https://suno-data-uploads.s3.amazonaws.com/studio/projects/249630e1-1257-4727-9941-ff2bf84eedd9/b5a4b8e8-81c0-49c1-9cfe-65e193b5004f.wav?AWSAccessKeyId=AKIA2V4GXGDKHOW5QKPA&Signature=0njpXv7PAW6GzlETPegadqQCdmM%3D&Expires=1663977879',\n",
       "     'type': 'audio'},\n",
       "    'user': {'email': 'martin@suno.ai'}}]}]"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p.list_data()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "911f3e95-5065-4ecd-a536-e58b52b08495",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
