Overview

When tractor-blade launches a new command, such as a render, it sets up a unique set of environment variables for that subprocess. There are several mechanisms for defining these environment variables and their values.

The default approach is to simply allow each command to clone the incoming environment inherited by tractor-blade when it was started. However, this is often a specialized "daemon" environment and thus not very useful.

The simplest approach to custom environment configuration is to add name-value pairs to an environment dictionary in the blade.config file (see below). This is often completely sufficient, and is very straightforward. There is a "default" dictionary, and there can be separate ones corresponding to incoming EnvKey values from commands in the job. Environment variables specified in this manner are additions and overrides to the incoming inherited environment.

Tractor envhandlers are Python objects that can apply dynamic, site-specific settings to each command launched by a tractor-blade. They are most often used to configure a specific set of environment variables based on the inbound EnvKey or the job's owner. These handlers can also rewrite the actual command that is being invoked as well, which can help to deal with particular machines that have a non-standard application installation location, or other quirks.


Environment Variable Dictionaries

Additions and overrides to the inherited external environment can be added to one or more Python dictionaries that will be loaded by the blade. They can be added to the "default" EnvKey definition to affect all commands, or added to the settings for a particular EnvKeyvalue. Similarly, definitions can be added to ProfileDefaults or specifically to a single profile.

{
    "ProfileDefaults":
    {   "ProfileName": "default",
        ...
        "EnvKeys": [
            {
                "keys": ["default"],
                "environment": {
                    "SOME_VAR": "xyzzy",
                    "CURRENT_SHOW": "(not_set)"
                },
                "envhandler": "default"
            },
        ]
    },

    "BladeProfiles":
    [...]
}

These environment dictionaries are either defined in the blade.config file, or can be contained in an external file that is referenced with the @merge directive in the blade.config file. The default installation includes three external files which contain the default environment dictionary setup. These files are shared.linux.envkeys, shared.macosx.envkeys and shared.windows.envkeys.


Environment Handlers

Default Environment Handlers

Tractor comes with a default set of environment handlers. The handlers are invoked when there is a match between the incoming envkey and the keys definition in the environment key dictionary. The envkey parameter in a tractor script can actually be a list of several envkey entries. In that case each handler will be called in sequence to modify the launch environment.

Each of the default handlers has a specific purpose.

The default handler source code is available and is located in the TrEnvHandlers.py file located in the blade-modules directory of the blade installation.


Adding A Custom Environment Handler