Refactor web build process and update documentation

- Removed Node.js build artifacts from .gitignore and adjusted Makefile to reflect changes in web UI build process, now using server-rendered Go templates instead of React.
- Updated README to clarify the new web UI architecture and output formats, emphasizing the removal of the Node.js build step.
- Added a command to set the number of frames per render task in manager configuration, enhancing user control over rendering settings.
- Improved Gitea workflow by removing unnecessary npm install step, streamlining the CI process.
This commit is contained in:
2026-03-12 19:44:40 -05:00
parent d3c5ee0dba
commit 2deb47e5ad
78 changed files with 3895 additions and 12499 deletions

View File

@@ -2,10 +2,13 @@ package executils
import (
"bufio"
"context"
"errors"
"fmt"
"io"
"os"
"os/exec"
"strings"
"sync"
"time"
@@ -107,6 +110,78 @@ type CommandResult struct {
ExitCode int
}
// RunCommandWithTimeout is like RunCommand but kills the process after timeout.
// A zero timeout means no timeout.
func RunCommandWithTimeout(
timeout time.Duration,
cmdPath string,
args []string,
dir string,
env []string,
taskID int64,
tracker *ProcessTracker,
) (*CommandResult, error) {
if timeout <= 0 {
return RunCommand(cmdPath, args, dir, env, taskID, tracker)
}
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
cmd := exec.CommandContext(ctx, cmdPath, args...)
cmd.Dir = dir
if env != nil {
cmd.Env = env
}
stdoutPipe, err := cmd.StdoutPipe()
if err != nil {
return nil, fmt.Errorf("failed to create stdout pipe: %w", err)
}
stderrPipe, err := cmd.StderrPipe()
if err != nil {
return nil, fmt.Errorf("failed to create stderr pipe: %w", err)
}
if err := cmd.Start(); err != nil {
return nil, fmt.Errorf("failed to start command: %w", err)
}
if tracker != nil {
tracker.Track(taskID, cmd)
defer tracker.Untrack(taskID)
}
var stdoutBuf, stderrBuf []byte
var stdoutErr, stderrErr error
var wg sync.WaitGroup
wg.Add(2)
go func() {
defer wg.Done()
stdoutBuf, stdoutErr = readAll(stdoutPipe)
}()
go func() {
defer wg.Done()
stderrBuf, stderrErr = readAll(stderrPipe)
}()
waitErr := cmd.Wait()
wg.Wait()
if stdoutErr != nil && !isBenignPipeReadError(stdoutErr) {
return nil, fmt.Errorf("failed to read stdout: %w", stdoutErr)
}
if stderrErr != nil && !isBenignPipeReadError(stderrErr) {
return nil, fmt.Errorf("failed to read stderr: %w", stderrErr)
}
result := &CommandResult{Stdout: string(stdoutBuf), Stderr: string(stderrBuf)}
if waitErr != nil {
if exitErr, ok := waitErr.(*exec.ExitError); ok {
result.ExitCode = exitErr.ExitCode()
} else {
result.ExitCode = -1
}
if ctx.Err() == context.DeadlineExceeded {
return result, fmt.Errorf("command timed out after %v: %w", timeout, waitErr)
}
return result, waitErr
}
result.ExitCode = 0
return result, nil
}
// RunCommand executes a command and returns the output
// If tracker is provided, the process will be registered for tracking
// This is useful for commands where you need to capture output (like metadata extraction)
@@ -164,10 +239,10 @@ func RunCommand(
wg.Wait()
// Check for read errors
if stdoutErr != nil {
if stdoutErr != nil && !isBenignPipeReadError(stdoutErr) {
return nil, fmt.Errorf("failed to read stdout: %w", stdoutErr)
}
if stderrErr != nil {
if stderrErr != nil && !isBenignPipeReadError(stderrErr) {
return nil, fmt.Errorf("failed to read stderr: %w", stderrErr)
}
@@ -208,6 +283,18 @@ func readAll(r interface{ Read([]byte) (int, error) }) ([]byte, error) {
return buf, nil
}
// isBenignPipeReadError treats EOF-like pipe close races as non-fatal.
func isBenignPipeReadError(err error) bool {
if err == nil {
return false
}
if errors.Is(err, io.EOF) || errors.Is(err, os.ErrClosed) || errors.Is(err, io.ErrClosedPipe) {
return true
}
// Some platforms return wrapped messages that don't map cleanly to sentinel errors.
return strings.Contains(strings.ToLower(err.Error()), "file already closed")
}
// LogSender is a function type for sending logs
type LogSender func(taskID int, level types.LogLevel, message string, stepName string)

View File

@@ -0,0 +1,32 @@
package executils
import (
"errors"
"io"
"os"
"testing"
)
func TestIsBenignPipeReadError(t *testing.T) {
tests := []struct {
name string
err error
want bool
}{
{name: "nil", err: nil, want: false},
{name: "eof", err: io.EOF, want: true},
{name: "closed", err: os.ErrClosed, want: true},
{name: "closed pipe", err: io.ErrClosedPipe, want: true},
{name: "wrapped closed", err: errors.New("read |0: file already closed"), want: true},
{name: "other", err: errors.New("permission denied"), want: false},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
got := isBenignPipeReadError(tc.err)
if got != tc.want {
t.Fatalf("got %v, want %v (err=%v)", got, tc.want, tc.err)
}
})
}
}

View File

@@ -95,31 +95,20 @@ if current_device:
print(f"Blend file output format: {current_output_format}")
# Override output format if specified
# The format file always takes precedence (it's written specifically for this job)
# Render output is EXR only and must remain linear for the encode pipeline (linear -> sRGB -> HLG).
if output_format_override:
print(f"Overriding output format from '{current_output_format}' to '{output_format_override}'")
# Map common format names to Blender's format constants
# For video formats, we render as appropriate frame format first
format_to_use = output_format_override.upper()
if format_to_use in ['EXR_264_MP4', 'EXR_AV1_MP4', 'EXR_VP9_WEBM']:
format_to_use = 'EXR' # Render as EXR for EXR video formats
format_map = {
'PNG': 'PNG',
'JPEG': 'JPEG',
'JPG': 'JPEG',
'EXR': 'OPEN_EXR',
'OPEN_EXR': 'OPEN_EXR',
'TARGA': 'TARGA',
'TIFF': 'TIFF',
'BMP': 'BMP',
}
blender_format = format_map.get(format_to_use, format_to_use)
print(f"Overriding output format from '{current_output_format}' to OPEN_EXR (always EXR for pipeline)")
try:
scene.render.image_settings.file_format = blender_format
print(f"Successfully set output format to: {blender_format}")
scene.render.image_settings.file_format = 'OPEN_EXR'
# Lock output color space to linear (defense in depth; EXR is linear for encode pipeline)
if getattr(scene.render.image_settings, 'has_linear_colorspace', False) and hasattr(scene.render.image_settings, 'linear_colorspace_settings'):
try:
scene.render.image_settings.linear_colorspace_settings.name = 'Linear'
except Exception as ex:
print(f"Note: Could not set linear output: {ex}")
print("Successfully set output format to: OPEN_EXR")
except Exception as e:
print(f"Warning: Could not set output format to {blender_format}: {e}")
print(f"Warning: Could not set output format to OPEN_EXR: {e}")
print(f"Using blend file's format: {current_output_format}")
else:
print(f"Using blend file's output format: {current_output_format}")

View File

@@ -93,7 +93,8 @@ type Task struct {
ID int64 `json:"id"`
JobID int64 `json:"job_id"`
RunnerID *int64 `json:"runner_id,omitempty"`
Frame int `json:"frame"`
Frame int `json:"frame"` // frame start (inclusive) for render tasks
FrameEnd *int `json:"frame_end,omitempty"` // frame end (inclusive); nil = single frame
TaskType TaskType `json:"task_type"`
Status TaskStatus `json:"status"`
CurrentStep string `json:"current_step,omitempty"`
@@ -138,8 +139,6 @@ type CreateJobRequest struct {
UnhideObjects *bool `json:"unhide_objects,omitempty"` // Optional: Enable unhide tweaks for objects/collections
EnableExecution *bool `json:"enable_execution,omitempty"` // Optional: Enable auto-execution in Blender (adds --enable-autoexec flag, defaults to false)
BlenderVersion *string `json:"blender_version,omitempty"` // Optional: Override Blender version (e.g., "4.2" or "4.2.3")
PreserveHDR *bool `json:"preserve_hdr,omitempty"` // Optional: Preserve HDR range for EXR encoding (uses HLG with bt709 primaries)
PreserveAlpha *bool `json:"preserve_alpha,omitempty"` // Optional: Preserve alpha channel for EXR encoding (requires AV1 or VP9 codec)
}
// UpdateJobProgressRequest represents a request to update job progress
@@ -234,8 +233,6 @@ type BlendMetadata struct {
UnhideObjects *bool `json:"unhide_objects,omitempty"` // Enable unhide tweaks for objects/collections
EnableExecution *bool `json:"enable_execution,omitempty"` // Enable auto-execution in Blender (adds --enable-autoexec flag, defaults to false)
BlenderVersion string `json:"blender_version,omitempty"` // Detected or overridden Blender version (e.g., "4.2" or "4.2.3")
PreserveHDR *bool `json:"preserve_hdr,omitempty"` // Preserve HDR range for EXR encoding (uses HLG with bt709 primaries)
PreserveAlpha *bool `json:"preserve_alpha,omitempty"` // Preserve alpha channel for EXR encoding (requires AV1 or VP9 codec)
}
// MissingFilesInfo represents information about missing files/addons