Skip to content

utils

should_open_workfiles_tool_on_launch(project_name, host_name, task_name, task_type, default_output=False, project_settings=None)

Define if host should start workfile tool at host launch.

Default output is False. Can be overridden with environment variable AYON_WORKFILE_TOOL_ON_START, valid values without case sensitivity are "0", "1", "true", "false", "yes", "no".

Parameters:

Name Type Description Default
project_name str

Name of project.

required
host_name str

Name of host which is launched. In avalon's application context it's value stored in app definition under key "application_dir". Is not case sensitive.

required
task_name str

Name of task which is used for launching the host. Task name is not case sensitive.

required
task_type str

Task type.

required
default_output Optional[bool]

Default output value if no profile is found.

False
project_settings Optional[dict[str, Any]]

Project settings.

None

Returns:

Name Type Description
bool

True if host should start workfile.

Source code in client/ayon_core/pipeline/workfile/utils.py
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
def should_open_workfiles_tool_on_launch(
    project_name,
    host_name,
    task_name,
    task_type,
    default_output=False,
    project_settings=None,
):
    """Define if host should start workfile tool at host launch.

    Default output is `False`. Can be overridden with environment variable
    `AYON_WORKFILE_TOOL_ON_START`, valid values without case sensitivity are
    `"0", "1", "true", "false", "yes", "no"`.

    Args:
        project_name (str): Name of project.
        host_name (str): Name of host which is launched. In avalon's
            application context it's value stored in app definition under
            key `"application_dir"`. Is not case sensitive.
        task_name (str): Name of task which is used for launching the host.
            Task name is not case sensitive.
        task_type (str): Task type.
        default_output (Optional[bool]): Default output value if no profile
            is found.
        project_settings (Optional[dict[str, Any]]): Project settings.

    Returns:
        bool: True if host should start workfile.

    """

    if project_settings is None:
        project_settings = get_project_settings(project_name)
    profiles = (
        project_settings
        ["core"]
        ["tools"]
        ["Workfiles"]
        ["open_workfile_tool_on_startup"]
    )

    if not profiles:
        return default_output

    filter_data = {
        "tasks": task_name,
        "task_types": task_type,
        "hosts": host_name
    }
    matching_item = filter_profiles(profiles, filter_data)

    output = None
    if matching_item:
        output = matching_item.get("enabled")

    if output is None:
        return default_output
    return output

should_use_last_workfile_on_launch(project_name, host_name, task_name, task_type, default_output=False, project_settings=None)

Define if host should start last version workfile if possible.

Default output is False. Can be overridden with environment variable AYON_OPEN_LAST_WORKFILE, valid values without case sensitivity are "0", "1", "true", "false", "yes", "no".

Parameters:

Name Type Description Default
project_name str

Name of project.

required
host_name str

Name of host which is launched. In avalon's application context it's value stored in app definition under key "application_dir". Is not case sensitive.

required
task_name str

Name of task which is used for launching the host. Task name is not case sensitive.

required
task_type str

Task type.

required
default_output Optional[bool]

Default output value if no profile is found.

False
project_settings Optional[dict[str, Any]]

Project settings.

None

Returns:

Name Type Description
bool

True if host should start workfile.

Source code in client/ayon_core/pipeline/workfile/utils.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def should_use_last_workfile_on_launch(
    project_name,
    host_name,
    task_name,
    task_type,
    default_output=False,
    project_settings=None,
):
    """Define if host should start last version workfile if possible.

    Default output is `False`. Can be overridden with environment variable
    `AYON_OPEN_LAST_WORKFILE`, valid values without case sensitivity are
    `"0", "1", "true", "false", "yes", "no"`.

    Args:
        project_name (str): Name of project.
        host_name (str): Name of host which is launched. In avalon's
            application context it's value stored in app definition under
            key `"application_dir"`. Is not case sensitive.
        task_name (str): Name of task which is used for launching the host.
            Task name is not case sensitive.
        task_type (str): Task type.
        default_output (Optional[bool]): Default output value if no profile
            is found.
        project_settings (Optional[dict[str, Any]]): Project settings.

    Returns:
        bool: True if host should start workfile.

    """
    if project_settings is None:
        project_settings = get_project_settings(project_name)
    profiles = (
        project_settings
        ["core"]
        ["tools"]
        ["Workfiles"]
        ["last_workfile_on_startup"]
    )

    if not profiles:
        return default_output

    filter_data = {
        "tasks": task_name,
        "task_types": task_type,
        "hosts": host_name
    }
    matching_item = filter_profiles(profiles, filter_data)

    output = None
    if matching_item:
        output = matching_item.get("enabled")

    if output is None:
        return default_output
    return output