Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Bugfix/multiroot cleanup #145

Merged
merged 15 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pyblish import api as pyblish
from avalon import api as avalon
from .lib import filter_pyblish_plugins
from pypeapp import config, Roots
from pypeapp import config, Anatomy


import logging
Expand Down Expand Up @@ -100,8 +100,9 @@ def install():
avalon.register_plugin_path(avalon.InventoryAction, path)

if project_name:
root_obj = Roots(project_name)
avalon.register_root(root_obj.roots)
anatomy = Anatomy(project_name)
anatomy.set_root_environments()
avalon.register_root(anatomy.roots)
# apply monkey patched discover to original one
avalon.discover = patched_discover

Expand Down
3 changes: 1 addition & 2 deletions pype/avalon_apps/avalon_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ def tray_menu(self, parent_menu=None):
def show_launcher(self):
# if app_launcher don't exist create it/otherwise only show main window
if self.app_launcher is None:
root = os.path.realpath(os.environ["AVALON_PROJECTS"])
io.install()
APP_PATH = launcher_lib.resource("qml", "main.qml")
self.app_launcher = launcher_widget.Launcher(root, APP_PATH)
self.app_launcher = launcher_widget.Launcher(APP_PATH)
self.app_launcher.window.show()

def show_library_loader(self):
Expand Down
30 changes: 1 addition & 29 deletions pype/ftrack/actions/action_delete_old_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,8 @@ def discover(self, session, entities, event):
return False

def interface(self, session, entities, event):
# TODO Add roots existence validation
items = []
root = os.environ.get("AVALON_PROJECTS")
if not root:
msg = "Root path to projects is not set."
items.append({
"type": "label",
"value": "<i><b>ERROR:</b> {}</i>".format(msg)
})
self.show_interface(
items=items, title=self.inteface_title, event=event
)
return {
"success": False,
"message": msg
}

if not os.path.exists(root):
msg = "Root path does not exists \"{}\".".format(str(root))
items.append({
"type": "label",
"value": "<i><b>ERROR:</b> {}</i>".format(msg)
})
self.show_interface(
items=items, title=self.inteface_title, event=event
)
return {
"success": False,
"message": msg
}

values = event["data"].get("values")
if values:
versions_count = int(values["last_versions_count"])
Expand Down
2 changes: 1 addition & 1 deletion pype/ftrack/actions/action_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def launch(self, session, entities, event):

