This commit is contained in:
1 parent
23b1cb2966
commit
e9532e8878
30 files changed
+1835
-542
No files matched your search
+63
-15
@@ -1,22 +1,70 @@
|
||||
#!/usr/bin/env python3
|
||||
# scripts/edges_dryrun.py
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Dry-Run: Erzeuge Edges aus einem Vault **ohne** Qdrant-Upsert.
|
||||
- Liest Markdown mit YAML-Frontmatter
|
||||
- Chunking: einfacher Absatz-Chunker (Index + text)
|
||||
- Kanten: nutzt app.core.edges.build_edges_for_note()
|
||||
- Ausgabe: JSON pro Note mit Edge-Counts und 3 Beispiel-Payloads
|
||||
FILE: scripts/edges_dryrun.py
|
||||
VERSION: 2.1.0 (2025-12-15)
|
||||
STATUS: Active
|
||||
COMPATIBILITY: v2.9.1 (Post-WP14/WP-15b)
|
||||
|
||||
Zweck:
|
||||
-------
|
||||
Simuliert die Edge-Erzeugung aus Markdown-Dateien ohne Datenbank-Upsert.
|
||||
Nützlich zur Analyse, welche Kanten aus einem Vault generiert würden.
|
||||
|
||||
Funktionsweise:
|
||||
---------------
|
||||
1. Scannt alle .md-Dateien im Vault
|
||||
2. Für jede Datei:
|
||||
- Parst Markdown mit Frontmatter
|
||||
- Erstellt einfache Absatz-basierte Chunks (vereinfachtes Chunking)
|
||||
- Extrahiert Edge-Kandidaten via build_edges_for_note():
|
||||
* Wikilinks [[...]]
|
||||
* Typed Relations [[rel:KIND|Target]]
|
||||
* Callout Relations [!edge] KIND: [[Target]]
|
||||
* Struktur-Kanten (belongs_to, next, prev)
|
||||
- Zählt Edges nach Typ (kind/relation)
|
||||
3. Gibt JSON-Report aus mit Edge-Statistiken pro Note
|
||||
|
||||
Ergebnis-Interpretation:
|
||||
------------------------
|
||||
- Ausgabe: JSON-Array mit einem Objekt pro Note
|
||||
- Jedes Objekt enthält:
|
||||
* path: Dateipfad
|
||||
* note_id: Note-Identifier
|
||||
* type: Note-Typ
|
||||
* chunks: Anzahl der Chunks
|
||||
* edges_total: Gesamtanzahl der Edges
|
||||
* edges_by_kind: Dictionary mit Edge-Anzahl pro Typ
|
||||
* samples: Erste 3 Edges als Beispiele
|
||||
|
||||
Verwendung:
|
||||
-----------
|
||||
- Analyse der Graph-Struktur vor dem Import
|
||||
- Debugging von fehlenden oder unerwarteten Edges
|
||||
- Validierung der Edge-Extraktion-Logik
|
||||
|
||||
Hinweise:
|
||||
---------
|
||||
- Verwendet vereinfachtes Chunking (Absatz-basiert), nicht das vollständige Chunking-System
|
||||
- Edge-Extraktion entspricht der Produktions-Logik (app.core.derive_edges)
|
||||
- Keine Datenbank-Operationen, rein analytisch
|
||||
|
||||
Aufruf:
|
||||
python3 -m scripts.edges_dryrun --vault ./vault
|
||||
-------
|
||||
python3 -m scripts.edges_dryrun --vault ./vault
|
||||
python3 -m scripts.edges_dryrun --vault ./vault --include-note-scope-refs
|
||||
|
||||
Optional:
|
||||
--include-note-scope-refs # auch Frontmatter-Links (links[].target_id) als Note-Scope-Referenzen
|
||||
Parameter:
|
||||
----------
|
||||
--vault PATH Pfad zum Vault-Verzeichnis (erforderlich)
|
||||
--include-note-scope-refs Berücksichtigt auch Frontmatter-Links (links[].target_id)
|
||||
|
||||
Voraussetzungen:
|
||||
- app/core/parser.py (read_markdown, normalize_frontmatter)
|
||||
- app/core/edges.py (dieses Modul forwardet zur v2-Implementierung)
|
||||
Änderungen:
|
||||
-----------
|
||||
v2.1.0 (2025-12-15): Kompatibilität mit WP-14 Modularisierung
|
||||
- Geändert: app.core.edges → app.core.derive_edges
|
||||
- Parameter korrigiert: chunk_payloads → chunks, note_level_refs → note_level_references
|
||||
v1.0.0: Erster Release
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -28,7 +76,7 @@ from pathlib import Path
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from app.core.parser import read_markdown, normalize_frontmatter
|
||||
from app.core.edges import build_edges_for_note
|
||||
from app.core.derive_edges import build_edges_for_note
|
||||
|
||||
def _iter_markdown(vault: str):
|
||||
for p in Path(vault).rglob("*.md"):
|
||||
@@ -83,8 +131,8 @@ def main():
|
||||
|
||||
edges = build_edges_for_note(
|
||||
note_id=note_id,
|
||||
chunk_payloads=chunks,
|
||||
note_level_refs=note_refs,
|
||||
chunks=chunks,
|
||||
note_level_references=note_refs,
|
||||
include_note_scope_refs=include_note_scope,
|
||||
)
|
||||
kinds = {}
|
||||
|
||||
Reference in new issue
Block a user