mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
fix: route OCR artifact paths through configured OCR root
This commit is contained in:
parent
cca983d517
commit
5bfed8d6f2
2 changed files with 52 additions and 2 deletions
|
|
@ -18,8 +18,8 @@ class OCRArtifactPaths:
|
|||
blocks_structured: Path
|
||||
|
||||
|
||||
def artifact_paths_for_key(vault: Path, zotero_key: str) -> OCRArtifactPaths:
|
||||
paper_root = vault / "System" / "PaperForge" / "ocr" / zotero_key
|
||||
def artifact_paths_for_root(ocr_root: Path, zotero_key: str) -> OCRArtifactPaths:
|
||||
paper_root = ocr_root / zotero_key
|
||||
return OCRArtifactPaths(
|
||||
paper_root=paper_root,
|
||||
meta_json=paper_root / "meta.json",
|
||||
|
|
@ -32,6 +32,12 @@ def artifact_paths_for_key(vault: Path, zotero_key: str) -> OCRArtifactPaths:
|
|||
)
|
||||
|
||||
|
||||
def artifact_paths_for_key(vault: Path, zotero_key: str) -> OCRArtifactPaths:
|
||||
from paperforge.worker._utils import pipeline_paths
|
||||
paths = pipeline_paths(vault)
|
||||
return artifact_paths_for_root(paths["ocr"], zotero_key)
|
||||
|
||||
|
||||
def build_version_payload(
|
||||
*,
|
||||
pdf_fingerprint: str,
|
||||
|
|
|
|||
44
tests/test_ocr_artifact_paths_config.py
Normal file
44
tests/test_ocr_artifact_paths_config.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_artifact_paths_follow_pipeline_ocr_root(tmp_path: Path) -> None:
|
||||
from paperforge.worker.ocr_artifacts import artifact_paths_for_root
|
||||
|
||||
ocr_root = tmp_path / "CustomSystem" / "PaperForge" / "ocr"
|
||||
paths = artifact_paths_for_root(ocr_root, "KEY001")
|
||||
|
||||
assert paths.paper_root == ocr_root / "KEY001"
|
||||
assert paths.meta_json == ocr_root / "KEY001" / "meta.json"
|
||||
|
||||
|
||||
def test_artifact_paths_for_key_still_works(tmp_path: Path) -> None:
|
||||
from paperforge.worker.ocr_artifacts import artifact_paths_for_key
|
||||
|
||||
vault = tmp_path / "vault"
|
||||
vault.mkdir()
|
||||
(vault / "paperforge.json").write_text(
|
||||
'{"vault_config":{"system_dir":"System","resources_dir":"Resources"}}',
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
paths = artifact_paths_for_key(vault, "KEY001")
|
||||
assert paths.paper_root.as_posix().endswith("/ocr/KEY001")
|
||||
assert paths.meta_json.as_posix().endswith("/ocr/KEY001/meta.json")
|
||||
|
||||
|
||||
def test_artifact_paths_for_root_has_all_fields(tmp_path: Path) -> None:
|
||||
from paperforge.worker.ocr_artifacts import artifact_paths_for_root
|
||||
|
||||
ocr_root = tmp_path / "ocr"
|
||||
paths = artifact_paths_for_root(ocr_root, "KEY001")
|
||||
|
||||
assert paths.paper_root == ocr_root / "KEY001"
|
||||
assert paths.meta_json == ocr_root / "KEY001" / "meta.json"
|
||||
assert paths.result_json == ocr_root / "KEY001" / "json" / "result.json"
|
||||
assert paths.compat_fulltext == ocr_root / "KEY001" / "fulltext.md"
|
||||
assert paths.raw_meta == ocr_root / "KEY001" / "raw" / "raw_meta.json"
|
||||
assert paths.source_metadata == ocr_root / "KEY001" / "raw" / "source_metadata.json"
|
||||
assert paths.blocks_raw == ocr_root / "KEY001" / "canonical" / "blocks.raw.jsonl"
|
||||
assert paths.blocks_structured == ocr_root / "KEY001" / "structure" / "blocks.structured.jsonl"
|
||||
Loading…
Reference in a new issue