| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
|
|
| |
| $InstallPath = (Split-Path -Path $PSScriptRoot -Parent) |
|
|
| $comfyPath = Join-Path $InstallPath "ComfyUI" |
| $customNodesPath = Join-Path $InstallPath "custom_nodes" |
| $workflowPath = Join-Path $InstallPath "user\default\workflows\UmeAiRT-Workflow" |
| $venvPython = Join-Path $comfyPath "venv\Scripts\python.exe" |
| $logPath = Join-Path $InstallPath "logs" |
| $logFile = Join-Path $logPath "update_log.txt" |
|
|
| if (-not (Test-Path $logPath)) { New-Item -ItemType Directory -Force -Path $logPath | Out-Null } |
|
|
| function Write-Log { |
| param([string]$Message, [string]$Color = "White") |
| $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" |
| $formattedMessage = "[$timestamp] $Message" |
| Write-Host $Message -ForegroundColor $Color |
| Add-Content -Path $logFile -Value $formattedMessage |
| } |
|
|
| function Invoke-Git-Pull { |
| param([string]$DirectoryPath) |
| if (Test-Path (Join-Path $DirectoryPath ".git")) { |
| |
| $commandToRun = "git -C `"$DirectoryPath`" pull" |
| $cmdArguments = "/C `"$commandToRun >> `"`"$logFile`"`" 2>&1`"" |
| try { |
| Start-Process -FilePath "cmd.exe" -ArgumentList $cmdArguments -Wait -WindowStyle Hidden |
| } catch { |
| Write-Log " - FAILED to run git pull in '$DirectoryPath'" -Color Red |
| } |
| } else { |
| Write-Log " - Skipping: Not a git repository." -Color Gray |
| } |
| } |
|
|
| function Invoke-Pip-Install { |
| param([string]$RequirementsPath) |
| if (Test-Path $RequirementsPath) { |
| Write-Log " - Found requirements: $RequirementsPath. Updating..." -Color Cyan |
| $tempLogFile = Join-Path $env:TEMP ([System.Guid]::NewGuid().ToString() + ".tmp") |
| try { |
| $commandToRun = "`"$venvPython`" -m pip install -r `"$RequirementsPath`"" |
| $cmdArguments = "/C `"$commandToRun > `"`"$tempLogFile`"`" 2>&1`"" |
| Start-Process -FilePath "cmd.exe" -ArgumentList $cmdArguments -Wait -WindowStyle Hidden |
| if (Test-Path $tempLogFile) { $output = Get-Content $tempLogFile; if($output){ Add-Content -Path $logFile -Value $output } } |
| } finally { |
| if (Test-Path $tempLogFile) { Remove-Item $tempLogFile } |
| } |
| } |
| } |
| function Invoke-AndLog { |
| param( |
| [string]$File, |
| [string]$Arguments |
| ) |
| |
| |
| $tempLogFile = Join-Path $env:TEMP ([System.Guid]::NewGuid().ToString() + ".tmp") |
|
|
| try { |
| |
| $commandToRun = "`"$File`" $Arguments" |
| $cmdArguments = "/C `"$commandToRun > `"`"$tempLogFile`"`" 2>&1`"" |
| Start-Process -FilePath "cmd.exe" -ArgumentList $cmdArguments -Wait -WindowStyle Hidden |
| |
| |
| if (Test-Path $tempLogFile) { |
| $output = Get-Content $tempLogFile |
| |
| Add-Content -Path $logFile -Value $output |
| } |
| } catch { |
| Write-Log "FATAL ERROR trying to execute command: $commandToRun" -Color Red |
| } finally { |
| |
| if (Test-Path $tempLogFile) { |
| Remove-Item $tempLogFile |
| } |
| } |
| } |
| |
| |
| |
| Clear-Host |
| Write-Log "===============================================================================" |
| Write-Log " Starting UmeAiRT ComfyUI Update Process" -Color Yellow |
| Write-Log "===============================================================================" |
|
|
| |
| Write-Log "`n[1/4] Updating ComfyUI Core..." -Color Green |
| Invoke-Git-Pull -DirectoryPath $comfyPath |
|
|
| |
| Write-Log "`n[2/4] Updating and Installing Custom Nodes..." -Color Green |
|
|
| $csvUrl = "https://github.com/UmeAiRT/ComfyUI-Auto_installer/raw/refs/heads/main/csv/custom_nodes.csv" |
| $scriptsFolder = Join-Path $InstallPath "scripts" |
| $csvPath = Join-Path $scriptsFolder "custom_nodes.csv" |
|
|
| |
| try { |
| Invoke-WebRequest -Uri $csvUrl -OutFile $csvPath |
| } catch { |
| Write-Log " - ERREUR: Impossible de télécharger la liste des custom nodes. Mise à jour des nodes ignorée." -Color Red |
| return |
| } |
|
|
| $customNodesList = Import-Csv -Path $csvPath |
| $existingNodeDirs = Get-ChildItem -Path $customNodesPath -Directory |
|
|
| |
| Write-Log " - Updating existing nodes..." |
| foreach ($dir in $existingNodeDirs) { |
| Write-Log " - Checking node: $($dir.Name)" |
| Invoke-Git-Pull -DirectoryPath $dir.FullName |
| } |
|
|
| |
| Write-Log " - Checking for new nodes to install..." |
| foreach ($node in $customNodesList) { |
| $nodeName = $node.Name |
| $nodePath = if ($node.Subfolder) { Join-Path $customNodesPath $node.Subfolder } else { Join-Path $customNodesPath $nodeName } |
|
|
| if (-not (Test-Path $nodePath)) { |
| Write-Log " - New node found: $nodeName. Installing..." -Color Yellow |
| |
| $repoUrl = $node.RepoUrl |
| $cloneTargetPath = if ($node.Subfolder) { (Split-Path $nodePath -Parent) } else { $nodePath } |
| if ($nodeName -eq 'ComfyUI-Impact-Subpack') { $clonePath = Join-Path $cloneTargetPath "impact_subpack" } else { $clonePath = $cloneTargetPath } |
| |
| $tempLogFile = Join-Path $env:TEMP ([System.Guid]::NewGuid().ToString() + ".tmp") |
| try { |
| $commandToRun = "git clone $repoUrl `"$clonePath`"" |
| $cmdArguments = "/C `"$commandToRun > `"`"$tempLogFile`"`" 2>&1`"" |
| Start-Process -FilePath "cmd.exe" -ArgumentList $cmdArguments -Wait -WindowStyle Hidden |
| if (Test-Path $tempLogFile) { Add-Content -Path $logFile -Value (Get-Content $tempLogFile) } |
| } finally { |
| if (Test-Path $tempLogFile) { Remove-Item $tempLogFile } |
| } |
| } |
| } |
|
|
|
|
| |
| Write-Log "`n[3/4] Updating UmeAiRT Workflows..." -Color Green |
| if (Test-Path $workflowPath) { |
| Invoke-Git-Pull -DirectoryPath $workflowPath |
| } else { |
| Write-Log " - Workflow directory not found, skipping." -Color Gray |
| } |
|
|
| |
| Write-Log "`n[4/4] Updating all Python dependencies..." -Color Green |
| Write-Log " - Checking main ComfyUI requirements..." |
| Invoke-Pip-Install -RequirementsPath (Join-Path $comfyPath "requirements.txt") |
|
|
| Write-Log " - Checking custom node requirements..." |
| if (Test-Path $customNodesPath) { |
| foreach ($dir in (Get-ChildItem -Path $customNodesPath -Directory)) { |
| Invoke-Pip-Install -RequirementsPath (Join-Path $dir.FullName "requirements.txt") |
| } |
| } |
| Write-Log " - Fixing Numpy..." |
| Invoke-AndLog "$venvPython" @('-m', 'pip', 'uninstall', 'numpy', 'pandas', '--yes') |
| Invoke-AndLog "$venvPython" "-m pip install numpy==1.26.4 pandas" |
|
|
| Write-Log " - Fixing transformers..." |
| Invoke-AndLog "$venvPython" "-m pip install --upgrade transformers==4.49.0" |
|
|
| Write-Log "===============================================================================" |
| Write-Log "Update process complete!" -Color Yellow |
| Write-Log "===============================================================================" |
| Read-Host "Press Enter to exit." |
|
|