from pathlib import Path
from moorcheh import MoorchehClient
from moorcheh.docker_runtime import ensure_upload_dir, host_path_to_container_upload_path
with MoorchehClient("http://localhost:8080") as client:
upload_root = ensure_upload_dir()
host_file = (upload_root / "document.pdf").resolve()
container_path = host_path_to_container_upload_path(host_file, upload_root)
resp = client.files.upload(
"my-documents",
files=[
{"path": container_path, "department": "engineering", "force_reindex": False}
],
)
job_id = resp["job_id"]
while True:
job = client.files.job_status("my-documents", job_id)
if job["status"] in ("completed", "failed"):
break