mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
mapping provided and required attributes in plugins
This commit is contained in:
parent
aeeb081421
commit
b63453d38f
13 changed files with 193 additions and 16 deletions
20
pype/plugins/global/publish/collect_anatomy.py
Normal file
20
pype/plugins/global/publish/collect_anatomy.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
"""
|
||||||
|
Requires:
|
||||||
|
None
|
||||||
|
Provides:
|
||||||
|
context -> anatomy (pypeapp.Anatomy)
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pypeapp import Anatomy
|
||||||
|
import pyblish.api
|
||||||
|
|
||||||
|
|
||||||
|
class CollectTemplates(pyblish.api.ContextPlugin):
|
||||||
|
"""Collect Anatomy into Context"""
|
||||||
|
|
||||||
|
order = pyblish.api.CollectorOrder
|
||||||
|
label = "Collect Templates"
|
||||||
|
|
||||||
|
def process(self, context):
|
||||||
|
context.data['anatomy'] = Anatomy()
|
||||||
|
self.log.info("Anatomy templates collected...")
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
"""
|
||||||
|
Requires:
|
||||||
|
None
|
||||||
|
Provides:
|
||||||
|
context -> comment (str)
|
||||||
|
"""
|
||||||
|
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,18 @@
|
||||||
|
"""
|
||||||
|
Requires:
|
||||||
|
environment -> SAPUBLISH_INPATH
|
||||||
|
environment -> SAPUBLISH_OUTPATH
|
||||||
|
|
||||||
|
Provides:
|
||||||
|
context -> returnJsonPath (str)
|
||||||
|
context -> project
|
||||||
|
context -> asset
|
||||||
|
instance -> destination_list (list)
|
||||||
|
instance -> representations (list)
|
||||||
|
instance -> source (list)
|
||||||
|
instance -> representations
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
from avalon import io
|
from avalon import io
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
"""
|
||||||
|
Requires:
|
||||||
|
context -> currentFile (str)
|
||||||
|
Provides:
|
||||||
|
context -> label (str)
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,11 @@
|
||||||
|
"""
|
||||||
|
Requires:
|
||||||
|
None
|
||||||
|
|
||||||
|
Provides:
|
||||||
|
context -> currentFile (str)
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,11 @@
|
||||||
|
"""
|
||||||
|
Requires:
|
||||||
|
environment -> DEADLINE_PATH
|
||||||
|
|
||||||
|
Provides:
|
||||||
|
context -> deadlineUser (str)
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
@ -54,4 +62,3 @@ class CollectDeadlineUser(pyblish.api.ContextPlugin):
|
||||||
|
|
||||||
self.log.info("Found Deadline user: {}".format(user))
|
self.log.info("Found Deadline user: {}".format(user))
|
||||||
context.data['deadlineUser'] = user
|
context.data['deadlineUser'] = user
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,13 @@
|
||||||
|
"""
|
||||||
|
Requires:
|
||||||
|
environment -> PYPE_PUBLISH_PATHS
|
||||||
|
context -> workspaceDir
|
||||||
|
|
||||||
|
Provides:
|
||||||
|
context -> user (str)
|
||||||
|
instance -> new instance
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import copy
|
import copy
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,11 @@
|
||||||
|
"""
|
||||||
|
Requires:
|
||||||
|
none
|
||||||
|
|
||||||
|
Provides:
|
||||||
|
context -> machine (str)
|
||||||
|
"""
|
||||||
|
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
import os
|
"""
|
||||||
import json
|
Requires:
|
||||||
|
config_data -> ftrack.output_representation
|
||||||
|
|
||||||
|
Provides:
|
||||||
|
context -> output_repre_config (str)
|
||||||
|
"""
|
||||||
|
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
from pypeapp import config
|
from pypeapp import config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,12 @@
|
||||||
|
"""
|
||||||
|
Requires:
|
||||||
|
config_data -> colorspace.default
|
||||||
|
config_data -> dataflow.default
|
||||||
|
|
||||||
|
Provides:
|
||||||
|
context -> presets
|
||||||
|
"""
|
||||||
|
|
||||||
from pyblish import api
|
from pyblish import api
|
||||||
from pypeapp import config
|
from pypeapp import config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,15 @@
|
||||||
|
"""
|
||||||
|
Requires:
|
||||||
|
None
|
||||||
|
|
||||||
|
Provides:
|
||||||
|
context -> projectData
|
||||||
|
"""
|
||||||
|
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
import pype.api as pype
|
import pype.api as pype
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CollectProjectData(pyblish.api.ContextPlugin):
|
class CollectProjectData(pyblish.api.ContextPlugin):
|
||||||
"""Collecting project data from avalon db"""
|
"""Collecting project data from avalon db"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,86 @@
|
||||||
|
"""
|
||||||
|
Requires:
|
||||||
|
session -> AVALON_PROJECT
|
||||||
|
context -> anatomy (pypeapp.Anatomy)
|
||||||
|
instance -> subset
|
||||||
|
instance -> asset
|
||||||
|
instance -> family
|
||||||
|
|
||||||
import pype.api as pype
|
Provides:
|
||||||
from pypeapp import Anatomy
|
instance -> template
|
||||||
|
instance -> assumedTemplateData
|
||||||
|
instance -> assumedDestination
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from avalon import io, api
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
|
|
||||||
|
|
||||||
class CollectTemplates(pyblish.api.ContextPlugin):
|
class CollectTemplates(pyblish.api.InstancePlugin):
|
||||||
"""Inject the current working file into context"""
|
"""Fill templates with data needed for publish"""
|
||||||
|
|
||||||
order = pyblish.api.CollectorOrder
|
order = pyblish.api.CollectorOrder + 0.1
|
||||||
label = "Collect Templates"
|
label = "Collect and fill Templates"
|
||||||
|
|
||||||
def process(self, context):
|
def process(self, instance):
|
||||||
context.data['anatomy'] = Anatomy()
|
# get all the stuff from the database
|
||||||
self.log.info("Anatomy templates collected...")
|
subset_name = instance.data["subset"]
|
||||||
|
asset_name = instance.data["asset"]
|
||||||
|
project_name = api.Session["AVALON_PROJECT"]
|
||||||
|
|
||||||
|
project = io.find_one({"type": "project",
|
||||||
|
"name": project_name},
|
||||||
|
projection={"config": True, "data": True})
|
||||||
|
|
||||||
|
template = project["config"]["template"]["publish"]
|
||||||
|
anatomy = instance.context.data['anatomy']
|
||||||
|
|
||||||
|
asset = io.find_one({"type": "asset",
|
||||||
|
"name": asset_name,
|
||||||
|
"parent": project["_id"]})
|
||||||
|
|
||||||
|
assert asset, ("No asset found by the name '{}' "
|
||||||
|
"in project '{}'".format(asset_name, project_name))
|
||||||
|
silo = asset['silo']
|
||||||
|
|
||||||
|
subset = io.find_one({"type": "subset",
|
||||||
|
"name": subset_name,
|
||||||
|
"parent": asset["_id"]})
|
||||||
|
|
||||||
|
# assume there is no version yet, we start at `1`
|
||||||
|
version = None
|
||||||
|
version_number = 1
|
||||||
|
if subset is not None:
|
||||||
|
version = io.find_one({"type": "version",
|
||||||
|
"parent": subset["_id"]},
|
||||||
|
sort=[("name", -1)])
|
||||||
|
|
||||||
|
# if there is a subset there ought to be version
|
||||||
|
if version is not None:
|
||||||
|
version_number += int(version["name"])
|
||||||
|
|
||||||
|
hierarchy = asset['data']['parents']
|
||||||
|
if hierarchy:
|
||||||
|
# hierarchy = os.path.sep.join(hierarchy)
|
||||||
|
hierarchy = os.path.join(*hierarchy)
|
||||||
|
|
||||||
|
template_data = {"root": api.Session["AVALON_PROJECTS"],
|
||||||
|
"project": {"name": project_name,
|
||||||
|
"code": project['data']['code']},
|
||||||
|
"silo": silo,
|
||||||
|
"family": instance.data['family'],
|
||||||
|
"asset": asset_name,
|
||||||
|
"subset": subset_name,
|
||||||
|
"version": version_number,
|
||||||
|
"hierarchy": hierarchy,
|
||||||
|
"representation": "TEMP"}
|
||||||
|
|
||||||
|
instance.data["template"] = template
|
||||||
|
instance.data["assumedTemplateData"] = template_data
|
||||||
|
|
||||||
|
# We take the parent folder of representation 'filepath'
|
||||||
|
instance.data["assumedDestination"] = os.path.dirname(
|
||||||
|
(anatomy.format(template_data)).publish.path
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ class IntegrateAssumedDestination(pyblish.api.InstancePlugin):
|
||||||
"resources")
|
"resources")
|
||||||
|
|
||||||
# Clean the path
|
# Clean the path
|
||||||
mock_destination = os.path.abspath(os.path.normpath(mock_destination)).replace("\\", "/")
|
mock_destination = os.path.abspath(
|
||||||
|
os.path.normpath(mock_destination)).replace("\\", "/")
|
||||||
|
|
||||||
# Define resource destination and transfers
|
# Define resource destination and transfers
|
||||||
resources = instance.data.get("resources", list())
|
resources = instance.data.get("resources", list())
|
||||||
|
|
@ -38,7 +39,8 @@ class IntegrateAssumedDestination(pyblish.api.InstancePlugin):
|
||||||
for resource in resources:
|
for resource in resources:
|
||||||
|
|
||||||
# Add destination to the resource
|
# Add destination to the resource
|
||||||
source_filename = os.path.basename(resource["source"]).replace("\\", "/")
|
source_filename = os.path.basename(
|
||||||
|
resource["source"]).replace("\\", "/")
|
||||||
destination = os.path.join(mock_destination, source_filename)
|
destination = os.path.join(mock_destination, source_filename)
|
||||||
|
|
||||||
# Force forward slashes to fix issue with software unable
|
# Force forward slashes to fix issue with software unable
|
||||||
|
|
@ -53,7 +55,8 @@ class IntegrateAssumedDestination(pyblish.api.InstancePlugin):
|
||||||
files = resource['files']
|
files = resource['files']
|
||||||
for fsrc in files:
|
for fsrc in files:
|
||||||
fname = os.path.basename(fsrc)
|
fname = os.path.basename(fsrc)
|
||||||
fdest = os.path.join(mock_destination, fname).replace("\\", "/")
|
fdest = os.path.join(
|
||||||
|
mock_destination, fname).replace("\\", "/")
|
||||||
transfers.append([fsrc, fdest])
|
transfers.append([fsrc, fdest])
|
||||||
|
|
||||||
instance.data["resources"] = resources
|
instance.data["resources"] = resources
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue