Skip to content

interfaces

ILoadHost

Bases: AbstractHost

Implementation requirements to be able use reference of representations.

The load plugins can do referencing even without implementation of methods here, but switch and removement of containers would not be possible.

Questions
  • Is list container dependency of host or load plugins?
  • Should this be directly in HostBase?
    • how to find out if referencing is available?
    • do we need to know that?
Source code in client/ayon_core/host/interfaces/interfaces.py
 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
class ILoadHost(AbstractHost):
    """Implementation requirements to be able use reference of representations.

    The load plugins can do referencing even without implementation of methods
    here, but switch and removement of containers would not be possible.

    Questions:
        - Is list container dependency of host or load plugins?
        - Should this be directly in HostBase?
            - how to find out if referencing is available?
            - do we need to know that?
    """

    @staticmethod
    def get_missing_load_methods(host):
        """Look for missing methods on "old type" host implementation.

        Method is used for validation of implemented functions related to
        loading. Checks only existence of methods.

        Args:
            Union[ModuleType, AbstractHost]: Object of host where to look for
                required methods.

        Returns:
            list[str]: Missing method implementations for loading workflow.
        """

        if isinstance(host, ILoadHost):
            return []

        required = ["ls"]
        missing = []
        for name in required:
            if not hasattr(host, name):
                missing.append(name)
        return missing

    @staticmethod
    def validate_load_methods(host):
        """Validate implemented methods of "old type" host for load workflow.

        Args:
            Union[ModuleType, AbstractHost]: Object of host to validate.

        Raises:
            MissingMethodsError: If there are missing methods on host
                implementation.
        """
        missing = ILoadHost.get_missing_load_methods(host)
        if missing:
            raise MissingMethodsError(host, missing)

    @abstractmethod
    def get_containers(self):
        """Retrieve referenced containers from scene.

        This can be implemented in hosts where referencing can be used.

        Todo:
            Rename function to something more self explanatory.
                Suggestion: 'get_containers'

        Returns:
            list[dict]: Information about loaded containers.
        """

        pass

    # --- Deprecated method names ---
    def ls(self):
        """Deprecated variant of 'get_containers'.

        Todo:
            Remove when all usages are replaced.
        """

        return self.get_containers()

get_containers() abstractmethod

Retrieve referenced containers from scene.

This can be implemented in hosts where referencing can be used.

Todo

Rename function to something more self explanatory. Suggestion: 'get_containers'

Returns:

Type Description

list[dict]: Information about loaded containers.

Source code in client/ayon_core/host/interfaces/interfaces.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@abstractmethod
def get_containers(self):
    """Retrieve referenced containers from scene.

    This can be implemented in hosts where referencing can be used.

    Todo:
        Rename function to something more self explanatory.
            Suggestion: 'get_containers'

    Returns:
        list[dict]: Information about loaded containers.
    """

    pass

get_missing_load_methods(host) staticmethod

Look for missing methods on "old type" host implementation.

Method is used for validation of implemented functions related to loading. Checks only existence of methods.

Parameters:

Name Type Description Default
Union[ModuleType, AbstractHost]

Object of host where to look for required methods.

required

Returns:

Type Description

list[str]: Missing method implementations for loading workflow.

Source code in client/ayon_core/host/interfaces/interfaces.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@staticmethod
def get_missing_load_methods(host):
    """Look for missing methods on "old type" host implementation.

    Method is used for validation of implemented functions related to
    loading. Checks only existence of methods.

    Args:
        Union[ModuleType, AbstractHost]: Object of host where to look for
            required methods.

    Returns:
        list[str]: Missing method implementations for loading workflow.
    """

    if isinstance(host, ILoadHost):
        return []

    required = ["ls"]
    missing = []
    for name in required:
        if not hasattr(host, name):
            missing.append(name)
    return missing

ls()

Deprecated variant of 'get_containers'.

Todo

Remove when all usages are replaced.

