Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USD Contribution Workflow: Enable asset contributions to write AYON Entity URIs #754

Merged
merged 9 commits into from
Aug 29, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,14 @@ def get_instance_uri_path(
folder_path = instance.data["folderPath"]
product_name = instance.data["productName"]
project_name = context.data["projectName"]
version_name = instance.data["version"]

# Get the layer's published path
path = construct_ayon_entity_uri(
project_name=project_name,
folder_path=folder_path,
product=product_name,
version="latest",
version=version_name,
representation_name="usd"
)

Expand Down Expand Up @@ -561,6 +562,8 @@ class ExtractUSDLayerContribution(publish.Extractor):
label = "Extract USD Layer Contributions (Asset/Shot)"
order = pyblish.api.ExtractorOrder + 0.45

use_ayon_entity_uri = True

def process(self, instance):

folder_path = instance.data["folderPath"]
Expand All @@ -578,7 +581,8 @@ def process(self, instance):

contributions = instance.data.get("usd_contributions", [])
for contribution in sorted(contributions, key=attrgetter("order")):
path = get_instance_uri_path(contribution.instance)
path = get_instance_uri_path(contribution.instance,
resolve=not self.use_ayon_entity_uri)
if isinstance(contribution, VariantContribution):
# Add contribution as a reference inside a variant
self.log.debug(f"Adding variant: {contribution}")
Expand Down Expand Up @@ -720,6 +724,8 @@ class ExtractUSDAssetContribution(publish.Extractor):
label = "Extract USD Asset/Shot Contributions"
order = ExtractUSDLayerContribution.order + 0.01

use_ayon_entity_uri = True

def process(self, instance):

folder_path = instance.data["folderPath"]
Expand Down Expand Up @@ -795,15 +801,15 @@ def sort_by_order(instance):
layer_id = layer_instance.data["usd_layer_id"]
order = layer_instance.data["usd_layer_order"]

path = get_instance_uri_path(instance=layer_instance)
path = get_instance_uri_path(instance=layer_instance,
resolve=not self.use_ayon_entity_uri)
add_ordered_sublayer(target_layer,
contribution_path=path,
layer_id=layer_id,
order=order,
# Add the sdf argument metadata which allows
# us to later detect whether another path
# has the same layer id, so we can replace it
# it.
# has the same layer id, so we can replace it.
add_sdf_arguments_metadata=True)

# Save the file
Expand Down
25 changes: 25 additions & 0 deletions server/settings/publish_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ def validate_unique_outputs(cls, value):
return value


class AyonEntityURIModel(BaseSettingsModel):
use_ayon_entity_uri: bool = SettingsField(
title="Use AYON Entity URI",
description=(
"When enabled the USD paths written using the contribution "
"workflow will use ayon entity URIs instead of resolved published "
"paths. You can only load these if you use the AYON USD Resolver."
)
)


class PluginStateByHostModelProfile(BaseSettingsModel):
_layout = "expanded"
# Filtering
Expand Down Expand Up @@ -857,6 +868,14 @@ class PublishPuginsModel(BaseSettingsModel):
default_factory=ExtractBurninModel,
title="Extract Burnin"
)
ExtractUSDAssetContribution: AyonEntityURIModel = SettingsField(
default_factory=AyonEntityURIModel,
title="Extract USD Asset Contribution",
)
ExtractUSDLayerContribution: AyonEntityURIModel = SettingsField(
default_factory=AyonEntityURIModel,
title="Extract USD Layer Contribution",
)
PreIntegrateThumbnails: PreIntegrateThumbnailsModel = SettingsField(
default_factory=PreIntegrateThumbnailsModel,
title="Override Integrate Thumbnail Representations"
Expand Down Expand Up @@ -1162,6 +1181,12 @@ class PublishPuginsModel(BaseSettingsModel):
}
]
},
"ExtractUSDAssetContribution": {
"use_ayon_entity_uri": False,
},
"ExtractUSDLayerContribution": {
"use_ayon_entity_uri": False,
},
"PreIntegrateThumbnails": {
"enabled": True,
"integrate_profiles": []
Expand Down