only project settings are passed by default to create plugin

This commit is contained in:
Jakub Trllo 2023-09-01 15:54:42 +02:00
parent 9cf21b77ff
commit 78b5ae149a
2 changed files with 27 additions and 15 deletions

View file

@ -16,6 +16,7 @@ from openpype.settings import (
get_system_settings,
get_project_settings
)
from openpype.lib import is_func_signature_supported
from openpype.lib.attribute_definitions import (
UnknownDef,
serialize_attr_defs,
@ -1774,7 +1775,7 @@ class CreateContext:
self.creator_discover_result = report
for creator_class in report.plugins:
if inspect.isabstract(creator_class):
self.log.info(
self.log.debug(
"Skipping abstract Creator {}".format(str(creator_class))
)
continue
@ -1798,12 +1799,16 @@ class CreateContext:
).format(creator_class.host_name, self.host_name))
continue
creator = creator_class(
project_settings,
system_settings,
self,
self.headless
)
if is_func_signature_supported(
creator_class, project_settings, self, self.headless
):
creator = creator_class(project_settings, self, self.headless)
else:
# Backwards compatibility to pass system settings to creators
creator = creator_class(
project_settings, system_settings, self, self.headless
)
if not creator.enabled:
disabled_creators[creator_identifier] = creator
continue

View file

@ -10,7 +10,7 @@ from abc import (
import six
from openpype.settings import get_system_settings, get_project_settings
from openpype.lib import Logger
from openpype.lib import Logger, is_func_signature_supported
from openpype.pipeline.plugin_discover import (
discover,
register_plugin,
@ -161,7 +161,6 @@ class BaseCreator:
Args:
project_settings (Dict[str, Any]): Project settings.
system_settings (Dict[str, Any]): System settings.
create_context (CreateContext): Context which initialized creator.
headless (bool): Running in headless mode.
"""
@ -197,9 +196,7 @@ class BaseCreator:
# QUESTION make this required?
host_name = None
def __init__(
self, project_settings, system_settings, create_context, headless=False
):
def __init__(self, project_settings, create_context, headless=False):
# Reference to CreateContext
self.create_context = create_context
self.project_settings = project_settings
@ -208,10 +205,20 @@ class BaseCreator:
# - we may use UI inside processing this attribute should be checked
self.headless = headless
self.apply_settings(project_settings, system_settings)
if is_func_signature_supported(
self.apply_settings, project_settings
):
self.apply_settings(project_settings)
else:
# Backwards compatibility for system settings
self.apply_settings(project_settings, {})
def apply_settings(self, project_settings, system_settings):
"""Method called on initialization of plugin to apply settings."""
def apply_settings(self, project_settings):
"""Method called on initialization of plugin to apply settings.
Args:
project_settings (dict[str, Any]): Project settings.
"""
pass