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

[QUAD] Deadline Plugins: Improve how settings are applied to plugins, always apply OP settings first #6323

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions openpype/hosts/equalizer/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,6 @@ class ExtractScriptBase(OptionalPyblishPluginMixin):
overscan_percent_height = 100
units = "mm"

@classmethod
def apply_settings(cls, project_settings, system_settings):
settings = project_settings["equalizer"]["publish"][
"ExtractMatchmoveScriptMaya"] # noqa

cls.hide_reference_frame = settings.get(
"hide_reference_frame", cls.hide_reference_frame)
cls.export_uv_textures = settings.get(
"export_uv_textures", cls.export_uv_textures)
cls.overscan_percent_width = settings.get(
"overscan_percent_width", cls.overscan_percent_width)
cls.overscan_percent_height = settings.get(
"overscan_percent_height", cls.overscan_percent_height)
cls.units = settings.get("units", cls.units)

@classmethod
def get_attribute_defs(cls):
defs = super(ExtractScriptBase, cls).get_attribute_defs()
Expand Down
7 changes: 0 additions & 7 deletions openpype/modules/deadline/plugins/publish/collect_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ class CollectDeadlinePools(pyblish.api.InstancePlugin,
primary_pool = None
secondary_pool = None

@classmethod
def apply_settings(cls, project_settings, system_settings):
# deadline.publish.CollectDeadlinePools
settings = project_settings["deadline"]["publish"]["CollectDeadlinePools"] # noqa
cls.primary_pool = settings.get("primary_pool", None)
cls.secondary_pool = settings.get("secondary_pool", None)

def process(self, instance):
attr_values = self.get_attr_values_from_data(instance.data)
if not instance.data.get("primaryPool"):
Expand Down
11 changes: 0 additions & 11 deletions openpype/modules/deadline/plugins/publish/submit_max_deadline.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline,
pluginInfo = {}
group = None

@classmethod
def apply_settings(cls, project_settings, system_settings):
settings = project_settings["deadline"]["publish"]["MaxSubmitDeadline"] # noqa

# Take some defaults from settings
cls.use_published = settings.get("use_published",
cls.use_published)
cls.priority = settings.get("priority",
cls.priority)
cls.chuck_size = settings.get("chunk_size", cls.chunk_size)
cls.group = settings.get("group", cls.group)
# TODO: multiple camera instance, separate job infos
def get_job_info(self):
job_info = DeadlineJobInfo(Plugin="3dsmax")
Expand Down
19 changes: 0 additions & 19 deletions openpype/modules/deadline/plugins/publish/submit_maya_deadline.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,6 @@ class MayaSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline,
group = "none"
strict_error_checking = True

@classmethod
def apply_settings(cls, project_settings, system_settings):
settings = project_settings["deadline"]["publish"]["MayaSubmitDeadline"] # noqa

# Take some defaults from settings
cls.asset_dependencies = settings.get("asset_dependencies",
cls.asset_dependencies)
cls.import_reference = settings.get("import_reference",
cls.import_reference)
cls.use_published = settings.get("use_published", cls.use_published)
cls.priority = settings.get("priority", cls.priority)
cls.tile_priority = settings.get("tile_priority", cls.tile_priority)
cls.limit = settings.get("limit", cls.limit)
cls.group = settings.get("group", cls.group)
cls.strict_error_checking = settings.get("strict_error_checking",
cls.strict_error_checking)
cls.jobInfo = settings.get("jobInfo", cls.jobInfo)
cls.pluginInfo = settings.get("pluginInfo", cls.pluginInfo)

def get_job_info(self):
job_info = DeadlineJobInfo(Plugin="MayaBatch")

Expand Down
8 changes: 4 additions & 4 deletions openpype/pipeline/publish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
get_instance_staging_dir,
get_publish_repre_path,

apply_plugin_settings_automatically,
get_plugin_settings,
apply_plugin_settings,
get_publish_plugin_settings,
get_publish_instance_label,
get_publish_instance_families,
)
Expand Down Expand Up @@ -85,8 +85,8 @@
"get_instance_staging_dir",
"get_publish_repre_path",

