Skip to content

pipeline

defer(callable, timeout=0)

Defer a callable to the next event loop.

Source code in client/ayon_silhouette/api/pipeline.py
54
55
56
def defer(callable, timeout=0):
    """Defer a callable to the next event loop."""
    QtCore.QTimer.singleShot(timeout, callable)

iter_containers(project=None, session=None)

Yield all source objects in the active project with AYON property AYON container ID

Source code in client/ayon_silhouette/api/pipeline.py
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
def iter_containers(project=None, session=None):
    """Yield all source objects in the active project with AYON property
     AYON container ID"""

    if project is None:
        project = fx.activeProject()

    if not project:
        return

    # List all sources in project with `AYON` property
    for source in project.sources:
        data = parse_container(source, project=project)
        if data:
            yield data

    if session is None:
        session = fx.activeSession()

    if not session:
        return

    # List all nodes in session with `AYON` property
    for node in session.nodes:
        data = parse_container(node, project=project, session=session)
        if data:
            yield data

iter_instances(session=None)

Yield all objects in the active session that have 'id' attribute set matching an AYON container ID

Source code in client/ayon_silhouette/api/pipeline.py
377
378
379
380
381
382
383
384
385
386
387
388
389
390
def iter_instances(session=None):
    """Yield all objects in the active session that have 'id' attribute set
    matching an AYON container ID"""

    if session is None:
        session = fx.activeSession()
    if not session:
        return

    for node in session.nodes:
        data = lib.read(node)
        if data and data.get("id") == AYON_INSTANCE_ID:
            data["_node"] = node
            yield data

parse_container(source, project=None, session=None)

Return the container node's full container data.

Parameters:

Name Type Description Default
source Source | Node

A Silhouette source or node.

required
project Optional[Project]

Project related to the source item or node so that we can track it back to the project.

None
session Optional[Session]

Session related to the source item or node so that we can track it back to the session.

None

Returns:

Type Description

dict[str, Any]: The container schema data for this container node.

Source code in client/ayon_silhouette/api/pipeline.py
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
def parse_container(source, project=None, session=None):
    """Return the container node's full container data.

    Args:
        source (fx.Source | fx.Node): A Silhouette source or node.
        project (Optional[fx.Project]): Project related to the source
            item or node so that we can track it back to the project.
        session (Optional[fx.Session]): Session related to the source
            item or node so that we can track it back to the session.

    Returns:
        dict[str, Any]: The container schema data for this container node.

    """
    data = lib.read(source)
    if not data:
        return

    # TODO: ensure object is actually a container by `id` value

    # Backwards compatibility pre-schemas for containers
    data["schema"] = data.get("schema", "ayon:container-3.0")
    data["objectName"] = source.label  # required for container data model

    # Append transient data
    data["_item"] = source
    if project is not None:
        data["_project"] = project
    if session is not None:
        data["_session"] = session

    return data