Skip to content

SG-43421 Add Flow AM desktop publish hooks (Phase 1)#220

Closed
chenm1adsk wants to merge 7 commits into
masterfrom
ticket/SG-43421-flowam-publish-hooks-phase1
Closed

SG-43421 Add Flow AM desktop publish hooks (Phase 1)#220
chenm1adsk wants to merge 7 commits into
masterfrom
ticket/SG-43421-flowam-publish-hooks-phase1

Conversation

@chenm1adsk

@chenm1adsk chenm1adsk commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Moves Flow AM desktop publish hooks from tk-config-flowam POC into upstream tk-desktop (Phase 1).

Added hooks/tk-multi-publish2/flowam/:

  • collector.py - Desktop-specific collector; blocks DCC file extensions and reads TK_FLOWAM_REVISION_ID_* env var set by Loader
  • publish_to_flow.py - Self-contained desktop publish plugin (DesktopFlowPublishPlugin)
  • icons/flow.png - Plugin icon resolved via self.disk_location

Design:

The original POC used a 3-class hierarchy in the hook chain: publish_file.pyFlowPublishPlugin (shared base in tk-multi-publish2) → DesktopFlowPublishPlugin (desktop leaf in tk-desktop). This PR rewrites DesktopFlowPublishPlugin to subclass publish_file.py directly, eliminating the dependency on the shared base class from tk-multi-publish2.

The DCC counterpart lives in tk-multi-publish2 as DccFlowPublishPlugin, also self-contained. tk-desktop and tk-multi-publish2 can evolve independently across separate release cycles.

The hooks are only active with a custom config (tk-config-flowam), which acts as a feature flag for the Flow AM workflow. Users on any other configuration are unaffected.

Config requirements

env/includes/desktop/project.yml:

tk-multi-publish2:
  collector: "{self}/collector.py:{engine}/tk-multi-publish2/flowam/collector.py"
  publish_plugins:
  - name: Publish to Flow AM
    hook: "{self}/publish_file.py:{engine}/tk-multi-publish2/flowam/publish_to_flow.py"
    settings: {}

Test plan

  • Desktop with Flow AM config - publish new asset completes, Flow AM revision created
  • Desktop with Flow AM config - publish existing asset (new revision) completes
  • Desktop with non-Flow-AM config - publishes normally with no regression

Move Flow AM publish hooks from tk-config-flowam POC into upstream tk-desktop as a lift-and-shift with no logic changes.

Added hooks/flowam/:
- collector_desktop.py: Desktop-specific collector extending base collector
- publish_to_flow_desktop.py: Desktop-specific publish to Flow AM hook
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 24.71%. Comparing base (1981272) to head (30ddbf0).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #220      +/-   ##
==========================================
- Coverage   24.81%   24.71%   -0.11%     
==========================================
  Files          68       68              
  Lines        3970     3970              
==========================================
- Hits          985      981       -4     
- Misses       2985     2989       +4     
Flag Coverage Δ
Linux 23.85% <ø> (ø)
Python-3.10 24.63% <ø> (ø)
Python-3.11 24.63% <ø> (-0.11%) ⬇️
Python-3.13 24.65% <ø> (ø)
Python-3.9 24.64% <ø> (ø)
Windows 24.08% <ø> (-0.11%) ⬇️
macOS 24.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chenm1adsk chenm1adsk marked this pull request as ready for review May 27, 2026 17:48
@chenm1adsk chenm1adsk requested a review from a team May 27, 2026 18:19
Comment thread hooks/tk-multi-publish2/flowam/collector.py
Comment thread hooks/tk-multi-publish2/flowam/publish_to_flow.py
carlos-villavicencio-adsk

This comment was marked as outdated.

Restructure the Flow AM publisher hooks to live under
hooks/tk-multi-publish2/flowam/ instead of hooks/flowam/. This matches
the layout used by other Toolkit engines (tk-nuke, tk-maya), which
group their app-specific hooks by consumer app first, then by variant.

Also add class-level docstrings to both hooks documenting their
dependency on the tk-multi-publish2 base hooks and the expected hook
chain string in the config.

Changes:
- hooks/flowam/collector.py -> hooks/tk-multi-publish2/flowam/collector.py
- hooks/flowam/publish_to_flow.py -> hooks/tk-multi-publish2/flowam/publish_to_flow.py

@carlos-villavicencio-adsk carlos-villavicencio-adsk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me. It's only about code move, so I didn't spend much time reviewing the code.

@julien-lang julien-lang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add typing info for the new methods

Comment thread hooks/tk-multi-publish2/flowam/publish_to_flow.py Outdated
Comment thread hooks/tk-multi-publish2/flowam/collector.py
Rewrite DesktopFlowPublishPlugin to subclass publish_file.py directly,
eliminating the dependency on FlowPublishPlugin from tk-multi-publish2.

Previously the hook chain included a shared base from tk-multi-publish2:
  {self}/publish_file.py:{self}/flowam/publish_to_flow.py:{engine}/tk-multi-publish2/flowam/publish_to_flow.py

Now the desktop plugin is fully self-contained:
  {self}/publish_file.py:{engine}/tk-multi-publish2/flowam/publish_to_flow.py

All shared logic (properties, accept, validate, publish, finalize,
get_publish_user) is inlined. _get_flow_args is inlined into _publish_to_flow.
Also add icons/flow.png so self.disk_location resolves the icon correctly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we have to add this icon here while we already added it in the parent hook in shotgunsoftware/tk-multi-publish2#217 ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this tk-desktop hook is directly inherit from tk-multi-publish2 hook, then it should use the parent's icon insted. Good call.

Publishes the file to Flow Production Tracking and Asset Manager. A <b>Publish</b> entry
will be created in Flow Production Tracking which will include a reference
to the file's current path on disk. Other users will be able to access the
published file via the <b><a href='%s'>Loader</a></b> so long as they have

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where is %s filled?

HTML attribute should always use double quotes.

specific revision validation - no super() call needed.
"""
# FlowAM framework import
# TODO: We have an issue on FPTR desktop where the `adsk` cannot be found

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What this about?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This was an old warning that should now be fixed with the latest changes we're doing at core level.

Comment on lines +142 to +145
project_valid, project_err = am.validate_project(self.sg_flow_am_id)
if not project_valid:
self.logger.error(
f"No Flow project associated with current SG project: {project_err}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I thought we were going to pass that via the Toolkit context?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This check can likely be removed. It really just validates whether the flow project attached to the current sg project matches the one that was set for the "flow session". It's a bit redundant.

Comment on lines +355 to +358
pub_info = self.flow_module.asset_management.create_generic_workfile(
create_inputs,
)
return pub_info

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Useless variable. Just return the instance.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would say it is nice to have the variable only to give the code reader a better idea of what that return value is. But of course, functionality wise it doesn't need to be there.

@chenm1adsk

Copy link
Copy Markdown
Contributor Author

Closing this PR due to the hooks will be place in tk-multi-publish2 instead.

@chenm1adsk chenm1adsk closed this Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants