-
Notifications
You must be signed in to change notification settings - Fork 3
Openclip loader respecting version order #92
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?
Openclip loader respecting version order #92
Conversation
| if not context["representation"]["context"].get("output"): | ||
| self.clip_name_template = self.clip_name_template.replace( | ||
| "output", "representation" | ||
| ) | ||
| clip_name = StringTemplate(self.clip_name_template).format( | ||
| self._get_formatting_data(context, options) | ||
| ) |
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.
Rather use represenation value for output instead of using .rename(...) which might modify more than what you need.
| if not context["representation"]["context"].get("output"): | |
| self.clip_name_template = self.clip_name_template.replace( | |
| "output", "representation" | |
| ) | |
| clip_name = StringTemplate(self.clip_name_template).format( | |
| self._get_formatting_data(context, options) | |
| ) | |
| repre_context = copy.deepcopy( | |
| context["representation"]["context"] | |
| ) | |
| if not repre_context.get("output"): | |
| repre_context["output"] = repre_context["representation"] | |
| clip_name = StringTemplate(self.clip_name_template).format( | |
| repre_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.
If _get_formatting_data has to be called, then:
| if not context["representation"]["context"].get("output"): | |
| self.clip_name_template = self.clip_name_template.replace( | |
| "output", "representation" | |
| ) | |
| clip_name = StringTemplate(self.clip_name_template).format( | |
| self._get_formatting_data(context, options) | |
| ) | |
| formatting_data = self._get_formatting_data( | |
| context["representation"]["context"], | |
| options | |
| ) | |
| if not formatting_data.get("output"): | |
| formatting_data["output"] = formatting_data["representation"] | |
| clip_name = StringTemplate(self.clip_name_template).format( | |
| formatting_data | |
| ) |
| if message_args: | ||
| flame.messages.show_in_dialog(*message_args) |
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.
First read https://github.com/ynput/ayon-flame/pull/92/files#r2606771730
| if message_args: | |
| flame.messages.show_in_dialog(*message_args) | |
| if not version_entity["taskId"]: | |
| flame.messages.show_in_dialog( | |
| "Import Warning", | |
| ( | |
| "Version doesn't have set task." | |
| "\nUnable to import any other versions alongside" | |
| " the current selection." | |
| "\nThis may result in unordered versions within the" | |
| " clip. Deleting the clip and reloading it will resolve" | |
| " this issue." | |
| ), | |
| "warning", | |
| ["OK"], | |
| ) |
| ) | ||
| rename_clip = clip_solver.out_clip_data is None | ||
| message_args = None | ||
| if not version_entity["taskId"]: |
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.
1st if this happens it means the version is not linked to a task. It doesn't mean the task was removed. Task is optional for version to be created or to exist.
2nd Why is task so important? Shouldn't that look just for all versions of the product?
all_versions = ayon_api.get_versions(
project_name,
product_ids=[version_entity["productId"]],
)| for version in all_versions: | ||
| representation = ayon_api.get_representation_by_name( | ||
| project_name, | ||
| representation_name, | ||
| version_id=version["id"], | ||
| ) |
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.
Fetch all representations at once instead of one-by-one.
| for version in all_versions: | |
| representation = ayon_api.get_representation_by_name( | |
| project_name, | |
| representation_name, | |
| version_id=version["id"], | |
| ) | |
| repres_by_version_id = { | |
| version["id"]: None | |
| for version in all_versions | |
| } | |
| for repre_entity in ayon_api.get_representations( | |
| project_name, | |
| representation_names={representation_name}, | |
| version_ids=set(repres_by_version_id), | |
| ): | |
| version_id = repre_entity["versionId"] | |
| repres_by_version_id[version_id] = repre_entity | |
| for version in all_versions: | |
| representation = repres_by_version_id[version["id"]] |
|
|
||
| def _get_reel(self): | ||
| raise NotImplementedError() | ||
|
|
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.
| matching_clip = [cl for cl in reel.clips | ||
| if cl.name.get_value().startswith(name)] | ||
| if matching_clip: | ||
| return matching_clip.pop() | ||
| else: | ||
| created_clips = flame.import_clips(str(clip_path), reel) | ||
| return created_clips.pop() |
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.
| matching_clip = [cl for cl in reel.clips | |
| if cl.name.get_value().startswith(name)] | |
| if matching_clip: | |
| return matching_clip.pop() | |
| else: | |
| created_clips = flame.import_clips(str(clip_path), reel) | |
| return created_clips.pop() | |
| for cl in reel.clips: | |
| if cl.name.get_value().startswith(name): | |
| return cl | |
| created_clips = flame.import_clips(str(clip_path), reel) | |
| return created_clips.pop() |
| out_xml_versions_obj.set('currentVersion', version_name) | ||
|
|
||
| for out_xml_track in self.out_clip_data.iter("track"): | ||
| out_feeds = out_xml_track.find('feeds') |
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.
| out_feeds = out_xml_track.find('feeds') | |
| out_feeds = out_xml_track.find("feeds") |
| out_feeds = out_xml_track.find('feeds') | ||
| for feed in out_feeds.iter("feed"): | ||
| if feed.get("vuid") == version_name: | ||
| out_feeds.set('currentVersion', version_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.
| out_feeds.set('currentVersion', version_name) | |
| out_feeds.set("currentVersion", version_name) |
|
|
||
| def set_current_version(self, version_name: str) -> None: | ||
| out_xml_versions_obj = self.out_clip_data.find('versions') | ||
| out_xml_versions_obj.set('currentVersion', version_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.
| out_xml_versions_obj.set('currentVersion', version_name) | |
| out_xml_versions_obj.set("currentVersion", version_name) |
| ) | ||
|
|
||
| def set_current_version(self, version_name: str) -> None: | ||
| out_xml_versions_obj = self.out_clip_data.find('versions') |
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.
| out_xml_versions_obj = self.out_clip_data.find('versions') | |
| out_xml_versions_obj = self.out_clip_data.find("versions") |
| version_context["version"] = version | ||
| version_context["representation"] = representation | ||
|
|
||
| version_name = f"v{version['version']:03}" |
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.
Also handles hero version.
| version_name = f"v{version['version']:03}" | |
| version_name = version["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.
this one is for reason. the version name should be v001 rather then 1
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.
Which is what version["name"] contains, version["version"] is an integer.
|
this is looking good! lets just apply suggestions where it is possible and discuss next steps later @Liametc . Thank you. |
#90
adding better openclip loading that keeps the order of versions in flame
Changelog Description
Refactored the base class for the openclip loaders to load in all available versions of a publish to help respect version ordering and allow artist to use native flame functionality to choose version to display.
Testing notes: