run-mineru-accurate-demo.ps1 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. param(
  2. [string]$SampleDir,
  3. [string]$OutDir,
  4. [int]$TimeoutSeconds = 900,
  5. [int]$IntervalSeconds = 5,
  6. [string]$ModelVersion = "vlm"
  7. )
  8. $ErrorActionPreference = "Stop"
  9. $OutputEncoding = [System.Text.Encoding]::UTF8
  10. [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
  11. [Console]::InputEncoding = [System.Text.Encoding]::UTF8
  12. $TestFilesName = "$([char]0x6D4B)$([char]0x8BD5)$([char]0x6587)$([char]0x4EF6)"
  13. $CompareName = "$([char]0x5BF9)$([char]0x6BD4)$([char]0x7ED3)$([char]0x679C)"
  14. if ([string]::IsNullOrWhiteSpace($SampleDir)) { $SampleDir = Join-Path $PSScriptRoot $TestFilesName }
  15. if ([string]::IsNullOrWhiteSpace($OutDir)) { $OutDir = Join-Path $PSScriptRoot (Join-Path $CompareName "mineru-accurate") }
  16. function Write-Log {
  17. param([string]$Message)
  18. Write-Host ("[{0:yyyy-MM-dd HH:mm:ss}] {1}" -f (Get-Date), $Message)
  19. }
  20. if (Test-Path $OutDir) { Remove-Item $OutDir -Recurse -Force }
  21. New-Item -ItemType Directory -Force $OutDir | Out-Null
  22. $LogFile = Join-Path $OutDir "run.log"
  23. Start-Transcript -Path $LogFile | Out-Null
  24. try {
  25. $ProjectDir = Join-Path $PSScriptRoot "mineru-accurate-demo"
  26. Write-Log "MinerU accurate demo started"
  27. Write-Log "SampleDir=$SampleDir"
  28. Write-Log "OutDir=$OutDir"
  29. Write-Log "ProjectDir=$ProjectDir"
  30. Write-Log "timeout=$TimeoutSeconds interval=$IntervalSeconds model=$ModelVersion"
  31. if (!(Test-Path $SampleDir)) { throw "SampleDir not found: $SampleDir" }
  32. if (!(Test-Path $ProjectDir)) { throw "ProjectDir not found: $ProjectDir" }
  33. if (!(Test-Path (Join-Path $ProjectDir ".env"))) { throw "Missing .env in mineru-accurate-demo" }
  34. Push-Location $ProjectDir
  35. try {
  36. if (!(Test-Path "node_modules")) {
  37. Write-Log "node_modules not found, running npm install"
  38. npm install
  39. }
  40. npm run smoke -- "$SampleDir" --out-dir "$OutDir" --timeout $TimeoutSeconds --interval $IntervalSeconds --model-version $ModelVersion
  41. Write-Log "npm exit code: $LASTEXITCODE"
  42. } finally {
  43. Pop-Location
  44. }
  45. Write-Log "MinerU accurate demo finished"
  46. } catch {
  47. Write-Log ("Failed: {0}" -f $_.Exception.Message)
  48. throw
  49. } finally {
  50. Stop-Transcript | Out-Null
  51. }