Skip to content

IWorkfileHost implementation (sync batch versioning to AYON workfiles) - #144

Open
miravassor wants to merge 15 commits into
ynput:developfrom
miravassor:enhancement/IWorkfileHost
Open

IWorkfileHost implementation (sync batch versioning to AYON workfiles)#144
miravassor wants to merge 15 commits into
ynput:developfrom
miravassor:enhancement/IWorkfileHost

Conversation

@miravassor

Copy link
Copy Markdown

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).

  • Iterate "Replace" makes the version follow the reused slot, re-iterating jumps to Flame's max+1, mimicking Flame behavior but confusing ?

Compatibility

Confirmed on Flame 2026. Most API calls were already used, new ones are PyBatch.open() + the two batch_setup_* hooks.

Thank you!

Copilot AI review requested due to automatic review settings July 22, 2026 17:02

Copilot AI 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.

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 IWorkfileHost support 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 workio stubs / .otoc extension.

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.

Comment on lines +155 to +158
try:
_show_workfiles_tool()
except Exception as error:
print(f"!!!! AYON: could not show workfiles tool: {error} !!!!")
Comment thread client/ayon_flame/api/pipeline.py Outdated
Comment on lines +191 to +193
# 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
@rdelillo rdelillo self-assigned this Jul 28, 2026
@rdelillo rdelillo added type: enhancement Improvement of existing functionality or minor addition community Issues and PRs coming from the community members labels Jul 28, 2026
@rdelillo rdelillo linked an issue Jul 28, 2026 that may be closed by this pull request
@rdelillo

Copy link
Copy Markdown
Contributor

@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.
I'd love we iterate a bit more over the need and implementation plan first on the issue so we have a proper battle plan.

@miravassor

Copy link
Copy Markdown
Author

@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!

@jakubjezek001

Copy link
Copy Markdown
Member

Hi @miravassor thank you for the suggested changes. I will be reacting for the discussion at the Issue #143

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Issues and PRs coming from the community members type: enhancement Improvement of existing functionality or minor addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workfile support (IWorkfileHost)

4 participants