Skip to content

SG-43935 data model derivative update (base branch)#224

Open
yungsiow wants to merge 24 commits into
masterfrom
ticket/sg-43935/data-model-derivative-update
Open

SG-43935 data model derivative update (base branch)#224
yungsiow wants to merge 24 commits into
masterfrom
ticket/sg-43935/data-model-derivative-update

Conversation

@yungsiow

Copy link
Copy Markdown
Contributor

NOTE: this branch will be treated as the base branch for publisher changes involving the Data Model project

  • fix for allowing alembic publishes only for non-templates (Ming)
  • when in "Flow mode" only do Flow publish (Ming)
  • remove restriction for only publishing one DCC workfile of same type under same parent
  • remove need to pass in SG task name to create functions
  • on first publish of a dcc workfile or derivative, update parent asset to add a variant set component
  • modify derivative publish to adjust to new DerivativeSource component
  • move validate_generic_asset() utility to publish.py module and removed validate.py module which only had one function in it

chenm1adsk and others added 22 commits June 23, 2026 13:51
Move Flow AM publish hooks from tk-config-flowam POC into upstream
tk-multi-publish2 as a lift-and-shift with no logic changes.

Added hooks/flowam/:
- collector_dcc.py: DCC-specific collector extending base collector
- pre_publish.py: pre-publish validation for Flow AM draft state
- publish_alembic_derivative.py: publish alembic derivative workflow
- publish_to_flow.py: base publish to Flow AM hook
- publish_to_flow_dcc.py: DCC-specific publish to Flow AM hook
- icons/alembic.png, icons/flow.png: icons referenced by publish hooks
- Remove collector_dcc.py - only called super() with no additional logic; Toolkit hook chain handles passthrough automatically
- Remove alembic.png icon - licensing concern; icon() now returns the alembic icon under hooks/icons/alembic.png
- Remove unused `settings` param from _publish_to_flow() across in publish_to_flow.py and its children
- Add return type annotations to new (non-overridden) methods:
_get_flow_module() -> ModuleType, _get_draft_id() -> str | None
- Update class docstrings to accurately describe responsibilities and expected hook chain configuration for each hook
- Add finalize() docstring explaining why the no-op override is needed
…tained hook

The shared base class FlowPublishPlugin (publish_to_flow.py) and its DCC
leaf (publish_to_flow_dcc.py) are merged into a single self-contained
DccFlowPublishPlugin in publish_to_flow.py.

This removes the 3-class hierarchy (publish_file -> FlowPublishPlugin ->
FlowDccPublishPlugin) in favour of two independent plugins - one per context
(DCC and desktop) - each subclassing publish_file.py directly. The desktop
counterpart lives in tk-desktop. Independent release cycles between the two
repos no longer require a shared base class in tk-multi-publish2.

Changes:
- publish_to_flow.py: rewritten as DccFlowPublishPlugin with all validation
  (project + draft + conflict check) merged into a single validate(), and
  _get_flow_args inlined into _publish_to_flow
- publish_to_flow_dcc.py: deleted (merged into publish_to_flow.py)
…top subclasses

Restore the base + subclass layout from the original tk-config-flowam POC, now living entirely under tk-multi-publish2 (no Flow AM publish hooks in tk-desktop anymore).

- publish_to_flow.py: FlowPublishPlugin base class with shared properties, project-level validation, publish/finalize/get_publish_user, and _get_flow_args helper.
- publish_to_flow_dcc.py: DccFlowPublishPlugin adds draft validation and  conflict check; publishes via publish_dcc_draft.
- publish_to_flow_desktop.py: DesktopFlowPublishPlugin rejects Maya files, adds revision validation, and publishes via publish_generic_revision or create_generic_workfile.
- collector_desktop.py: desktop-only collector moved from tk-desktop.
- Embed Flow AM publish logic directly into the stock collector, pre_publish, and publish_file hooks, gated on ctx.flow_project_id
- Add python/tk_multi_publish2/flowam/ package with publish, validate, inputs, constants, and exceptions modules
- Expose flowam package via app.py as self.parent.flowam
- collector.py: capture TK_FLOWAM_REVISION_ID_* env var for Desktop revision publishes; block DCC extensions via FLOWAM_DCC_EXTENSIONS
- pre_publish.py: add Flow AM project validation branch
- publish_file.py: add Flow AM validate/publish/finalize branches for both DCC (draft-based) and Desktop (generic asset) publish paths
- publish_alembic_derivative.py: drop load_framework calls, use SDK imports and self.parent.flowam directly
- Eliminate tk-framework-flowam dependency
feat: [SG-43419] Flow AM publish hooks migration (Phase 2) + single file mode
 
 - Add single_file_mode param to show_dialog() and AppDialog to restrict publisher to one file when republishing a Flow AM generic asset from Loader
- add .flake8 config copied from tk-core
- handle flow generic publish from nuke FlowWrite node
- add vim file types to .gitignore
- remove check for asset conflict
- remove sg_task_name from CreateGenericInputs
- removed several functions from validate.py and moved the one remaining function validate_generic_asset() into publish.py
- after first dcc publish, add variant set component to parent pointing to dcc asset
- better error handling in derivative publish process
- store version id instead of revision id on derivative source component
- after first derviative publish, add variant set component to parent pointing to derivative asset
When Flow AM is active, validate/publish/finalize were falling through
into FPT logic after the Flow AM branch, causing both a Flow AM revision
and an FPT PublishedFile to be created on every publish. On partial
failure this left orphaned records in one system.

- validate: return _flow_validate() result directly, skipping FPT
  conflict-publish check entirely
- publish: return after _flow_publish(), skipping sgtk.util.register_publish
- finalize: early return when Flow AM active, since sg_publish_data does
  not exist on Flow AM publishes
The accept() method was rejecting the plugin whenever storage_key_to_asset_id
raised FlowError (asset not found in MEDM), which happens on first-time
publishes before the asset exists. This caused the alembic derivative plugin
to be invisible until at least one publish had already been completed.

Fix by reading the local draft info instead of querying MEDM to determine
whether the asset is a template:
- NewDraftInfo (unpublished asset): check type_ids from local draft file
- CheckoutDraftInfo (published asset): query FlowAsset.type_ids from MEDM

This correctly distinguishes between "not a template" and "not yet published",
so the plugin is visible from the very first publish attempt.
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.12%. Comparing base (0c85314) to head (ec4ed1e).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #224      +/-   ##
==========================================
+ Coverage   41.21%   48.12%   +6.90%     
==========================================
  Files          62       58       -4     
  Lines        5054     3836    -1218     
==========================================
- Hits         2083     1846     -237     
+ Misses       2971     1990     -981     
Flag Coverage Δ
Linux 48.12% <ø> (+6.90%) ⬆️
Python-3.10 48.12% <ø> (+6.90%) ⬆️
Python-3.11 48.12% <ø> (+6.90%) ⬆️
Python-3.13 48.12% <ø> (+6.90%) ⬆️
Python-3.9 48.12% <ø> (+6.90%) ⬆️
Windows 48.12% <ø> (+6.90%) ⬆️
macOS 48.12% <ø> (+6.90%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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 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.

Left a question and some small issues.

Comment thread python/tk_multi_publish2/flowam/publish.py Outdated
Comment thread python/tk_multi_publish2/flowam/publish.py Outdated
Comment thread python/tk_multi_publish2/flowam/publish.py Outdated
Comment thread python/tk_multi_publish2/flowam/publish.py
Comment thread python/tk_multi_publish2/flowam/inputs.py Outdated

@chenm1adsk chenm1adsk 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.

LGTM!

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.

2 participants