Source code in client/ayon_core/host/interfaces/interfaces.py
78
79
80
81
82
83
84
85
def ls(self):
    """Deprecated variant of 'get_containers'.

    Todo:
        Remove when all usages are replaced.
    """

    return self.get_containers()

validate_load_methods(host) staticmethod

Validate implemented methods of "old type" host for load workflow.

Parameters:

Name Type Description Default
Union[ModuleType, AbstractHost]

Object of host to validate.

required

Raises:

Type Description
MissingMethodsError

If there are missing methods on host implementation.

Source code in client/ayon_core/host/interfaces/interfaces.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@staticmethod
def validate_load_methods(host):
    """Validate implemented methods of "old type" host for load workflow.

    Args:
        Union[ModuleType, AbstractHost]: Object of host to validate.

    Raises:
        MissingMethodsError: If there are missing methods on host
            implementation.
    """
    missing = ILoadHost.get_missing_load_methods(host)
    if missing:
        raise MissingMethodsError(host, missing)

INewPublisher

Bases: IPublishHost

Legacy interface replaced by 'IPublishHost'.

Deprecated

'INewPublisher' is replaced by 'IPublishHost' please change your imports. There is no "reasonable" way hot mark these classes as deprecated to show warning of wrong import. Deprecated since 3.14. will be removed in 3.15.

Source code in client/ayon_core/host/interfaces/interfaces.py
178
179
180
181
182
183
184
185
186
187
188
189
class INewPublisher(IPublishHost):
    """Legacy interface replaced by 'IPublishHost'.

    Deprecated:
        'INewPublisher' is replaced by 'IPublishHost' please change your
        imports.
        There is no "reasonable" way hot mark these classes as deprecated
        to show warning of wrong import. Deprecated since 3.14.* will be
        removed in 3.15.*
    """

    pass

IPublishHost

Bases: AbstractHost

Functions related to new creation system in new publisher.

New publisher is not storing information only about each created instance but also some global data. At this moment are data related only to context publish plugins but that can extend in future.

Source code in client/ayon_core/host/interfaces/interfaces.py
 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
class IPublishHost(AbstractHost):
    """Functions related to new creation system in new publisher.

    New publisher is not storing information only about each created instance
    but also some global data. At this moment are data related only to context
    publish plugins but that can extend in future.
    """

    @staticmethod
    def get_missing_publish_methods(host):
        """Look for missing methods on "old type" host implementation.

        Method is used for validation of implemented functions related to
        new publish creation. Checks only existence of methods.

        Args:
            Union[ModuleType, AbstractHost]: Host module where to look for
                required methods.

        Returns:
            list[str]: Missing method implementations for new publisher
                workflow.
        """

        if isinstance(host, IPublishHost):
            return []

        required = [
            "get_context_data",
            "update_context_data",
            "get_context_title",
            "get_current_context",
        ]
        missing = []
        for name in required:
            if not hasattr(host, name):
                missing.append(name)
        return missing

    @staticmethod
    def validate_publish_methods(host):
        """Validate implemented methods of "old type" host.

        Args:
            Union[ModuleType, AbstractHost]: Host module to validate.

        Raises:
            MissingMethodsError: If there are missing methods on host
                implementation.
        """
        missing = IPublishHost.get_missing_publish_methods(host)
        if missing:
            raise MissingMethodsError(host, missing)

    @abstractmethod
    def get_context_data(self):
        """Get global data related to creation-publishing from workfile.

        These data are not related to any created instance but to whole
        publishing context. Not saving/returning them will cause that each
        reset of publishing resets all values to default ones.

        Context data can contain information about enabled/disabled publish
        plugins or other values that can be filled by artist.

        Returns:
            dict: Context data stored using 'update_context_data'.
        """

        pass

    @abstractmethod
    def update_context_data(self, data, changes):
        """Store global context data to workfile.

        Called when some values in context data has changed.

        Without storing the values in a way that 'get_context_data' would
        return them will each reset of publishing cause loose of filled values
        by artist. Best practice is to store values into workfile, if possible.

        Args:
            data (dict): New data as are.
            changes (dict): Only data that has been changed. Each value has
                tuple with '(<old>, <new>)' value.
        """

        pass

get_context_data() abstractmethod

Get global data related to creation-publishing from workfile.

These data are not related to any created instance but to whole publishing context. Not saving/returning them will cause that each reset of publishing resets all values to default ones.

Context data can contain information about enabled/disabled publish plugins or other values that can be filled by artist.

Returns:

Name Type Description
dict

Context data stored using 'update_context_data'.

Source code in client/ayon_core/host/interfaces/interfaces.py
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
@abstractmethod
def get_context_data(self):
    """Get global data related to creation-publishing from workfile.

    These data are not related to any created instance but to whole
    publishing context. Not saving/returning them will cause that each
    reset of publishing resets all values to default ones.

    Context data can contain information about enabled/disabled publish
    plugins or other values that can be filled by artist.

    Returns:
        dict: Context data stored using 'update_context_data'.
    """

    pass

get_missing_publish_methods(host) staticmethod

Look for missing methods on "old type" host implementation.

Method is used for validation of implemented functions related to new publish creation. Checks only existence of methods.

Parameters:

Name Type Description Default
Union[ModuleType, AbstractHost]

Host module where to look for required methods.

required

Returns:

Type Description

list[str]: Missing method implementations for new publisher workflow.

Source code in client/ayon_core/host/interfaces/interfaces.py
 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
122
123
124
125
@staticmethod
def get_missing_publish_methods(host):
    """Look for missing methods on "old type" host implementation.

    Method is used for validation of implemented functions related to
    new publish creation. Checks only existence of methods.

    Args:
        Union[ModuleType, AbstractHost]: Host module where to look for
            required methods.

    Returns:
        list[str]: Missing method implementations for new publisher
            workflow.
    """

    if isinstance(host, IPublishHost):
        return []

    required = [
        "get_context_data",
        "update_context_data",
        "get_context_title",
        "get_current_context",
    ]
    missing = []
    for name in required:
        if not hasattr(host, name):
            missing.append(name)
    return missing

update_context_data(data, changes) abstractmethod

Store global context data to workfile.

Called when some values in context data has changed.

Without storing the values in a way that 'get_context_data' would return them will each reset of publishing cause loose of filled values by artist. Best practice is to store values into workfile, if possible.

Parameters:

Name Type Description Default
data dict

New data as are.

required
changes dict

Only data that has been changed. Each value has tuple with '(, )' value.

required
Source code in client/ayon_core/host/interfaces/interfaces.py
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
@abstractmethod
def update_context_data(self, data, changes):
    """Store global context data to workfile.

    Called when some values in context data has changed.

    Without storing the values in a way that 'get_context_data' would
    return them will each reset of publishing cause loose of filled values
    by artist. Best practice is to store values into workfile, if possible.

    Args:
        data (dict): New data as are.
        changes (dict): Only data that has been changed. Each value has
            tuple with '(<old>, <new>)' value.
    """

    pass

validate_publish_methods(host) staticmethod

Validate implemented methods of "old type" host.

Parameters:

Name Type Description Default
Union[ModuleType, AbstractHost]

Host module to validate.

required

Raises:

Type Description
MissingMethodsError

If there are missing methods on host implementation.

Source code in client/ayon_core/host/interfaces/interfaces.py
127
128
129
130
131
132
133
134
135
136
137
138
139
140
@staticmethod
def validate_publish_methods(host):
    """Validate implemented methods of "old type" host.

    Args:
        Union[ModuleType, AbstractHost]: Host module to validate.

    Raises:
        MissingMethodsError: If there are missing methods on host
            implementation.
    """
    missing = IPublishHost.get_missing_publish_methods(host)
    if missing:
        raise MissingMethodsError(host, missing)