59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
"""Run the approved arXiv component over the five local ClinDB paper copies."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
|
|
from mdpolish.components import ArxivSubmissionStampComponent
|
|
from mdpolish.experiment import InputDocument, collect_tool_metadata, run_experiment
|
|
from mdpolish.models import RunStatus
|
|
from mdpolish.pipeline import Pipeline
|
|
|
|
_DOCUMENT_IDS = ("dmp", "ejhf", "jama", "sim", "springer")
|
|
|
|
|
|
def _parse_args() -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--run-id", required=True, help="safe identifier within today's artifact directory")
|
|
return parser.parse_args()
|
|
|
|
|
|
def main() -> int:
|
|
args = _parse_args()
|
|
repository_root = Path(__file__).resolve().parents[1]
|
|
documents = tuple(
|
|
InputDocument(
|
|
document_id=document_id,
|
|
source_path=repository_root / "data" / "md" / f"{document_id}.md",
|
|
source_label=f"data/md/{document_id}.md",
|
|
)
|
|
for document_id in _DOCUMENT_IDS
|
|
)
|
|
started_at = datetime.now().astimezone()
|
|
try:
|
|
result = run_experiment(
|
|
pipeline=Pipeline([ArxivSubmissionStampComponent()]),
|
|
documents=documents,
|
|
run_id=args.run_id,
|
|
artifacts_root=repository_root / "artifacts",
|
|
started_at=started_at,
|
|
tool=collect_tool_metadata(repository_root),
|
|
)
|
|
except Exception as error:
|
|
print(f"experiment failed: {type(error).__name__}: {error}", file=sys.stderr)
|
|
return 1
|
|
|
|
print(f"run_id={args.run_id}")
|
|
print(f"status={result.status.value}")
|
|
print(f"documents={result.document_count}")
|
|
print(f"changes={result.change_count}")
|
|
print(f"artifacts={result.run_directory}")
|
|
return 0 if result.status is RunStatus.SUCCESS else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|