Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Publisher: Convertors for legacy instances #4020

Merged
merged 31 commits into from
Oct 26, 2022

Conversation

iLLiCiTiT
Copy link
Member

@iLLiCiTiT iLLiCiTiT commented Oct 21, 2022

Brief description

Give ability to have convertor plugins for conversion from legacy instances to new creators.

Description

Added Convertor plugins which can collect ConvertorItem into CreateContext. These items are shown in UI next to instances with a label that the convertor plugin defines. Convertor collect items after Creator's collection so there should not be a clash if any creator would convert something automatically and also has access to shared data. Has 2 methods find_instances and convert both without any arguments. Plugin must be in files next to creators (can be in file with creator). In UI is conversion button always before creator attributes. So multiple conversion plugins can be selected and UI does not break when instances are selected too.

Screenshots

image
image

Testing notes:

Create fake convertor in TrayPublisher e.g. ~/openpype/hosts/traypublisher/plugins/create/converter_test.py with this content.

from openpype.pipeline.create.creator_plugins import SubsetConvertorPlugin


class TestConverted(SubsetConvertorPlugin):
    identifier = "text.converter"

    def find_instances(self):
        # This is called during collection - plugin should create it's item based on some logic
        #  - for example find an instance without 'creator_identifier'
        self.add_convertor_item("My testing legacy item")

    def convert(self):
        # This is method which is triggered from the UI
        # - should update items for new creators and remove item if was successfull
        print("Fake converting. This is when would logic of conversion be.")
        self.remove_convertor_item()

@ynbot
Copy link
Contributor

ynbot commented Oct 21, 2022

Task linked: OP-4285 Convertors for legacy instances

@iLLiCiTiT iLLiCiTiT marked this pull request as draft October 21, 2022 17:40
@iLLiCiTiT iLLiCiTiT self-assigned this Oct 21, 2022
@iLLiCiTiT iLLiCiTiT added the type: enhancement Enhancements to existing functionality label Oct 21, 2022
@iLLiCiTiT iLLiCiTiT marked this pull request as ready for review October 24, 2022 17:32
try:
self.run_convertor(convertor_identifier)

except:
Copy link

Choose a reason for hiding this comment

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

Do not use bare except:, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer except Exception:. If you're sure what you're doing, be explicit and write except BaseException:.
do not use bare 'except'

new_item["label"] = new_item.pop("creator_label")
new_item["identifier"] = new_item.pop("creator_identifier")
new_failed_info.append(new_item)
self.add_error_message_dialog(event["title"], new_failed_info, "Creator:")
Copy link

Choose a reason for hiding this comment

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

line too long (82 > 79 characters)

Copy link
Member

@antirotor antirotor left a comment

Choose a reason for hiding this comment

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

Seems like it is working but I would add two things:

  1. Reset publisher after conversion is done
  2. add log to the converter (to access self.log.*)

@iLLiCiTiT
Copy link
Member Author

Seems like it is working but I would add two things:

Both should be available now.

@mkolar mkolar merged commit 6d75023 into develop Oct 26, 2022
@iLLiCiTiT iLLiCiTiT deleted the feature/OP-4285_Convertors-for-legacy-instances branch October 26, 2022 09:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: enhancement Enhancements to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants