-
Notifications
You must be signed in to change notification settings - Fork 67
Implement ValidateFolderCreationResolution. #1293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Implement ValidateFolderCreationResolution. #1293
Conversation
|
Task linked: AY-7197 Override resolution on editorial publish |
| else: | ||
| for resolution_attrib in _RESOLUTION_ATTRIBS: | ||
| shot_data.pop(resolution_attrib, None) | ||
|
|
||
| self.log.info( | ||
| "Ignore existing shot resolution validation " | ||
| "(update is disabled)." | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A validator should usually not change the data - it's really about validating, not by adjusting how the rest of publishing behaves. @iLLiCiTiT any pointers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To explain a bit more here. extract_hierarchy_to_ayon is blindly updating any folder attributes from the data provided by the instance. See https://github.com/ynput/ayon-core/blob/develop/client/ayon_core/plugins/publish/extract_hierarchy_to_ayon.py#L128
Most of our editorial publishers creating shots are forcing resolution attributes in different ways (from DCC timeline depending or the source, from the collect_explicit_resolution.py, or from CSV/EDL entry...).
So far, the most elegant way I found to prevent a resolution update was to simply get rid of the values here and keep the logic self-scoped. Do you guys think of anything better ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data change should technically need to occur during collecting stage as far as I know, but it can definitely appear to complicate code for these use cases. Will leave it to @antirotor @iLLiCiTiT @philippe-ynput to state how we should approach this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe some concret examples to help understand how various settings/attributes/input might interfer the shot resolution present in hierarchyContext data as I'd need some guidance if we want to streamline that.
-
Hiero publisher:
- shot resolution computed in
ayon-hiero/collect_shotsplugin- either from timeline if
sourceResolutioncreator attribute is disabled - or read from plate source if
sourceResolutioncreator attribute is enabled
- either from timeline if
- shot resolution then potentially overriden by
ayon_core/collect_explicit_resolutionif configured via settings - shot resolution is set in
hierarchyContextviaayon-core/collect_hierarchyplugin
- shot resolution computed in
-
CSV ingest (Traypublisher)
- shot resolution is read from input CSV file if exists
- shot resolution then potentially overriden by
ayon_core/collect_explicit_resolutionif configured via settings - shot resolution is reported to
hierarchyContextviaayon-traypublisher/collect_shot_instances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry but I'm lost in this PR. Is the goal to not update attributes on folders based on checkbox, and have option to validate the attribute values (based on the same checkbox)?
If that's the case then the checkbox value should change behavior of the extractor to not override the attributes, and the same value should be used in validator. The validator should not change anything, should only compare and raise error if it's wrong (repair actions can change).
Or there can be additional collector that would "set" the attributes to values set on existing entities, so rest of publishing is using values that are really. I can't tell which is better because I don't know at which places it is used.
To explain a bit more here. extract_hierarchy_to_ayon is blindly updating any folder attributes from the data provided by the instance.
I don't think it's blindly updating it, it is updating them based on what was collected from scene, or? The host said, that the resolution is A, so I should set it to A.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No you're right, with @moonyuet and your feedback, I think I overworked a bit the feature here.
I've change this to make it a simpler validator:
- Validate resolution from
hierarchyContext(disabled by default): if a folder already exists under a different resolution this validation fails. - This can be skipped via UI (and a repair action).
- If the validation fails, this becomes the user responsability to accomodate the instance (via different ways) to keep a consistent resolution.
Sounds safer to me, what do you guys think ?
Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>
Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>
Thanks @moonyuet for the feedback ! |
I see. I think the label should be more descriptive and otherwise it looks good. |
| actions = [RepairIgnoreResolution, RepairOverrideResolution] | ||
|
|
||
| @classmethod | ||
| def get_shot_data(self, hierarchy_context): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about what this actually does? It returns first folder with "Shot" folder type that can be found in project?
What is that good for? Why we're using EntityHub for it? How do we know the folder type is actually "Shot"? Shouldn't we find existing entity by the path we're looking for, or by something that has merit? How does fixing one entity help with the others? Or we're just finding first shot to set the same values for all other shots?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reworked this function. It is now _validate_hierarchy_resolution which validate the resolution attributes of hierarchyContext against existing folders (hence the EntityHub usage).
Does this work OK for you ?
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
antirotor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the code changes I think this looks good. Can't test it right now, though.
moonyuet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| """ Deep validation of hierarchy_context resolution. | ||
| """ | ||
| project_name = tuple(hierarchy_context.keys())[0] | ||
| entity_hub = EntityHub(project_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion to avoid using EntityHub here. It would be faster to prepare all folder paths you need, fetch all folder entities at once using those paths and then compare them.
entity_items_by_path = {}
folder_paths = []
current_item = next(iter(hierarchy_context.values()))
queue = collections.deque()
queue.append((current_item, ""))
while queue:
current_item, current_path = queue.popleft()
children = current_item.get("children") or {}
for name, child in children.items():
path = f"{current_path}/{name}"
folder_paths.append(path)
queue.append((child, path))
# Skip validation of items without attributes
if child.get("attributes"):
entity_items_by_path[path] = child
# Fetch folder entities that should be validated
folder_entities_by_path = {
folder_entity["path"]: folder_entity
for folder_entity in ayon_api.get_folders(
project_name,
folder_paths=folder_paths,
fields={"path", "attrib"}
)
}
# Run the validation
for path, item in entity_items_by_path.items():
folder_entity = folder_entities_by_path.get(path)
if folder_entity:
self._validate_folder_resolution(
item["attributes"],
folder_entity,
)(Would require change in _validate_folder_resolution to work with flder entity as dictionary.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think this should be addressed. Using EntityHub can slow down the publishing a lot. EntityHub is fetching the entities one by one if are not pre-fetched... You know ahead which entities you're interested in, so using get_folders with prepared paths will make it signifincatly faster for bigger hierarchies.
If you'd compare e.g. 1 seqeunce vs. 10 sequences it can be 10x slower.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rdelillo are you planning to address the changes and remove the EntityHub?
| create_context.save_changes() | ||
|
|
||
|
|
||
| class ValidateFolderCreationResolution( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this plugin should be Context plugin to run only once, or?
Currently it is instance plugin, with attribute on each instance, but validates all instances (and is running on all instances).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the main reason this is on instance is that user can control this per instance @rdelillo ?





Changelog Description
resolve: #1289
Implement a new validator that check existing shot resolution instead of blindly update.

If a mismatch is detected, 2 repair actions are suggested:
Testing notes:
2a. Ensure disabling the validator let the shot product to go through with no resolution changes
2b. Ensure enabling the validator does nothing if the resolution match
2c. Ensure the validator raises if the resolution mismatches with 2 suggested repairs: