Conversation
|
@iLLiCiTiT can you give me your thoughts on this? |
There was a problem hiding this comment.
Pull request overview
Refactors the publish integrator to operate as a pyblish.api.ContextPlugin with more upfront data prefetching (products/versions/representations) and introduces stronger typing via dataclasses and type hints to support faster large ingests.
Changes:
- Converted
IntegrateAssetfromInstancePlugintoContextPluginand integrated all eligible instances in one pass. - Added
_PreparedInstance/_PreparedRepresentationdataclasses and expanded type hints across the integrator code. - Added operation chunking (
operations_chunk_size) and prefetch logic viaget_products/get_versions/get_representations.
Suppressed comments (2)
client/ayon_core/plugins/publish/integrate.py:915
- Using
asserthere is unsafe because asserts can be stripped with-O, and thenrepre_context["frame"] = ...could crash ifrepre_contextis unexpectedlyNone. Prefer an explicit guard (and keep the finalif repre_context is None: raiseas the authoritative error).
if not is_udim:
assert repre_context is not None
repre_context["frame"] = first_index_padded
client/ayon_core/plugins/publish/integrate.py:920
- This
assertcan be stripped with-O, so the next line could crash ifrepre_contextisNone. Use a guard instead of an assert for safety.
if instance.data.get("renderlayer"):
assert repre_context is not None
repre_context["renderlayer"] = instance.data["renderlayer"]
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…erations for a single instance.
…com/ynput/ayon-core into enhancement/integrate_ContextPlugin
|
May be good to do some performance testing with this. Maybe @antirotor loves to do that, or @jakubjezek001 comparing it with latest |
|
I agree that we need to do some performance testing and my concern is whether prefetching data in this PR rapidly increasing memory usage.
|
| import logging | ||
| import sys | ||
| import copy | ||
| from dataclasses import dataclass |
There was a problem hiding this comment.
They can, if you don't have from __future__ import annotations in the file. ;)
As such, do we still care?
Also, given how painful this is it makes me wonder if we should have a dataclass decorator wrapper that avoids the bug, just so we can use dataclasses. Because this stuff gets painful easily otherwise.
There was a problem hiding this comment.
I have it in my TODO list to fix the issue.
There was a problem hiding this comment.
It's fixed in pyblish pyblish/pyblish-base#403 btw ;) there's just no new pyblish release since.
There was a problem hiding this comment.
BTW I think from __future__ import annotations is issue with core's import logic, but with pyblish import logic it fails completelly event without the import.
There was a problem hiding this comment.
Pretty sure the pyblish one also ONLY happened if that from future import was there. @antirotor worked on that fix at the time.
There was a problem hiding this comment.
Pretty sure the pyblish one also ONLY happened if that from future import was there. @antirotor worked on that fix at the time.
Oh, yeah, but that is not released, and 100% is not in any dependency package we have. So in practice we can't rely on it.
| template_data["udim"] = index | ||
| else: | ||
| template_data["frame"] = index | ||
| template_filled = path_template_obj.format_strict( |
There was a problem hiding this comment.
NOTE: In ideal case scenario we should collect file info now. The template_filled object has rootless path with root that was 100% used instead of guessing it later on.
| "anatomy_data": template_data, | ||
| "transfers": transfers, | ||
| return _PreparedRepresentation( | ||
| representation=repre_doc, |
There was a problem hiding this comment.
Why the hell is the variable still named repre_doc? 😆
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Changelog Description
Integrator: Refactor to
ContextPluginand add type hintsAdditional info
Turning this into an integrator allows us to optimize some queries, like the prefetching of products, version data, etc. and also join the file transactions into one threaded bulk and the OperationsSession into fewer bulks. This should make big ingests with many instances faster. But timings will still need to be made.
Draft for now, because it needs more performance tests but also general discussion
Testing notes: