richtige Filename für den pool Lookup

This commit is contained in:
Lars committed 2025-12-27 06:31:57 +01:00
1 parent c676c8263f
commit 82c7752266
2 files changed
+51 -27

No files matched your search

+24 -12
View File
@@ -3,8 +3,9 @@
scripts/import_markdown.py
CLI-Tool zum Importieren von Markdown-Dateien in Qdrant.
WP-15b: Implementiert den Two-Pass Workflow (Pre-Scan + Processing).
Sorgt dafür, dass der LocalBatchCache vor der Verarbeitung gefüllt wird.
VERSION: 2.4.0
Sorgt dafür, dass der LocalBatchCache vor der Verarbeitung robust gefüllt wird.
Indiziert Notizen nach ID, Titel und Dateiname für maximale Link-Kompatibilität.
VERSION: 2.4.1
"""
import asyncio
import os
@@ -13,10 +14,10 @@ import logging
from pathlib import Path
from dotenv import load_dotenv
# Setzt das Level global auf INFO, damit Sie den Fortschritt sehen
# Setzt das Level global auf INFO, damit der Fortschritt im Log sichtbar ist
logging.basicConfig(level=logging.INFO, format='%(asctime)s [%(levelname)s] %(message)s')
# Importiere den neuen Async Service
# Importiere den neuen Async Service und stelle Python-Pfad sicher
import sys
sys.path.append(os.getcwd())
@@ -44,30 +45,41 @@ async def main_async(args):
logger.info(f"Found {len(files)} markdown files.")
# =========================================================================
# PASS 1: Global Pre-Scan (WP-15b)
# PASS 1: Global Pre-Scan (WP-15b Harvester)
# Füllt den LocalBatchCache für die semantische Kanten-Validierung.
# Nutzt ID, Titel und Filename für robusten Look-up.
# =========================================================================
logger.info(f"🔍 [Pass 1] Pre-scanning {len(files)} files for global context cache...")
for f_path in files:
try:
ctx = pre_scan_markdown(str(f_path))
if ctx:
# 1. Look-up via Note ID (UUID oder Frontmatter ID)
service.batch_cache[ctx.note_id] = ctx
# 2. Look-up via Titel (Wichtig für Wikilinks [[Titel]])
service.batch_cache[ctx.title] = ctx
# 3. Look-up via Dateiname (Wichtig für Wikilinks [[Filename]])
fname = os.path.splitext(f_path.name)[0]
service.batch_cache[fname] = ctx
except Exception as e:
logger.warning(f"⚠️ Could not pre-scan {f_path}: {e}")
logger.warning(f"⚠️ Could not pre-scan {f_path.name}: {e}")
logger.info(f"✅ Cache populated with {len(service.batch_cache)} note contexts.")
logger.info(f"✅ Context Cache populated for {len(files)} notes.")
# =========================================================================
# PASS 2: Processing (Batch-Verarbeitung)
# PASS 2: Processing (Semantic Batch-Verarbeitung)
# Nutzt den gefüllten Cache zur binären Validierung semantischer Kanten.
# =========================================================================
stats = {"processed": 0, "skipped": 0, "errors": 0}
sem = asyncio.Semaphore(5) # Max 5 parallele Dateien für Stabilität
sem = asyncio.Semaphore(5) # Max 5 parallele Dateien für Cloud-Stabilität
async def process_with_limit(f_path):
async with sem:
try:
# Nutzt den nun gefüllten Batch-Cache für die Validierung
# Nutzt den nun gefüllten Batch-Cache in der process_file Logik
res = await service.process_file(
file_path=str(f_path),
vault_root=str(vault_path),
@@ -106,7 +118,7 @@ def main():
load_dotenv()
default_prefix = os.getenv("COLLECTION_PREFIX", "mindnet")
parser = argparse.ArgumentParser(description="Import Vault to Qdrant (Two-Pass Ingestion)")
parser = argparse.ArgumentParser(description="Two-Pass Markdown Ingestion for Mindnet")
parser.add_argument("--vault", default="./vault", help="Path to vault root")
parser.add_argument("--prefix", default=default_prefix, help="Collection prefix")
parser.add_argument("--force", action="store_true", help="Force re-index all files")
@@ -114,7 +126,7 @@ def main():
args = parser.parse_args()
# Starte den Async Loop
# Starte den asynchronen Haupt-Loop
asyncio.run(main_async(args))
if __name__ == "__main__":