Worker: check BLENDER_CMD environment variable (for multi-GPU Eevee rendering) #104193

Open
MKRelax wants to merge 9 commits from MKRelax/flamenco:worker-use-blender-from-env into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
4 changed files with 12 additions and 10 deletions
Showing only changes of commit 4dd489ac01 - Show all commits

View File

@ -24,6 +24,8 @@ var (
ErrTimedOut = errors.New("version check took too long")
)
const BlenderPathEnvVariable = "FLAMENCO_BLENDER_PATH"
// blenderVersionTimeout is how long `blender --version` is allowed to take,
// before timing out. This can be much slower than expected, when loading
// Blender from shared storage on a not-so-fast NAS.
@ -50,9 +52,9 @@ func FileAssociation() (string, error) {
return fileAssociation()
}
// EnvironmentVariable returns the content of the BLENDER_CMD environment variable.
// EnvironmentVariable returns the full path of a Blender executable, if given as environment variable
MKRelax marked this conversation as resolved Outdated

I think the name of this variable should be in a constant. Can be in the same file. That way the string literal doesn't get repeated everywhere.

I think the name of this variable should be in a constant. Can be in the same file. That way the string literal doesn't get repeated everywhere.
func EnvironmentVariable() string {
return os.Getenv("BLENDER_CMD")
return os.Getenv(BlenderPathEnvVariable)
}
func CheckBlender(ctx context.Context, exename string) (CheckBlenderResult, error) {

View File

@ -49,10 +49,10 @@ func TestGetBlenderCommandFromEnvironment(t *testing.T) {
path := EnvironmentVariable()
MKRelax marked this conversation as resolved Outdated

This should check that the environment variable isn't already set while running the test ;-)

This should check that the environment variable isn't already set while running the test ;-)
assert.Equal(t, "", path)
// Try finding the blender path in the BLENDER_CMD environment variable
err := os.Setenv("BLENDER_CMD", "/path/specified/in/env/to/blender")
// Try finding the blender path in the environment variable
err := os.Setenv(BlenderPathEnvVariable, "/path/specified/in/env/to/blender")
if err != nil {
t.Fatal("Could not set BLENDER_CMD environment variable")
t.Fatal("Could not set blender executable in environment variable")
MKRelax marked this conversation as resolved Outdated

The if and t.Fatal() can be replaced with require.NoError(t, err, "Could not set BLENDER_CMD environment variable").

The `if` and `t.Fatal()` can be replaced with `require.NoError(t, err, "Could not set BLENDER_CMD environment variable")`.
}
path = EnvironmentVariable()

View File

@ -85,8 +85,8 @@ func (ce *CommandExecutor) cmdBlenderRenderCommand(
}
if crosspath.Dir(parameters.exe) == "." {
// No directory path given. Check that the executable can be found in the
// environment variable BLENDER_CMD or on the path.
// No directory path given. Check that the executable is set in an
// environment variable or can be found on the path.
if path := find_blender.EnvironmentVariable(); path != "" {
logger.Info().Str("path", path).Msg("found Blender in environment")
parameters.exe = path

View File

@ -10,6 +10,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/assert"
"projects.blender.org/studio/flamenco/internal/find_blender"
"projects.blender.org/studio/flamenco/pkg/api"
)
@ -88,10 +89,9 @@ func TestCmdBlenderFromEnvironment(t *testing.T) {
envExe := `D:\Blender_3.2_stable\blender.exe`
// This should use blender.exe from the BLENDER_CMD environment variable
err := os.Setenv("BLENDER_CMD", envExe)
err := os.Setenv(find_blender.BlenderPathEnvVariable, envExe)
if err != nil {
t.Fatal("Could not set BLENDER_CMD environment variable")
t.Fatal("Could not set blender executable in environment variable")
}
taskID := "c5dfdfab-4492-4ab1-9b38-8ca4cbd84a17"