repre_path = self.path_from_represenation(repre, anatomy)
# TODO add backup solution where root of path from component
# is repalced with AVALON_PROJECTS root
# is repalced with root
if not frame:
self.process_single_file(
repre_path, anatomy, anatomy_name, anatomy_data
Expand Down
13 changes: 11 additions & 2 deletions pype/nuke/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,16 @@ def format_anatomy(data):
log.debug("__ anatomy.templates: {}".format(anatomy.templates))

try:
padding = int(anatomy.templates['render']['padding'])
# TODO: bck compatibility with old anatomy template
padding = int(
anatomy.templates["render"].get(
"frame_padding",
anatomy.templates["render"].get("padding")
)
)
except KeyError as e:
msg = ("`padding` key is not in `render` "
"or `frame_padding` on is not available in "
"Anatomy template. Please, add it there and restart "
"the pipeline (padding: \"4\"): `{}`").format(e)

Expand Down Expand Up @@ -973,7 +980,9 @@ def set_context_settings(self):
self.set_colorspace()

def set_favorites(self):
projects_root = os.getenv("AVALON_PROJECTS")
anatomy = get_anatomy()
work_template = anatomy.templates["work"]["path"]
projects_root = anatomy.root_value_for_template(work_template)
work_dir = os.getenv("AVALON_WORKDIR")
asset = os.getenv("AVALON_ASSET")
project = os.getenv("AVALON_PROJECT")
Expand Down
29 changes: 18 additions & 11 deletions pype/nukestudio/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import avalon.api as avalon
from avalon.vendor.Qt import (QtWidgets, QtGui)
import pype.api as pype
from pypeapp import Logger
from pypeapp import Logger, Anatomy

log = Logger().get_logger(__name__, "nukestudio")

Expand All @@ -30,12 +30,17 @@ def set_workfiles():
# show workfile gui
workfiles.show(workdir)


def sync_avalon_data_to_workfile():
# import session to get project dir
S = avalon.Session
active_project_root = os.path.normpath(
os.path.join(S['AVALON_PROJECTS'], S['AVALON_PROJECT'])
)
project_name = avalon.Session["AVALON_PROJECT"]

anatomy = Anatomy(project_name)
work_template = anatomy.templates["work"]["path"]
work_root = anatomy.root_value_for_template(work_template)
active_project_root = (
os.path.join(work_root, project_name)
).replace("\\", "/")
# getting project
project = hiero.core.projects()[-1]

Expand Down Expand Up @@ -350,17 +355,19 @@ def CreateNukeWorkfile(nodes=None,
# create root node and save all metadata
root_node = hiero.core.nuke.RootNode()

root_path = os.environ["AVALON_PROJECTS"]
anatomy = Anatomy(os.environ["AVALON_PROJECT"])
work_template = anatomy.templates["work"]["path"]
root_path = anatomy.root_value_for_template(work_template)

nuke_script.addNode(root_node)

# here to call pype.nuke.lib.BuildWorkfile
script_builder = nklib.BuildWorkfile(
root_node=root_node,
root_path=root_path,
nodes=nuke_script.getNodes(),
**kwargs
)
root_node=root_node,
root_path=root_path,
nodes=nuke_script.getNodes(),
**kwargs
)


class ClipLoader:
Expand Down
2 changes: 0 additions & 2 deletions pype/plugins/adobecommunicator/publish/collect_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ def process(self, context):
# get avalon session data and convert \ to /
_S = avalon.session

projects = Path(_S["AVALON_PROJECTS"]).resolve()
asset = _S["AVALON_ASSET"]
workdir = Path(_S["AVALON_WORKDIR"]).resolve()
_S["AVALON_PROJECTS"] = str(projects)
_S["AVALON_WORKDIR"] = str(workdir)

context.data["avalonSession"] = _S
Expand Down
7 changes: 5 additions & 2 deletions pype/plugins/global/publish/integrate_master_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,11 @@ def process(self, instance):
_anatomy_filled = anatomy.format(anatomy_data)
_template_filled = _anatomy_filled["master"]["path"]
head, tail = _template_filled.split(frame_splitter)
padding = (
anatomy.templates["render"]["padding"]
padding = int(
anatomy.templates["render"].get(
"frame_padding",
anatomy.templates["render"].get("padding")
)
)

dst_col = clique.Collection(
Expand Down
9 changes: 6 additions & 3 deletions pype/plugins/global/publish/integrate_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,11 @@ def register(self, instance):
index_frame_start = None

if repre.get("frameStart"):
frame_start_padding = (
anatomy.templates["render"]["padding"]
frame_start_padding = int(
anatomy.templates["render"].get(
"frame_padding",
anatomy.templates["render"].get("padding")
)
)
index_frame_start = int(repre.get("frameStart"))

Expand Down Expand Up @@ -651,7 +654,7 @@ def create_version_data(self, context, instance):
source = context.data["currentFile"]
anatomy = instance.context.data["anatomy"]
success, rootless_path = (
anatomy.roots_obj.find_root_template_from_path(source)
anatomy.find_root_template_from_path(source)
)
if success:
source = rootless_path
Expand Down
12 changes: 6 additions & 6 deletions pype/plugins/global/publish/submit_publish_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _submit_deadline_post_job(self, instance, job):
output_dir = instance.data["outputDir"]
# Convert output dir to `{root}/rest/of/path/...` with Anatomy
success, rootless_path = (
self.anatomy.roots_obj.find_root_template_from_path(output_dir)
self.anatomy.find_root_template_from_path(output_dir)
)
if not success:
# `rootless_path` is not set to `output_dir` if none of roots match
Expand Down Expand Up @@ -379,7 +379,7 @@ def _create_instances_for_aov(self, instance_data, exp_files):

staging = os.path.dirname(list(cols[0])[0])
success, rootless_staging_dir = (
self.anatomy.roots_obj.find_root_template_from_path(staging)
self.anatomy.find_root_template_from_path(staging)
)
if success:
staging = rootless_staging_dir
Expand Down Expand Up @@ -471,7 +471,7 @@ def _get_representations(self, instance, exp_files):

staging = os.path.dirname(list(collection)[0])
success, rootless_staging_dir = (
self.anatomy.roots_obj.find_root_template_from_path(staging)
self.anatomy.find_root_template_from_path(staging)
)
if success:
staging = rootless_staging_dir
Expand Down Expand Up @@ -506,7 +506,7 @@ def _get_representations(self, instance, exp_files):

staging = os.path.dirname(remainder)
success, rootless_staging_dir = (
self.anatomy.roots_obj.find_root_template_from_path(staging)
self.anatomy.find_root_template_from_path(staging)
)
if success:
staging = rootless_staging_dir
Expand Down Expand Up @@ -619,7 +619,7 @@ def process(self, instance):
source = context.data["currentFile"]

success, rootless_path = (
self.anatomy.roots_obj.find_root_template_from_path(source)
self.anatomy.find_root_template_from_path(source)
)
if success:
source = rootless_path
Expand Down Expand Up @@ -684,7 +684,7 @@ def process(self, instance):
staging_dir = repre.get("stagingDir")
if staging_dir:
success, rootless_staging_dir = (
self.anatomy.roots_obj.find_root_template_from_path(
self.anatomy.find_root_template_from_path(
staging_dir
)
)
Expand Down
85 changes: 53 additions & 32 deletions pype/plugins/maya/publish/validate_ass_relative_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,50 +37,71 @@ def process(self, instance):

scene_dir, scene_basename = os.path.split(cmds.file(q=True, loc=True))
scene_name, _ = os.path.splitext(scene_basename)
project_root = "{}{}{}".format(
os.environ.get("AVALON_PROJECTS"),
os.path.sep,
os.environ.get("AVALON_PROJECT")
)
assert self.maya_is_true(relative_texture) is not True, \
("Texture path is set to be absolute")
assert self.maya_is_true(relative_procedural) is not True, \
("Procedural path is set to be absolute")

texture_search_path = texture_search_path.replace("\\", "/")
procedural_search_path = procedural_search_path.replace("\\", "/")
project_root = project_root.replace("\\", "/")
anatomy = instance.context.data["anatomy"]

# Use project root variables for multiplatform support, see:
# https://docs.arnoldrenderer.com/display/A5AFMUG/Search+Path
# ':' as path separator is supported by Arnold for all platforms.
keys = anatomy.root_environments().keys()
paths = []
for k in keys:
paths.append("[{}]".format(k))

self.log.info("discovered roots: {}".format(":".join(paths)))

assert project_root in texture_search_path, \
("Project root is not in texture_search_path")
assert project_root in procedural_search_path, \
("Project root is not in procedural_search_path")
assert ":".join(paths) in texture_search_path, (
"Project roots are not in texture_search_path"
)

assert ":".join(paths) in procedural_search_path, (
"Project roots are not in procedural_search_path"
)

@classmethod
def repair(cls, instance):
texture_search_path = cmds.getAttr(
"defaultArnoldRenderOptions.tspath"
texture_path = cmds.getAttr("defaultArnoldRenderOptions.tspath")
procedural_path = cmds.getAttr("defaultArnoldRenderOptions.pspath")

# Use project root variables for multiplatform support, see:
# https://docs.arnoldrenderer.com/display/A5AFMUG/Search+Path
# ':' as path separator is supported by Arnold for all platforms.
anatomy = instance.context.data["anatomy"]
keys = anatomy.root_environments().keys()
paths = []
for k in keys:
paths.append("[{}]".format(k))

cmds.setAttr(
"defaultArnoldRenderOptions.tspath",
":".join([p for p in paths + [texture_path] if p]),
type="string"
)
cmds.setAttr(
"defaultArnoldRenderOptions.absolute_texture_paths",
False
)

cmds.setAttr(
"defaultArnoldRenderOptions.pspath",
":".join([p for p in paths + [procedural_path] if p]),
type="string"
)
procedural_search_path = cmds.getAttr(
"defaultArnoldRenderOptions.pspath"
cmds.setAttr(
"defaultArnoldRenderOptions.absolute_procedural_paths",
False
)

project_root = "{}{}{}".format(
os.environ.get("AVALON_PROJECTS"),
os.path.sep,
os.environ.get("AVALON_PROJECT"),
).replace("\\", "/")

cmds.setAttr("defaultArnoldRenderOptions.tspath",
project_root + os.pathsep + texture_search_path,
type="string")
cmds.setAttr("defaultArnoldRenderOptions.pspath",
project_root + os.pathsep + procedural_search_path,
type="string")
cmds.setAttr("defaultArnoldRenderOptions.absolute_procedural_paths",
False)
cmds.setAttr("defaultArnoldRenderOptions.absolute_texture_paths",
False)
@staticmethod
def find_absolute_path(relative_path, all_root_paths):
for root_path in all_root_paths:
possible_path = os.path.join(root_path, relative_path)
if os.path.exists(possible_path):
return possible_path

def maya_is_true(self, attr_val):
"""
Expand Down
7 changes: 6 additions & 1 deletion pype/plugins/nukestudio/publish/collect_plates.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ def process(self, instance):
version_data = dict()
context = instance.context
anatomy = context.data.get("anatomy", None)
padding = int(anatomy.templates['render']['padding'])
padding = int(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local variable 'padding' is assigned to but never used

anatomy.templates["render"].get(
"frame_padding",
anatomy.templates["render"].get("padding")
)
)

name = instance.data["subset"]
source_path = instance.data["sourcePath"]
Expand Down
Loading