Update rule + flow hdfs new

This commit is contained in:
2026-09-23 11:36:34 +07:00
parent c79ea9f05f
commit 0e15bc89a8
10 changed files with 159 additions and 35 deletions

View File

@@ -10,9 +10,12 @@ class StorageError(Exception):
pass
def _hdfs(*args: str) -> None:
def _hdfs(settings: Settings, *args: str) -> None:
command = ["hdfs", "dfs"]
if settings.hdfs_native_uri:
command.extend(["-fs", settings.hdfs_native_uri])
try:
subprocess.run(["hdfs", "dfs", *args], check=True, capture_output=True, text=True, timeout=600)
subprocess.run([*command, *args], check=True, capture_output=True, text=True, timeout=600)
except (OSError, subprocess.CalledProcessError, subprocess.TimeoutExpired) as exc:
detail = getattr(exc, "stderr", None) or str(exc)
raise StorageError(f"HDFS operation failed: {detail[:500]}") from exc
@@ -26,7 +29,7 @@ def fetch_pdf(settings: Settings, source: str, destination: Path) -> None:
from .webhdfs import download_pdf
download_pdf(settings.hdfs_url, source, temporary, settings.max_pdf_bytes)
elif settings.storage == "hdfs_cli":
_hdfs("-get", source, str(temporary))
_hdfs(settings, "-get", source, str(temporary))
elif settings.storage == "local":
source_path = Path(source).resolve()
if not source_path.is_file():