"apply_plugin_settings_automatically",
"get_plugin_settings",
"apply_plugin_settings",
"get_publish_plugin_settings",
"get_publish_instance_label",
"get_publish_instance_families",

Expand Down
37 changes: 20 additions & 17 deletions openpype/pipeline/publish/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def publish_plugins_discover(paths=None):
return result


def get_plugin_settings(plugin, project_settings, log, category=None):
def get_publish_plugin_settings(plugin, project_settings, category=None, logger=None):
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 (86 > 79 characters)

"""Get plugin settings based on host name and plugin name.

Note:
Expand All @@ -325,13 +325,15 @@ def get_plugin_settings(plugin, project_settings, log, category=None):
Args:
plugin (pyblish.Plugin): Plugin where settings are applied.
project_settings (dict[str, Any]): Project settings.
log (logging.Logger): Logger to log messages.
category (Optional[str]): Settings category key where to look
for plugin settings.
logger (Optional[logging.Logger]): Logger to log messages.

Returns:
dict[str, Any]: Plugin settings {'attribute': 'value'}.
"""
if not logger:
logger = Logger.get_logger("get_publish_plugin_settings")

# Plugin can define settings category by class attribute
# - it's impossible to set `settings_category` via settings because
Expand All @@ -347,7 +349,7 @@ def get_plugin_settings(plugin, project_settings, log, category=None):
[plugin.__name__]
)
except KeyError:
log.warning((
logger.warning((
"Couldn't find plugin '{}' settings"
" under settings category '{}'"
).format(plugin.__name__, settings_category))
Expand All @@ -366,13 +368,13 @@ def get_plugin_settings(plugin, project_settings, log, category=None):
pass

# Settings category determined from path
# - usually path is './<category>/plugins/publish/<plugin file>'
# - usually the path is './<category>/plugins/publish/<plugin file>'
# - category can be host name of addon name ('maya', 'deadline', ...)
filepath = os.path.normpath(inspect.getsourcefile(plugin))

split_path = filepath.rsplit(os.path.sep, 5)
if len(split_path) < 4:
log.debug((
logger.debug((
"Plugin path is too short to automatically"
" extract settings category. {}"
).format(filepath))
Expand All @@ -397,7 +399,7 @@ def get_plugin_settings(plugin, project_settings, log, category=None):
return {}


def apply_plugin_settings_automatically(plugin, settings, logger=None):
def apply_plugin_settings(plugin, settings, logger=None):
"""Automatically apply plugin settings to a plugin object.

Note:
Expand Down Expand Up @@ -431,10 +433,10 @@ class method 'def apply_settings(cls, project_settings, system_settings)'
are applied settings.
"""

log = Logger.get_logger("filter_pyblish_plugins")
logger = Logger.get_logger("filter_pyblish_plugins")

# TODO: Don't use host from 'pyblish.api' but from defined host by us.
# - kept becau on farm is probably used host 'shell' which propably
# - kept because on farm is probably used host 'shell' which probably
# affect how settings are applied there
host_name = pyblish.api.current_host()
project_name = os.environ.get("AVALON_PROJECT")
Expand All @@ -444,7 +446,14 @@ class method 'def apply_settings(cls, project_settings, system_settings)'

# iterate over plugins
for plugin in plugins[:]:
# Apply settings to plugins
# Apply settings to plugin

# First settings from OP settings
plugin_settings = get_publish_plugin_settings(
plugin, project_settings, host_name, logger)
apply_plugin_settings(plugin, plugin_settings, logger)

# Then (if defined) calling the class method

apply_settings_func = getattr(plugin, "apply_settings", None)
if apply_settings_func is not None:
Expand All @@ -466,19 +475,13 @@ class method 'def apply_settings(cls, project_settings, system_settings)'
else:
plugin.apply_settings(project_settings, system_settings)

except Exception:
log.warning(
except Exception: # noqa
logger.warning(
(
"Failed to apply settings on plugin {}"
).format(plugin.__name__),
exc_info=True
)
else:
# Automated
plugin_settins = get_plugin_settings(
plugin, project_settings, log, host_name
)
apply_plugin_settings_automatically(plugin, plugin_settins, log)

# Remove disabled plugins
if getattr(plugin, "enabled", True) is False:
Expand Down
Loading