-
Notifications
You must be signed in to change notification settings - Fork 60
SG-44786 Reference previous pipeline step publish when building a new scene (Rig, Texture) #163
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
Changes from 7 commits
1eab1ad
019ae3c
ab070fa
2ee69ab
07f8797
9436cb7
bf20af5
95f5454
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,11 @@ | |
| open_draft, | ||
| ) | ||
| from .reference import copy_reference_link, reference_revision | ||
| from .step_validation import find_unpublished_upstream_step | ||
| from .step_validation import ( | ||
| find_unpublished_upstream_step, | ||
| find_workfile_asset, | ||
| get_upstream_step, | ||
| ) | ||
|
|
||
|
|
||
| class FlowAMActions: | ||
|
|
@@ -253,16 +257,82 @@ def _confirm_upstream_step_published(self, create_inputs: CreateInputs) -> bool: | |
|
|
||
| def _prep_scene(self, sg_publish_data: dict) -> None: | ||
| """ | ||
| Let clients run set-up scripts when building a new scene/asset. | ||
| Default scene-prep opinion for a freshly built scene: reference the | ||
| previous pipeline step's published Maya scene into it. | ||
|
|
||
| :param sg_publish_data: Shotgun data dictionary with all the standard publish fields. | ||
| Runs from ``create_dcc_workfile()``'s ``prep_scene_callback`` - after the | ||
| host has created/loaded the scene and before it is saved into the draft - | ||
| so the reference is baked into the built scene. It is a no-op unless the | ||
| host is Maya (only the Maya scene publish is referenced) and the upstream | ||
| step has a published workfile. When nothing is published - for instance | ||
| when the artist chose to build an empty scene from the publish warning - | ||
| there is simply nothing to reference. | ||
|
|
||
| A referencing failure is surfaced as a warning but never aborts the | ||
| build: the artist still gets their new scene, just without the reference. | ||
|
|
||
| TDs can override this method to change or replace this default behavior. | ||
|
|
||
| :param sg_publish_data: FPTR Task data the new scene is built from. | ||
| """ | ||
| host = getattr(sgtk.platform.current_engine(), "flow_host", None) | ||
| workfile_type = getattr(host, "WORKFILE_TYPE", "") | ||
| if workfile_type != MAYA_WORKFILE_TYPE: | ||
| return | ||
|
|
||
| entity = sg_publish_data.get("entity") or {} | ||
| task = ( | ||
| self._app.shotgun.find_one( | ||
| "Task", | ||
| filters=[["id", "is", sg_publish_data["id"]]], | ||
| fields=["step"], | ||
| ) | ||
| or {} | ||
| ) | ||
| pipeline_step = (task.get("step") or {}).get("name", "") | ||
| upstream_step = get_upstream_step( | ||
| pipeline_step, | ||
| self._app.get_setting("pipeline_step_dependencies", {}), | ||
| ) | ||
| if not upstream_step: | ||
| return | ||
|
|
||
| try: | ||
| workfile = find_workfile_asset( | ||
| am_project_id=self._get_flowam_id(), | ||
| sg_entity_type=entity.get("type", ""), | ||
| sg_entity_name=entity.get("name", ""), | ||
| pipeline_step=upstream_step, | ||
| workfile_type=workfile_type, | ||
| ) | ||
| except exceptions.FlowError as exc: | ||
| self._app.log_warning( | ||
| f"Could not resolve a published workfile for pipeline step " | ||
| f'"{upstream_step}". Building without a reference. ({exc})' | ||
| ) | ||
| return | ||
| if workfile is None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need the same warning here as above if the workfile is not found (but no error is raised)? I assume we still want to warn the users in this case that the previous pipeline step is missing a workfile and therefore we have nothing to reference.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding a debug log for internal purposes only. Pretty much the user was warned in the dialog while building the new scene. |
||
| return | ||
|
|
||
| try: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a comment here to explain the need for "require_asset_context=False". Example: |
||
| file_path = reference_revision( | ||
| workfile.revision_id, require_asset_context=False | ||
| ) | ||
| except exceptions.FlowError as exc: | ||
| message = ( | ||
| f"Could not reference the previous step's published scene for " | ||
| f'"{entity.get("name", "")}". The new scene was built without ' | ||
| f"it. ({exc})" | ||
| ) | ||
| self._app.log_error(message) | ||
| if host: | ||
| host.dialog("Reference failed", message, buttons=["OK"]) | ||
| return | ||
|
|
||
| self._app.log_info( | ||
| f"prep_scene() called with sg_publish_data: {sg_publish_data}" | ||
| f"Referenced the previous step's published scene into the new " | ||
| f'"{pipeline_step}" scene: {file_path}' | ||
| ) | ||
| # TDs can override this method to add custom scene prep logic | ||
| pass | ||
|
|
||
| def _discard_draft(self, sg_publish_data: dict) -> None: | ||
| """ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this specifically related to this PR or just a bonus change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of a bonus change but also related. I've improved the tooltip on hooks/tk-maya_actions.py to describe the asset management pipeline behavior. But that description wasn't being displayed anywhere. I fixed it so it can be visible on the tooltip when hovering the Build New Scene option in the context menu.