Skip to content

Commit 0445fba

Browse files
authored
Merge pull request #305 from open-edge-platform/update-branch
fix: fix setup scripts (#820)
2 parents 43bbad4 + 3fd7493 commit 0445fba

File tree

21 files changed

+522
-149
lines changed

21 files changed

+522
-149
lines changed

usecases/ai/edge-ai-studio/docs/DEVELOPMENT.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

usecases/ai/edge-ai-studio/electron/setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ main() {
6161
# Trap to ensure environment is reset on exit
6262
trap reset_env EXIT
6363

64-
main
64+
main

usecases/ai/edge-ai-studio/frontend/setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ main() {
8787
exit 0
8888
fi
8989
echo "Starting frontend setup..."
90+
cd "$SCRIPT_DIR"
9091
ensure_env_file
9192
setup_frontend_dependencies
9293
echo "Frontend setup completed successfully."

usecases/ai/edge-ai-studio/frontend/src/app/(frontend)/(services)/lipsync/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export default function LipsyncPage() {
3838
const [resetIndex, setResetIndex] = useState(0)
3939

4040
const { data: workload, isLoading } = useGetWorkloadByType(TYPE)
41-
const { data: ttsWorkload } = useGetWorkloadByType('text-to-speech')
4241
const { isOpen, onClose, onOpen } = useDisclosure()
4342
const updateWorkload = useUpdateWorkload()
4443
const createWorkload = useCreateWorkload()

usecases/ai/edge-ai-studio/out/run_web.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path
1111
$env:PORT = "8080"
1212

1313
# Define paths relative to the script directory
14-
$RESOURCES_DIR = Join-Path $SCRIPT_DIR "edge-ai-studio-win32-x64\resources"
14+
$RESOURCES_DIR = Join-Path $SCRIPT_DIR "win-unpacked\resources"
1515
$FRONTEND_DIR = Join-Path $RESOURCES_DIR "frontend"
1616
$NODE_EXECUTABLE = Join-Path $RESOURCES_DIR "thirdparty\node\node.exe"
1717
$SERVER_JS = Join-Path $FRONTEND_DIR "server.js"

usecases/ai/edge-ai-studio/out/setup.ps1

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,24 @@
44
# Exit immediately if a command fails
55
$ErrorActionPreference = "Stop"
66

7-
# Set default skip variables if not already set
8-
param(
9-
[switch]$SkipFrontend = $false,
10-
[switch]$SkipElectron = $false,
11-
[switch]$SkipWorkers = $false
12-
)
13-
147
# Get the directory of this script
158
$SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path
169

1710
# Resources directory in the packaged application
18-
$RESOURCES_DIR = Join-Path $SCRIPT_DIR "edge-ai-studio-win32-x64\resources"
11+
$RESOURCES_DIR = Join-Path $SCRIPT_DIR "win-unpacked\resources"
1912
$THIRDPARTY_DIR = Join-Path $RESOURCES_DIR "thirdparty"
2013

2114
# Service configurations (Name -> Path:SkipFlag)
2215
$serviceConfigs = @{
2316
"Workers" = @{
2417
Path = "workers"
25-
Skip = $SkipWorkers
2618
}
2719
}
28-
# Frontend setup is skipped - only setting up workers
2920

3021
function Setup-Services {
3122
foreach ($serviceName in $serviceConfigs.Keys) {
3223
$config = $serviceConfigs[$serviceName]
3324
$servicePath = $config.Path
34-
$skipService = $config.Skip
35-
36-
if ($skipService) {
37-
Write-Host "Skipping setup for $serviceName" -ForegroundColor Yellow
38-
continue
39-
}
4025

4126
Set-Location $RESOURCES_DIR
4227
$serviceSetupFile = "setup.ps1"
@@ -99,21 +84,4 @@ function Main {
9984
Write-Host "Setup completed successfully!" -ForegroundColor Green
10085
}
10186

102-
# Parse additional arguments for compatibility
103-
$remainingArgs = $args
104-
for ($i = 0; $i -lt $remainingArgs.Length; $i++) {
105-
switch ($remainingArgs[$i]) {
106-
"--skip-workers" { $SkipWorkers = $true }
107-
"--skip-frontend" { $SkipFrontend = $true }
108-
"--skip-electron" { $SkipElectron = $true }
109-
default {
110-
Write-Host "Unknown option: $($remainingArgs[$i])" -ForegroundColor Red
111-
exit 1
112-
}
113-
}
114-
}
115-
116-
# Update service configs with parsed flags
117-
$serviceConfigs["Workers"].Skip = $SkipWorkers
118-
11987
Main

usecases/ai/edge-ai-studio/scripts/package.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ finalize_package() {
103103
echo "run_web.sh copied to EdgeAIStudio root successfully."
104104
fi
105105

106-
# Copy setup.sh to the root of EdgeAIStudio
106+
# Copy run_web.sh to the root of EdgeAIStudio
107107
if [ -f "$SCRIPT_DIR/../out/setup.sh" ]; then
108108
cp "$SCRIPT_DIR/../out/setup.sh" EdgeAIStudio/ || { echo "Failed to copy setup.sh to EdgeAIStudio folder."; exit 1; }
109109
echo "setup.sh copied to EdgeAIStudio root successfully."
@@ -191,7 +191,7 @@ run_electron_package() {
191191
}
192192

193193
main() {
194-
cd "$SCRIPT_DIR"
194+
cd "$SCRIPT_DIR"
195195
create_temp_dir
196196
setup_node_env
197197
copy_workers

usecases/ai/edge-ai-studio/scripts/setup_thirdparty.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Exit on error, unset variable, or failed pipe
55
set -euo pipefail
66

7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
78
THIRDPARTY_DIR="${1:-$SCRIPT_DIR/../thirdparty}"
89
NODE_ZIP_PATH="$THIRDPARTY_DIR/node.tar.xz"
910
NODE_URL="https://nodejs.org/dist/v22.18.0/node-v22.18.0-linux-x64.tar.xz"

usecases/ai/edge-ai-studio/setup.ps1

Lines changed: 119 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
# Parameters for switches and options
55
param(
6-
[switch]$SkipLLM,
7-
[switch]$SkipTTS,
6+
[switch]$SkipWorkers,
87
[switch]$SkipFrontend,
98
[switch]$SkipElectron,
10-
[switch]$Verbose
9+
[switch]$Verbose,
10+
[switch]$ContinueOnError # Continue setup for remaining services even if one fails
1111
)
1212

1313
# Helper: Cleanup processes
@@ -38,7 +38,8 @@ function Invoke-ServiceSetup {
3838
# Check if setup.ps1 exists
3939
$setupScript = Join-Path $ServicePath "setup.ps1"
4040
if (-not (Test-Path $setupScript)) {
41-
throw "setup.ps1 not found in $ServicePath"
41+
Write-ColorOutput "Warning: setup.ps1 not found in $ServicePath" "Yellow"
42+
return @{ Success = $false; ErrorMessage = "setup.ps1 not found"; ExitCode = -1 }
4243
}
4344

4445
try {
@@ -49,9 +50,8 @@ function Invoke-ServiceSetup {
4950

5051
# Add skip parameters for workers setup
5152
if ($ServiceName -eq "Workers") {
52-
if ($SkipLLM) { $scriptArgs += "-SkipLLM" }
53-
if ($SkipTTS) { $scriptArgs += "-SkipTTS" }
5453
if ($Verbose) { $scriptArgs += "-Verbose" }
54+
if ($ContinueOnError) { $scriptArgs += "-ContinueOnError" }
5555
}
5656

5757
if ($Verbose) {
@@ -95,21 +95,23 @@ function Invoke-ServiceSetup {
9595
# Check the exit code
9696
if ($setupProcess.ExitCode -eq 0) {
9797
Write-ColorOutput "$ServiceName setup completed successfully!" "Green"
98+
return @{ Success = $true; ErrorMessage = $null; ExitCode = $setupProcess.ExitCode }
9899
} else {
100+
$errorMsg = "Setup failed with exit code $($setupProcess.ExitCode)"
99101
Write-ColorOutput "$ServiceName setup failed with exit code $($setupProcess.ExitCode)!" "Red"
100-
throw "Setup failed for $ServiceName with exit code $($setupProcess.ExitCode)"
102+
return @{ Success = $false; ErrorMessage = $errorMsg; ExitCode = $setupProcess.ExitCode }
101103
}
102104

103-
return $setupProcess
104105
} catch {
105-
Write-ColorOutput "Setup failed for $ServiceName`: $($_.Exception.Message)" "Red"
106-
throw
106+
$errorMsg = $_.Exception.Message
107+
Write-ColorOutput "Setup failed for $ServiceName`: $errorMsg" "Red"
108+
return @{ Success = $false; ErrorMessage = $errorMsg; ExitCode = -1 }
107109
}
108110
}
109111

110112
# Define service configuration
111113
$services = @(
112-
@{Name = "Workers"; Path = "workers"; Skip = $false},
114+
@{Name = "Workers"; Path = "workers"; Skip = $SkipWorkers},
113115
@{Name = "Frontend"; Path = "frontend"; Skip = $SkipFrontend},
114116
@{Name = "Electron"; Path = "electron"; Skip = $SkipElectron}
115117
)
@@ -121,6 +123,11 @@ foreach ($service in $services) {
121123
}
122124
Write-ColorOutput "==========================================" "Cyan"
123125

126+
# Track setup results
127+
$setupResults = @()
128+
$successfulSetups = @()
129+
$failedSetups = @()
130+
124131
try {
125132
# Install Node.js first using shared setup_thirdparty.ps1 function
126133
$thirdPartyScript = Join-Path $PSScriptRoot 'scripts\setup_thirdparty.ps1'
@@ -132,24 +139,119 @@ try {
132139
$setupPath = Join-Path $PWD "$($service.Path)\setup.ps1"
133140
if (Test-Path $setupPath) {
134141
Write-ColorOutput "Starting $($service.Name) setup..." "Yellow"
135-
try {
136-
$setupProcess = Invoke-ServiceSetup -ServicePath (Join-Path $PWD $service.Path) -ServiceName $service.Name
137-
} catch {
138-
Write-ColorOutput "$($service.Name) setup failed: $($_.Exception.Message)" "Red"
139-
throw
142+
143+
$result = Invoke-ServiceSetup -ServicePath (Join-Path $PWD $service.Path) -ServiceName $service.Name
144+
$setupResults += @{
145+
ServiceName = $service.Name
146+
Success = $result.Success
147+
ErrorMessage = $result.ErrorMessage
148+
ExitCode = $result.ExitCode
149+
}
150+
151+
if ($result.Success) {
152+
$successfulSetups += $service.Name
153+
} else {
154+
$failedSetups += @{
155+
Name = $service.Name
156+
Error = $result.ErrorMessage
157+
ExitCode = $result.ExitCode
158+
}
159+
160+
if (-not $ContinueOnError) {
161+
Write-ColorOutput "Setup failed for $($service.Name). Use -ContinueOnError to continue with remaining services." "Red"
162+
throw "Setup failed for $($service.Name): $($result.ErrorMessage)"
163+
} else {
164+
Write-ColorOutput "Setup failed for $($service.Name), but continuing with remaining services..." "Yellow"
165+
}
140166
}
141167
} else {
142168
Write-ColorOutput "Warning: $($service.Name) setup.ps1 not found!" "Yellow"
169+
$setupResults += @{
170+
ServiceName = $service.Name
171+
Success = $false
172+
ErrorMessage = "setup.ps1 not found"
173+
ExitCode = -1
174+
}
175+
$failedSetups += @{
176+
Name = $service.Name
177+
Error = "setup.ps1 not found"
178+
ExitCode = -1
179+
}
180+
181+
if (-not $ContinueOnError) {
182+
throw "Setup script not found for $($service.Name)"
183+
} else {
184+
Write-ColorOutput "Setup script not found for $($service.Name), but continuing with remaining services..." "Yellow"
185+
}
186+
}
187+
} else {
188+
Write-ColorOutput "Skipping $($service.Name) setup..." "Yellow"
189+
$setupResults += @{
190+
ServiceName = $service.Name
191+
Success = $null # Indicates skipped
192+
ErrorMessage = "Skipped by user"
193+
ExitCode = 0
143194
}
144195
}
145196
}
146197

147-
Write-ColorOutput "All setup processes completed successfully!" "Green"
198+
# Display summary
199+
Write-ColorOutput "`n=== Setup Summary ===" "Cyan"
200+
201+
if ($successfulSetups.Count -gt 0) {
202+
Write-ColorOutput "✅ Successful setups ($($successfulSetups.Count)):" "Green"
203+
foreach ($success in $successfulSetups) {
204+
Write-ColorOutput " - $success" "Green"
205+
}
206+
}
207+
208+
if ($failedSetups.Count -gt 0) {
209+
Write-ColorOutput "❌ Failed setups ($($failedSetups.Count)):" "Red"
210+
foreach ($failure in $failedSetups) {
211+
Write-ColorOutput " - $($failure.Name): $($failure.Error) (Exit Code: $($failure.ExitCode))" "Red"
212+
}
213+
}
214+
215+
$skippedCount = ($setupResults | Where-Object { $_.Success -eq $null }).Count
216+
if ($skippedCount -gt 0) {
217+
Write-ColorOutput "⏭️ Skipped setups ($skippedCount):" "Yellow"
218+
foreach ($result in ($setupResults | Where-Object { $_.Success -eq $null })) {
219+
Write-ColorOutput " - $($result.ServiceName)" "Yellow"
220+
}
221+
}
222+
223+
Write-ColorOutput "===================" "Cyan"
224+
225+
# Final status
226+
if ($failedSetups.Count -eq 0) {
227+
Write-ColorOutput "All setup processes completed successfully!" "Green"
228+
} else {
229+
Write-ColorOutput "Some setup processes failed. Check the summary above for details." "Red"
230+
exit 1
231+
}
232+
148233
} catch {
149234
Write-ColorOutput "Error occurred: $($_.Exception.Message)" "Red"
150235
if ($Verbose) {
151236
Write-ColorOutput "Stack trace: $($_.ScriptStackTrace)" "Red"
152237
}
238+
239+
# Display partial summary if any setups were completed
240+
if ($setupResults.Count -gt 0) {
241+
Write-ColorOutput "`n=== Partial Setup Summary ===" "Cyan"
242+
foreach ($result in $setupResults) {
243+
if ($result.Success -eq $true) {
244+
Write-ColorOutput "$($result.ServiceName): Success" "Green"
245+
} elseif ($result.Success -eq $false) {
246+
Write-ColorOutput "$($result.ServiceName): $($result.ErrorMessage)" "Red"
247+
} else {
248+
Write-ColorOutput "⏭️ $($result.ServiceName): Skipped" "Yellow"
249+
}
250+
}
251+
Write-ColorOutput "===================" "Cyan"
252+
}
253+
254+
exit 1
153255
} finally {
154256
Cleanup
155257
}

0 commit comments

Comments
 (0)