Skip to content

Conversation

@Liametc
Copy link
Contributor

@Liametc Liametc commented Dec 8, 2025

#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:

  1. Create a few versions of a render
  2. bring the versions in to flame through the loader in a random order
  3. The clip version should go up in order and the last chosen version to load will be the one selected

@jakubjezek001 jakubjezek001 added type: enhancement Improvement of existing functionality or minor addition sponsored This is directly sponsored by a client or community member labels Dec 10, 2025
Comment on lines +653 to +659
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)
)
Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 10, 2025

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.

Suggested change
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
)

Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 10, 2025

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:

Suggested change
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
)

Comment on lines +751 to +752
if message_args:
flame.messages.show_in_dialog(*message_args)
Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 10, 2025

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

Suggested change
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"]:
Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 10, 2025

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"]],
            )

Comment on lines +697 to +702
for version in all_versions:
representation = ayon_api.get_representation_by_name(
project_name,
representation_name,
version_id=version["id"],
)
Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 10, 2025

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.

Suggested change
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()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +759 to +765
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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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}"
Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also handles hero version.

Suggested change
version_name = f"v{version['version']:03}"
version_name = version["name"]

Copy link
Member

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

Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 11, 2025

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.

@jakubjezek001
Copy link
Member

this is looking good! lets just apply suggestions where it is possible and discuss next steps later @Liametc . Thank you.

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

Labels

sponsored This is directly sponsored by a client or community member type: enhancement Improvement of existing functionality or minor addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants