Cambios a las 3 bases Model mapper repo para que funcionen a partir de las clases heredando todos los metodos comunes

This commit is contained in:
2025-05-12 01:24:44 +02:00
parent 712bd877b8
commit bf1814bb8e
18 changed files with 992 additions and 361 deletions
+80 -34
View File
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 1,
"id": "255345d5",
"metadata": {},
"outputs": [],
@@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 2,
"id": "b414a66c",
"metadata": {},
"outputs": [],
@@ -93,7 +93,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 9,
"id": "8e57e511",
"metadata": {},
"outputs": [
@@ -104,24 +104,24 @@
"[INFO] Iniciando el proceso de agregar nota a la biblioteca...\n",
"[INFO] Buscando biblioteca con ID: BBLI20250511-a91dbb2168172979414\n",
"[INFO] Biblioteca encontrada: biblio_Pruebas_1 (vector_dim=3072)\n",
"[INFO] Creando objeto Nota con título: sajdhasjdhasjdh\n",
"[DEBUG] Nota creada: titulo='sajdhasjdhasjdh', texto_len=0, tags=0, conexiones=0, resumen_len=0\n",
"[INFO] Creando objeto Nota con título: fdsfdsfsdfewww\n",
"[DEBUG] Nota creada: titulo='fdsfdsfsdfewww', texto_len=0, tags=0, conexiones=0, resumen_len=0\n",
"[INFO] Generando tabla y modelo de Nota para la biblioteca: biblio_Pruebas_1\n",
"[INFO] Creando tabla en la base de datos si no existe...\n",
"[INFO] Tabla 'biblio_pruebas_1' verificada/creada.\n",
"[INFO] Guardando nota en la base de datos...\n",
"[INFO] Nota guardada con ID: NOTA20250511-04dbb203a9126228444\n",
"[SUCCESS] Nota 'sajdhasjdhasjdh' agregada con éxito a la biblioteca 'biblio_Pruebas_1'.\n"
"[INFO] Nota guardada con ID: NOTA20250511-0cf0187e58905045667\n",
"[SUCCESS] Nota 'fdsfdsfsdfewww' agregada con éxito a la biblioteca 'biblio_Pruebas_1'.\n"
]
},
{
"data": {
"text/plain": [
"{'mensaje': \"Nota 'sajdhasjdhasjdh' agregada con éxito a la biblioteca 'biblio_Pruebas_1'.\",\n",
" 'nota_id': 'NOTA20250511-04dbb203a9126228444'}"
"{'mensaje': \"Nota 'fdsfdsfsdfewww' agregada con éxito a la biblioteca 'biblio_Pruebas_1'.\",\n",
" 'nota_id': 'NOTA20250511-0cf0187e58905045667'}"
]
},
"execution_count": 11,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
@@ -133,13 +133,13 @@
"agregar_nota_a_biblioteca(\n",
" conexion=conexion_admin,\n",
" biblioteca_id=\"BBLI20250511-a91dbb2168172979414\",\n",
" titulo=\"sajdhasjdhasjdh\"\n",
" titulo=\"fdsfdsfsdfewww\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"id": "431f24f1",
"metadata": {},
"outputs": [],
@@ -171,32 +171,78 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"id": "ae4f2994",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"E:\\Fitz_Studio\\src\\TextManager\\notas_biblioteca_mmr.py:51: SAWarning: This declarative base already contains a class with the same class name and module name as src.TextManager.notas_biblioteca_mmr.NotaModel, and will be replaced in the string-lookup table.\n",
" mapper_registry.map_imperatively(NotaModel, tabla)\n"
]
},
{
"ename": "TypeError",
"evalue": "'NoneType' object is not iterable",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mTypeError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[14]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mlistar_notas_de_biblioteca\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 2\u001b[39m \u001b[43m \u001b[49m\u001b[43mconexion\u001b[49m\u001b[43m=\u001b[49m\u001b[43mconexion_admin\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3\u001b[39m \u001b[43m \u001b[49m\u001b[43mbiblioteca_id\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mBBLI20250511-a91dbb2168172979414\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\n\u001b[32m 4\u001b[39m \u001b[43m)\u001b[49m\n",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[13]\u001b[39m\u001b[32m, line 12\u001b[39m, in \u001b[36mlistar_notas_de_biblioteca\u001b[39m\u001b[34m(conexion, biblioteca_id)\u001b[39m\n\u001b[32m 9\u001b[39m metadata.create_all(conexion.get_engine())\n\u001b[32m 11\u001b[39m repo_nota = NotaRepo(conexion.get_session(), ModeloNota)\n\u001b[32m---> \u001b[39m\u001b[32m12\u001b[39m notas = \u001b[43mrepo_nota\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_all\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 13\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m [\n\u001b[32m 14\u001b[39m {\n\u001b[32m 15\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mid\u001b[39m\u001b[33m\"\u001b[39m: n.id,\n\u001b[32m (...)\u001b[39m\u001b[32m 22\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m n \u001b[38;5;129;01min\u001b[39;00m notas\n\u001b[32m 23\u001b[39m ]\n",
"\u001b[36mFile \u001b[39m\u001b[32mE:\\Fitz_Studio\\src\\TextManager\\notas_biblioteca_mmr.py:109\u001b[39m, in \u001b[36mget_all\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 0\u001b[39m <Error retrieving source code with stack_data see ipython/ipython#13598>\n",
"\u001b[36mFile \u001b[39m\u001b[32mE:\\Fitz_Studio\\src\\TextManager\\notas_biblioteca_mmr.py:109\u001b[39m, in \u001b[36m<listcomp>\u001b[39m\u001b[34m(.0)\u001b[39m\n\u001b[32m 0\u001b[39m <Error retrieving source code with stack_data see ipython/ipython#13598>\n",
"\u001b[36mFile \u001b[39m\u001b[32mE:\\Fitz_Studio\\src\\TextManager\\notas_biblioteca_mmr.py:82\u001b[39m, in \u001b[36mfrom_model\u001b[39m\u001b[34m(model)\u001b[39m\n\u001b[32m 76\u001b[39m \u001b[38;5;129m@staticmethod\u001b[39m\n\u001b[32m 77\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mfrom_model\u001b[39m(model) -> Nota:\n\u001b[32m 78\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m Nota(\n\u001b[32m 79\u001b[39m \u001b[38;5;28mid\u001b[39m=model.id,\n\u001b[32m 80\u001b[39m titulo=model.titulo,\n\u001b[32m 81\u001b[39m tags=model.tags.split(\u001b[33m\"\u001b[39m\u001b[33m,\u001b[39m\u001b[33m\"\u001b[39m) \u001b[38;5;28;01mif\u001b[39;00m model.tags \u001b[38;5;28;01melse\u001b[39;00m [],\n\u001b[32m---> \u001b[39m\u001b[32m82\u001b[39m conexiones=model.conexiones.split(\u001b[33m\"\u001b[39m\u001b[33m,\u001b[39m\u001b[33m\"\u001b[39m) \u001b[38;5;28;01mif\u001b[39;00m model.conexiones \u001b[38;5;28;01melse\u001b[39;00m [],\n\u001b[32m 83\u001b[39m texto=model.texto,\n\u001b[32m 84\u001b[39m resumen=model.resumen,\n\u001b[32m 85\u001b[39m vector=\u001b[38;5;28mlist\u001b[39m(model.vector),\n\u001b[32m 86\u001b[39m vector_resumen=\u001b[38;5;28mlist\u001b[39m(model.vector_resumen) \u001b[38;5;28;01mif\u001b[39;00m model.vector_resumen \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 87\u001b[39m )\n",
"\u001b[31mTypeError\u001b[39m: 'NoneType' object is not iterable"
]
"data": {
"text/plain": [
"[{'id': 'NOTA20250511-6cf9b177a2249549641',\n",
" 'titulo': 'Hola que tal',\n",
" 'tags': [],\n",
" 'texto': '',\n",
" 'resumen': '',\n",
" 'conexiones': []},\n",
" {'id': 'NOTA20250511-664831e1bd118315114',\n",
" 'titulo': 'Holoooo',\n",
" 'tags': [],\n",
" 'texto': '',\n",
" 'resumen': '',\n",
" 'conexiones': []},\n",
" {'id': 'NOTA20250511-04dbb203a9126228444',\n",
" 'titulo': 'sajdhasjdhasjdh',\n",
" 'tags': [],\n",
" 'texto': '',\n",
" 'resumen': '',\n",
" 'conexiones': []},\n",
" {'id': 'NOTA20250511-668f68e425271569668',\n",
" 'titulo': 'fsdfdf',\n",
" 'tags': [],\n",
" 'texto': '',\n",
" 'resumen': '',\n",
" 'conexiones': []},\n",
" {'id': 'NOTA20250511-a6ad7166d5660286632',\n",
" 'titulo': 'fsdfdf',\n",
" 'tags': [],\n",
" 'texto': '',\n",
" 'resumen': '',\n",
" 'conexiones': []},\n",
" {'id': 'NOTA20250511-639fa883c2266940759',\n",
" 'titulo': 'fsdfdf',\n",
" 'tags': [],\n",
" 'texto': '',\n",
" 'resumen': '',\n",
" 'conexiones': []},\n",
" {'id': 'NOTA20250511-27e86a8da6529002860',\n",
" 'titulo': 'fsdfdf',\n",
" 'tags': [],\n",
" 'texto': '',\n",
" 'resumen': '',\n",
" 'conexiones': []},\n",
" {'id': 'NOTA20250511-06479aca23973772356',\n",
" 'titulo': 'fsdfdf',\n",
" 'tags': [],\n",
" 'texto': '',\n",
" 'resumen': '',\n",
" 'conexiones': []},\n",
" {'id': 'NOTA20250511-0d577e3336174429305',\n",
" 'titulo': 'fdsfdsfsdfewww',\n",
" 'tags': [],\n",
" 'texto': '',\n",
" 'resumen': '',\n",
" 'conexiones': []},\n",
" {'id': 'NOTA20250511-0cf0187e58905045667',\n",
" 'titulo': 'fdsfdsfsdfewww',\n",
" 'tags': [],\n",
" 'texto': '',\n",
" 'resumen': '',\n",
" 'conexiones': []}]"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [