mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
use representation entity in global load and inventory actions
This commit is contained in:
parent
c4f74a6aed
commit
6045fc5baa
3 changed files with 27 additions and 18 deletions
|
|
@ -1,12 +1,12 @@
|
|||
from ayon_core.pipeline import InventoryAction
|
||||
from ayon_core.pipeline import get_current_project_name
|
||||
import ayon_api
|
||||
|
||||
from ayon_core.pipeline import get_current_project_name, InventoryAction
|
||||
from ayon_core.pipeline.load.plugins import discover_loader_plugins
|
||||
from ayon_core.pipeline.load.utils import (
|
||||
get_loader_identifier,
|
||||
remove_container,
|
||||
load_container,
|
||||
)
|
||||
from ayon_core.client import get_representation_by_id
|
||||
|
||||
|
||||
class RemoveAndLoad(InventoryAction):
|
||||
|
|
@ -21,6 +21,7 @@ class RemoveAndLoad(InventoryAction):
|
|||
get_loader_identifier(plugin): plugin
|
||||
for plugin in discover_loader_plugins(project_name=project_name)
|
||||
}
|
||||
repre_ids = set()
|
||||
for container in containers:
|
||||
# Get loader
|
||||
loader_name = container["loader"]
|
||||
|
|
@ -30,16 +31,23 @@ class RemoveAndLoad(InventoryAction):
|
|||
"Failed to get loader '{}', can't remove "
|
||||
"and load container".format(loader_name)
|
||||
)
|
||||
repre_ids.add(container["representation"])
|
||||
|
||||
# Get representation
|
||||
representation = get_representation_by_id(
|
||||
project_name, container["representation"]
|
||||
repre_entities_by_id = {
|
||||
repre_entity["id"]: repre_entity
|
||||
for repre_entity in ayon_api.get_representations(
|
||||
project_name, representation_ids=repre_ids
|
||||
)
|
||||
if not representation:
|
||||
}
|
||||
for container in containers:
|
||||
# Get representation
|
||||
repre_id = container["representation"]
|
||||
repre_entity = repre_entities_by_id.get(repre_id)
|
||||
if not repre_entity:
|
||||
self.log.warning(
|
||||
"Skipping remove and load because representation id is not"
|
||||
" found in database: '{}'".format(
|
||||
container["representation"]
|
||||
repre_id
|
||||
)
|
||||
)
|
||||
continue
|
||||
|
|
@ -48,4 +56,4 @@ class RemoveAndLoad(InventoryAction):
|
|||
remove_container(container)
|
||||
|
||||
# Load container
|
||||
load_container(loader, representation)
|
||||
load_container(loader, repre_entity)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
# from qtpy import QtWidgets, QtCore
|
||||
#
|
||||
# from ayon_core import style
|
||||
# from ayon_core.client import get_representations
|
||||
# from ayon_core.addon import AddonsManager
|
||||
# from ayon_core.lib import format_file_size
|
||||
# from ayon_core.pipeline import load, Anatomy
|
||||
|
|
@ -265,7 +264,7 @@
|
|||
# print(msg)
|
||||
# return
|
||||
#
|
||||
# repres = list(get_representations(
|
||||
# repres = list(ayon_api.get_representations(
|
||||
# project_name, version_ids=version_ids
|
||||
# ))
|
||||
#
|
||||
|
|
@ -276,7 +275,9 @@
|
|||
# dir_paths = {}
|
||||
# file_paths_by_dir = collections.defaultdict(list)
|
||||
# for repre in repres:
|
||||
# file_path, seq_path = self.path_from_representation(repre, anatomy)
|
||||
# file_path, seq_path = self.path_from_representation(
|
||||
# repre, anatomy
|
||||
# )
|
||||
# if file_path is None:
|
||||
# self.log.debug((
|
||||
# "Could not format path for represenation \"{}\""
|
||||
|
|
@ -347,7 +348,7 @@
|
|||
# if version_tags == orig_version_tags:
|
||||
# continue
|
||||
#
|
||||
# update_query = {"_id": version["id"]}
|
||||
# update_query = {"id": version["id"]}
|
||||
# update_data = {"$set": {"data.tags": version_tags}}
|
||||
# mongo_changes_bulk.append(UpdateOne(update_query, update_data))
|
||||
#
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ import copy
|
|||
import platform
|
||||
from collections import defaultdict
|
||||
|
||||
import ayon_api
|
||||
from qtpy import QtWidgets, QtCore, QtGui
|
||||
|
||||
from ayon_core.client import get_representations
|
||||
from ayon_core.pipeline import load, Anatomy
|
||||
from ayon_core import resources, style
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ class DeliveryOptionsDialog(QtWidgets.QDialog):
|
|||
)
|
||||
|
||||
anatomy_data = copy.deepcopy(repre["context"])
|
||||
new_report_items = check_destination_path(str(repre["_id"]),
|
||||
new_report_items = check_destination_path(repre["id"],
|
||||
self.anatomy,
|
||||
anatomy_data,
|
||||
datetime_data,
|
||||
|
|
@ -260,7 +260,7 @@ class DeliveryOptionsDialog(QtWidgets.QDialog):
|
|||
report_items.update(new_report_items)
|
||||
self._update_progress(uploaded)
|
||||
else: # fallback for Pype2 and representations without files
|
||||
frame = repre['context'].get('frame')
|
||||
frame = repre["context"].get("frame")
|
||||
if frame:
|
||||
repre["context"]["frame"] = len(str(frame)) * "#"
|
||||
|
||||
|
|
@ -290,9 +290,9 @@ class DeliveryOptionsDialog(QtWidgets.QDialog):
|
|||
return templates
|
||||
|
||||
def _set_representations(self, project_name, contexts):
|
||||
version_ids = [context["version"]["_id"] for context in contexts]
|
||||
version_ids = {context["version"]["id"] for context in contexts}
|
||||
|
||||
repres = list(get_representations(
|
||||
repres = list(ayon_api.get_representations(
|
||||
project_name, version_ids=version_ids
|
||||
))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue