-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_all.ps1
More file actions
69 lines (68 loc) · 3.2 KB
/
Copy pathrun_all.ps1
File metadata and controls
69 lines (68 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)][Alias('Input')][string]$InputFile,
[string]$DatasetConfig = '',
[string]$Output = 'results',
[string]$Languages = 'python,r,matlab,fortran',
[string]$PythonEnvironment = 'distribution-inference',
[string]$REnvironment = 'distribution-inference',
[int]$Bootstrap = 1000,
[int]$Seed = 12345,
[double]$KsAlpha = 0.05,
[string]$CiLevels = '0.90,0.95,0.99'
)
$ErrorActionPreference = 'Continue'
$root = $PSScriptRoot
Push-Location $root
$inputPath = $InputFile.Replace('\', '/')
$outputPath = $Output
$configPath = $DatasetConfig.Replace('\', '/')
New-Item -ItemType Directory -Force -Path $outputPath | Out-Null
$common = @('--input', $inputPath, '--output')
$tail = @('--bootstrap', "$Bootstrap", '--seed', "$Seed", '--ks-alpha', "$KsAlpha", '--ci-levels', $CiLevels)
if ($configPath) { $tail = @('--dataset-config', $configPath) + $tail }
$selected = $Languages.Split(',') | ForEach-Object { $_.Trim().ToLowerInvariant() }
$failures = @()
if ($selected -contains 'python') {
try {
$env:PYTHONPATH = 'src\python'
conda run --no-capture-output -n $PythonEnvironment python -m distribution_inference.cli @common (Join-Path $outputPath 'python') @tail
if ($LASTEXITCODE -ne 0) { throw "exit code $LASTEXITCODE" }
} catch { $failures += "python: $_"; Write-Warning $failures[-1] }
}
if ($selected -contains 'r') {
try {
conda run --no-capture-output -n $REnvironment Rscript 'src\r\distribution_inference.R' @common (Join-Path $outputPath 'r') @tail
if ($LASTEXITCODE -ne 0) { throw "exit code $LASTEXITCODE" }
} catch { $failures += "r: $_"; Write-Warning $failures[-1] }
}
if ($selected -contains 'matlab') {
try {
if (-not (Get-Command matlab -ErrorAction SilentlyContinue)) { throw 'matlab was not found on PATH' }
$matArgs = @('--input',$inputPath,'--output',(Join-Path $outputPath 'matlab')) + $tail
$quoted = ($matArgs | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ','
matlab -batch "addpath('src/matlab'); distribution_inference($quoted);"
if ($LASTEXITCODE -ne 0) { throw "exit code $LASTEXITCODE" }
} catch { $failures += "matlab: $_"; Write-Warning $failures[-1] }
}
if ($selected -contains 'fortran') {
try {
$binary = 'build\distribution_inference_fortran.exe'
if (-not (Test-Path $binary)) { & 'scripts\build_fortran.ps1' }
& $binary @common (Join-Path $outputPath 'fortran') @tail
if ($LASTEXITCODE -ne 0) { throw "exit code $LASTEXITCODE" }
} catch { $failures += "fortran: $_"; Write-Warning $failures[-1] }
}
try {
$env:PYTHONPATH = 'src\python'
$reportArgs = @('-m','distribution_inference.report','--input',$inputPath,'--results-root',$outputPath)
if ($configPath) { $reportArgs += @('--dataset-config',$configPath) }
conda run --no-capture-output -n $PythonEnvironment python @reportArgs
} catch { $failures += "report: $_"; Write-Warning $failures[-1] }
if ($failures.Count) {
Write-Warning ("Completed with unavailable/failed components:`n " + ($failures -join "`n "))
Pop-Location
exit 1
}
Write-Host "All selected implementations completed. Results: $outputPath"
Pop-Location