Skip to content

Commit

Permalink
Add branch 4-enhancement-allow-hiero-to-publish-using-symlinks into 3…
Browse files Browse the repository at this point in the history
….15.12-quad.3.13
  • Loading branch information
BenSouchet committed Oct 30, 2023
1 parent f6d9a08 commit 2b073b4
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
12 changes: 9 additions & 3 deletions openpype/hosts/hiero/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,9 @@ def __init__(self, cls, track_item, **kwargs):
# adding ui inputs if any
self.ui_inputs = kwargs.get("ui_inputs", {})

project_settings = get_current_project_settings()
self.symlink = project_settings["hiero"]["create"]["CreateShotClip"]["symlink"] # noqa

# populate default data before we get other attributes
self._populate_track_item_default_data()

Expand Down Expand Up @@ -756,7 +759,6 @@ def convert(self):

def _populate_track_item_default_data(self):
""" Populate default formatting data from track item. """
symlink = self.ui_inputs['hierarchyData']['value'].get('symlink')

self.track_item_default_data = {
"_folder_": "shots",
Expand All @@ -765,7 +767,7 @@ def _populate_track_item_default_data(self):
"_clip_": self.ti_name,
"_trackIndex_": self.track_index,
"_clipIndex_": self.ti_index,
"_symlink_": symlink["value"]
"_symlink_": self.symlink
}

def _populate_attributes(self):
Expand All @@ -789,7 +791,11 @@ def _populate_attributes(self):
self.hierarchy_data = self.ui_inputs.get(
"hierarchyData", {}).get("value") or \
self.track_item_default_data.copy()
self.hierarchy_data["symlink"].update({"value": "{_symlink_}"})

ui_symlink = self.ui_inputs.get(
"hierarchyData", {}).get("value").get("symlink").get("value")
self.hierarchy_data["symlink"].update({"value": str(ui_symlink)})

self.count_from = self.ui_inputs.get(
"countFrom", {}).get("value") or self.count_from_default
self.count_steps = self.ui_inputs.get(
Expand Down
2 changes: 1 addition & 1 deletion openpype/hosts/hiero/plugins/create/create_shot_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class CreateShotClip(phiero.Creator):
"type": "QCheckBox",
"label": "Publish using symlink",
"target": "tag",
"toolTip": "Publish symlinks and not copied files",
"toolTip": "Publish symlinks, don't copy files",
"order": 5}
}
},
Expand Down
38 changes: 25 additions & 13 deletions openpype/plugins/publish/integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,6 @@ def register(self, instance, file_transactions, filtered_repres):
)
}

is_symlink_mode = False
hierarchy_data = instance.data.get("hierarchyData")
if hierarchy_data:
is_symlink_mode = hierarchy_data.get("symlink")

# Prepare all representations
prepared_representations = []
for repre in filtered_repres:
Expand All @@ -320,14 +315,8 @@ def register(self, instance, file_transactions, filtered_repres):

for src, dst in prepared["transfers"]:
# todo: add support for hardlink transfers
if is_symlink_mode:
file_transactions.add(
src,
dst,
mode=FileTransaction.MODE_SYMLINK
)
else:
file_transactions.add(src, dst)
file_transaction_mode = self.get_file_transaction_mode(instance, src)
file_transactions.add(src, dst, mode=file_transaction_mode)

prepared_representations.append(prepared)

Expand Down Expand Up @@ -439,6 +428,29 @@ def register(self, instance, file_transactions, filtered_repres):
self.log.info("Registered {} representations"
"".format(len(prepared_representations)))

@staticmethod
def get_file_transaction_mode(instance, src):
import re
is_symlink_mode_enable = False
hierarchy_data = instance.data.get("hierarchyData")
if hierarchy_data:
is_symlink_mode_enable = (hierarchy_data.get("symlink") == "True")

if not is_symlink_mode_enable:
return FileTransaction.MODE_COPY

pattern = instance.context.data["project_settings"]["global"]["tools"]["publish"]["symlink"][
"file_regex_pattern"]
if not pattern:
is_valid_symlink_path = True
else:
is_valid_symlink_path = bool(re.match(pattern, src))

if is_symlink_mode_enable and is_valid_symlink_path:
return FileTransaction.MODE_SYMLINK

return FileTransaction.MODE_COPY

def prepare_subset(self, instance, op_session, project_name):
asset_doc = instance.data["assetEntity"]
subset_name = instance.data["subset"]
Expand Down
5 changes: 4 additions & 1 deletion openpype/settings/defaults/project_settings/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,10 @@
"template_name": "simpleUnrealTextureHero"
}
],
"custom_staging_dir_profiles": []
"custom_staging_dir_profiles": [],
"symlink": {
"file_regex_pattern": "^[^\\/\\\\]*[\\/\\\\]prod[\\/\\\\].*$"
}
}
},
"project_folder_structure": "{\"__project_root__\": {\"prod\": {}, \"resources\": {\"footage\": {\"plates\": {}, \"offline\": {}}, \"audio\": {}, \"art_dept\": {}}, \"editorial\": {}, \"assets\": {\"characters\": {}, \"locations\": {}}, \"shots\": {}}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,20 @@
}
]
}
},
{
"type": "dict",
"collapsible": true,
"key": "symlink",
"label": "Symlink",
"is_group": true,
"children": [
{
"type": "text",
"key": "file_regex_pattern",
"label": "File Regex Pattern"
}
]
}
]
}
Expand Down

0 comments on commit 2b073b4

Please sign in to comment.