IWorkfileHost implementation (sync batch versioning to AYON workfiles) - #144
IWorkfileHost implementation (sync batch versioning to AYON workfiles)#144miravassor wants to merge 15 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Implements AYON workfiles support for Flame Batch Groups by adding an IWorkfileHost implementation and syncing Flame’s native iteration number to AYON workfile versions, with optional “open last workfile on launch” and a Workfiles menu entry.
Changes:
- Add
IWorkfileHostsupport in the Flame host (save/open/current workfile) using consolidated JSON batches (.json). - Sync AYON workfile versioning to Flame batch iterations on save/iterate/publish-iterate events.
- Add UX entry points (Batch menu “Workfiles…”, optional open-last/show-workfiles-on-start behavior) and remove legacy
workiostubs /.otocextension.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| client/ayon_flame/startup/AYON_in_flame.py | Adds launch-time actions (open-last/show-workfiles) and hooks to trigger workfile sync on save/iterate/batch-save. |
| client/ayon_flame/plugins/publish/integrate_batch_iteration.py | Sync workfile after creating a new iteration post-publish. |
| client/ayon_flame/api/workio.py | Removes legacy Workfiles tool host API stub (previous .otoc-based placeholder). |
| client/ayon_flame/api/pipeline.py | Implements IWorkfileHost and adds sync_workfile_to_current_iteration() helper with re-entrancy guard. |
| client/ayon_flame/api/menu.py | Adds “Workfiles…” entry to the Batch menu. |
| client/ayon_flame/api/batch_utils.py | Adds batch name normalization, workfile-path stamping via a hidden Note node, and safer .batch temp filename generation. |
| client/ayon_flame/api/init.py | Updates public API exports (adds sync + batch utils helpers, removes workio exports). |
| client/ayon_flame/addon.py | Updates declared workfile extension from .otoc to .json. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try: | ||
| _show_workfiles_tool() | ||
| except Exception as error: | ||
| print(f"!!!! AYON: could not show workfiles tool: {error} !!!!") |
| # brand-new batch that has never been iterated reports 0. | ||
| # this let core assign the first version (v1) | ||
| version = iteration if iteration >= 1 else None |
|
@miravassor I'm gonna mark this PR as draft for know if that's OK with you ? Just to flag to everyone that this is still under discussion and current code is to be used as reference for now. |
|
@rdelillo of course, it's a big subject, let's discuss! I proposed this solution because it felt like a solid middle ground between how Ayon and Flame operate. However, I remain completely open to other ideas! |
|
Hi @miravassor thank you for the suggested changes. I will be reacting for the discussion at the Issue #143 |
What it does
Makes Flame batch groups behave as AYON workfiles: implements IWorkfileHost (save/open/get-current, .json extension), open-last-on-launch, a Workfiles menu entry, and syncs Flame's native iteration with AYON workfile versions so every save/iterate gesture writes the matching version.
What was already here
A lot of this branch follows existing publish behavior:
ExtractBatchWorkfile already serialized the batch (via save_batch_as_consolidated_json) in json format. IWorkfileHost reuses it, so publish and workfiles speak the same format. (This is also why the extension moved .otoc → .json.). The .otoc file wasn't used to my knowledge.
Version = flame.batch.current_iteration_number. Publish already set the version to the iteration number (collect_batch_version) and already called batch.iterate() after publishing (integrate_batch_iteration). So I leaned into the number Flame + publish were already using: iterate → new version, save → refresh current.
Decisions made (to discuss)
Reopen reuses the live batch (even if "Open last workfile on launch" is activated) → else last JSON → else fresh. I went this way after confirming quit doesn't fire project_saved, so reloading JSON on open would load stale work. Debatable.
workfile_has_unsaved_changes left as None, found no Flame "dirty" API.
Limitations / by-design
Context resolves to the launched task (multi-batch of a different task writes to the launched task's area).
Compatibility
Confirmed on Flame 2026. Most API calls were already used, new ones are PyBatch.open() + the two batch_setup_* hooks.
Thank you!