mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
remove usage of system settings
This commit is contained in:
parent
4a785268c8
commit
01e69fa321
30 changed files with 83 additions and 157 deletions
|
|
@ -460,14 +460,14 @@ def is_representation_from_latest(representation):
|
|||
return version_is_latest(project_name, representation["parent"])
|
||||
|
||||
|
||||
def get_template_data_from_session(session=None, system_settings=None):
|
||||
def get_template_data_from_session(session=None, settings=None):
|
||||
"""Template data for template fill from session keys.
|
||||
|
||||
Args:
|
||||
session (Union[Dict[str, str], None]): The Session to use. If not
|
||||
provided use the currently active global Session.
|
||||
system_settings (Union[Dict[str, Any], Any]): Prepared system settings.
|
||||
Optional are auto received if not passed.
|
||||
settings (Optional[Dict[str, Any]]): Prepared studio or project
|
||||
settings.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: All available data from session.
|
||||
|
|
@ -486,15 +486,16 @@ def get_template_data_from_session(session=None, system_settings=None):
|
|||
host_name = get_current_host_name()
|
||||
|
||||
return get_template_data_with_names(
|
||||
project_name, asset_name, task_name, host_name, system_settings
|
||||
project_name, asset_name, task_name, host_name, settings
|
||||
)
|
||||
|
||||
|
||||
def get_current_context_template_data(system_settings=None):
|
||||
def get_current_context_template_data(settings=None):
|
||||
"""Prepare template data for current context.
|
||||
|
||||
Args:
|
||||
system_settings (Optional[Dict[str, Any]]): Prepared system settings.
|
||||
settings (Optional[Dict[str, Any]]): Prepared studio or
|
||||
project settings.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any] Template data for current context.
|
||||
|
|
@ -507,7 +508,7 @@ def get_current_context_template_data(system_settings=None):
|
|||
host_name = get_current_host_name()
|
||||
|
||||
return get_template_data_with_names(
|
||||
project_name, asset_name, task_name, host_name, system_settings
|
||||
project_name, asset_name, task_name, host_name, settings
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,10 +16,7 @@ from ayon_core.client import (
|
|||
get_asset_by_name,
|
||||
get_asset_name_identifier,
|
||||
)
|
||||
from ayon_core.settings import (
|
||||
get_system_settings,
|
||||
get_project_settings
|
||||
)
|
||||
from ayon_core.settings import get_project_settings
|
||||
from ayon_core.lib.attribute_definitions import (
|
||||
UnknownDef,
|
||||
serialize_attr_defs,
|
||||
|
|
@ -1774,7 +1771,6 @@ class CreateContext:
|
|||
|
||||
def _reset_creator_plugins(self):
|
||||
# Prepare settings
|
||||
system_settings = get_system_settings()
|
||||
project_settings = get_project_settings(self.project_name)
|
||||
|
||||
# Discover and prepare creators
|
||||
|
|
@ -1812,7 +1808,6 @@ class CreateContext:
|
|||
|
||||
creator = creator_class(
|
||||
project_settings,
|
||||
system_settings,
|
||||
self,
|
||||
self.headless
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ from abc import ABCMeta, abstractmethod
|
|||
|
||||
import six
|
||||
|
||||
from ayon_core.settings import get_system_settings, get_project_settings
|
||||
from ayon_core.lib import Logger, is_func_signature_supported
|
||||
from ayon_core.settings import get_project_settings
|
||||
from ayon_core.lib import Logger
|
||||
from ayon_core.pipeline.plugin_discover import (
|
||||
discover,
|
||||
register_plugin,
|
||||
|
|
@ -201,7 +201,7 @@ class BaseCreator:
|
|||
settings_name = None
|
||||
|
||||
def __init__(
|
||||
self, project_settings, system_settings, create_context, headless=False
|
||||
self, project_settings, create_context, headless=False
|
||||
):
|
||||
# Reference to CreateContext
|
||||
self.create_context = create_context
|
||||
|
|
@ -211,34 +211,7 @@ class BaseCreator:
|
|||
# - we may use UI inside processing this attribute should be checked
|
||||
self.headless = headless
|
||||
|
||||
expect_system_settings = False
|
||||
if is_func_signature_supported(
|
||||
self.apply_settings, project_settings
|
||||
):
|
||||
self.apply_settings(project_settings)
|
||||
else:
|
||||
expect_system_settings = True
|
||||
# Backwards compatibility for system settings
|
||||
self.apply_settings(project_settings, system_settings)
|
||||
|
||||
init_use_base = any(
|
||||
self.__class__.__init__ is cls.__init__
|
||||
for cls in {
|
||||
BaseCreator,
|
||||
Creator,
|
||||
HiddenCreator,
|
||||
AutoCreator,
|
||||
}
|
||||
)
|
||||
if not init_use_base or expect_system_settings:
|
||||
self.log.warning((
|
||||
"WARNING: Source - Create plugin {}."
|
||||
" System settings argument will not be passed to"
|
||||
" '__init__' and 'apply_settings' methods in future versions"
|
||||
" of OpenPype. Planned version to drop the support"
|
||||
" is 3.16.6 or 3.17.0. Please contact Ynput core team if you"
|
||||
" need to keep system settings."
|
||||
).format(self.__class__.__name__))
|
||||
self.apply_settings(project_settings)
|
||||
|
||||
@staticmethod
|
||||
def _get_settings_values(project_settings, category_name, plugin_name):
|
||||
|
|
@ -838,11 +811,10 @@ def discover_legacy_creator_plugins():
|
|||
|
||||
plugins = discover(LegacyCreator)
|
||||
project_name = get_current_project_name()
|
||||
system_settings = get_system_settings()
|
||||
project_settings = get_project_settings(project_name)
|
||||
for plugin in plugins:
|
||||
try:
|
||||
plugin.apply_settings(project_settings, system_settings)
|
||||
plugin.apply_settings(project_settings)
|
||||
except Exception:
|
||||
log.warning(
|
||||
"Failed to apply settings to creator {}".format(
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class LegacyCreator(object):
|
|||
self.data.update(data or {})
|
||||
|
||||
@classmethod
|
||||
def apply_settings(cls, project_settings, system_settings):
|
||||
def apply_settings(cls, project_settings):
|
||||
"""Apply OpenPype settings to a plugin class."""
|
||||
|
||||
host_name = os.environ.get("AYON_HOST_NAME")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
import logging
|
||||
|
||||
from ayon_core.settings import get_system_settings, get_project_settings
|
||||
from ayon_core.settings import get_project_settings
|
||||
from ayon_core.pipeline import schema
|
||||
from ayon_core.pipeline.plugin_discover import (
|
||||
discover,
|
||||
|
|
@ -37,7 +37,7 @@ class LoaderPlugin(list):
|
|||
log.propagate = True
|
||||
|
||||
@classmethod
|
||||
def apply_settings(cls, project_settings, system_settings):
|
||||
def apply_settings(cls, project_settings):
|
||||
host_name = os.environ.get("AYON_HOST_NAME")
|
||||
plugin_type = "load"
|
||||
plugin_type_settings = (
|
||||
|
|
@ -262,11 +262,10 @@ def discover_loader_plugins(project_name=None):
|
|||
plugins = discover(LoaderPlugin)
|
||||
if not project_name:
|
||||
project_name = get_current_project_name()
|
||||
system_settings = get_system_settings()
|
||||
project_settings = get_project_settings(project_name)
|
||||
for plugin in plugins:
|
||||
try:
|
||||
plugin.apply_settings(project_settings, system_settings)
|
||||
plugin.apply_settings(project_settings)
|
||||
except Exception:
|
||||
log.warning(
|
||||
"Failed to apply settings to loader {}".format(
|
||||
|
|
|
|||
|
|
@ -13,12 +13,8 @@ from ayon_core.lib import (
|
|||
Logger,
|
||||
import_filepath,
|
||||
filter_profiles,
|
||||
is_func_signature_supported,
|
||||
)
|
||||
from ayon_core.settings import (
|
||||
get_project_settings,
|
||||
get_system_settings,
|
||||
)
|
||||
from ayon_core.settings import get_project_settings
|
||||
from ayon_core.pipeline import (
|
||||
tempdir,
|
||||
Anatomy
|
||||
|
|
@ -421,8 +417,8 @@ def apply_plugin_settings_automatically(plugin, settings, logger=None):
|
|||
def filter_pyblish_plugins(plugins):
|
||||
"""Pyblish plugin filter which applies AYON settings.
|
||||
|
||||
Apply OpenPype settings on discovered plugins. On plugin with implemented
|
||||
class method 'def apply_settings(cls, project_settings, system_settings)'
|
||||
Apply settings on discovered plugins. On plugin with implemented
|
||||
class method 'def apply_settings(cls, project_settings)'
|
||||
is called the method. Default behavior looks for plugin name and current
|
||||
host name to look for
|
||||
|
||||
|
|
@ -440,7 +436,6 @@ def filter_pyblish_plugins(plugins):
|
|||
project_name = os.environ.get("AYON_PROJECT_NAME")
|
||||
|
||||
project_settings = get_project_settings(project_name)
|
||||
system_settings = get_system_settings()
|
||||
|
||||
# iterate over plugins
|
||||
for plugin in plugins[:]:
|
||||
|
|
@ -452,19 +447,7 @@ def filter_pyblish_plugins(plugins):
|
|||
# - can be used to target settings from custom settings place
|
||||
# - skip default behavior when successful
|
||||
try:
|
||||
# Support to pass only project settings
|
||||
# - make sure that both settings are passed, when can be
|
||||
# - that covers cases when *args are in method parameters
|
||||
both_supported = is_func_signature_supported(
|
||||
apply_settings_func, project_settings, system_settings
|
||||
)
|
||||
project_supported = is_func_signature_supported(
|
||||
apply_settings_func, project_settings
|
||||
)
|
||||
if not both_supported and project_supported:
|
||||
plugin.apply_settings(project_settings)
|
||||
else:
|
||||
plugin.apply_settings(project_settings, system_settings)
|
||||
plugin.apply_settings(project_settings)
|
||||
|
||||
except Exception:
|
||||
log.warning(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from ayon_core.client import get_project, get_asset_by_name
|
||||
from ayon_core.settings import get_system_settings
|
||||
from ayon_core.settings import get_studio_settings
|
||||
from ayon_core.lib.local_settings import get_ayon_username
|
||||
|
||||
|
||||
def get_general_template_data(system_settings=None):
|
||||
def get_general_template_data(settings=None):
|
||||
"""General template data based on system settings or machine.
|
||||
|
||||
Output contains formatting keys:
|
||||
|
|
@ -12,12 +12,12 @@ def get_general_template_data(system_settings=None):
|
|||
- 'user' - User's name using 'get_ayon_username'
|
||||
|
||||
Args:
|
||||
system_settings (Dict[str, Any]): System settings.
|
||||
settings (Dict[str, Any]): Studio or project settings.
|
||||
"""
|
||||
|
||||
if not system_settings:
|
||||
system_settings = get_system_settings()
|
||||
core_settings = system_settings["core"]
|
||||
if not settings:
|
||||
settings = get_studio_settings()
|
||||
core_settings = settings["core"]
|
||||
return {
|
||||
"studio": {
|
||||
"name": core_settings["studio_name"],
|
||||
|
|
@ -154,7 +154,7 @@ def get_template_data(
|
|||
asset_doc=None,
|
||||
task_name=None,
|
||||
host_name=None,
|
||||
system_settings=None
|
||||
settings=None
|
||||
):
|
||||
"""Prepare data for templates filling from entered documents and info.
|
||||
|
||||
|
|
@ -174,14 +174,14 @@ def get_template_data(
|
|||
asset_doc (Dict[str, Any]): Mongo document of asset from MongoDB.
|
||||
task_name (Union[str, None]): Task name under passed asset.
|
||||
host_name (Union[str, None]): Used to fill '{app}' key.
|
||||
system_settings (Union[Dict, None]): Prepared system settings.
|
||||
settings (Union[Dict, None]): Prepared studio or project settings.
|
||||
They're queried if not passed (may be slower).
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: Data prepared for filling workdir template.
|
||||
"""
|
||||
|
||||
template_data = get_general_template_data(system_settings)
|
||||
template_data = get_general_template_data(settings)
|
||||
template_data.update(get_project_template_data(project_doc))
|
||||
if asset_doc:
|
||||
template_data.update(get_asset_template_data(
|
||||
|
|
@ -203,7 +203,7 @@ def get_template_data_with_names(
|
|||
asset_name=None,
|
||||
task_name=None,
|
||||
host_name=None,
|
||||
system_settings=None
|
||||
settings=None
|
||||
):
|
||||
"""Prepare data for templates filling from entered entity names and info.
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ def get_template_data_with_names(
|
|||
task_name (Union[str, None]): Task name under passed asset.
|
||||
host_name (Union[str, None]):Used to fill '{app}' key.
|
||||
because workdir template may contain `{app}` key.
|
||||
system_settings (Union[Dict, None]): Prepared system settings.
|
||||
settings (Union[Dict, None]): Prepared studio or project settings.
|
||||
They're queried if not passed.
|
||||
|
||||
Returns:
|
||||
|
|
@ -236,5 +236,5 @@ def get_template_data_with_names(
|
|||
fields=["name", "data.parents", "data.tasks"]
|
||||
)
|
||||
return get_template_data(
|
||||
project_doc, asset_doc, task_name, host_name, system_settings
|
||||
project_doc, asset_doc, task_name, host_name, settings
|
||||
)
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@ from ayon_core.client import (
|
|||
get_representations,
|
||||
get_ayon_server_api_connection,
|
||||
)
|
||||
from ayon_core.settings import (
|
||||
get_project_settings,
|
||||
get_system_settings,
|
||||
)
|
||||
from ayon_core.settings import get_project_settings
|
||||
from ayon_core.host import IWorkfileHost, HostBase
|
||||
from ayon_core.lib import (
|
||||
Logger,
|
||||
|
|
@ -118,7 +115,6 @@ class AbstractTemplateBuilder(object):
|
|||
self._creators_by_name = None
|
||||
self._create_context = None
|
||||
|
||||
self._system_settings = None
|
||||
self._project_settings = None
|
||||
|
||||
self._current_asset_doc = None
|
||||
|
|
@ -152,12 +148,6 @@ class AbstractTemplateBuilder(object):
|
|||
"task_name": self.current_task_name
|
||||
}
|
||||
|
||||
@property
|
||||
def system_settings(self):
|
||||
if self._system_settings is None:
|
||||
self._system_settings = get_system_settings()
|
||||
return self._system_settings
|
||||
|
||||
@property
|
||||
def project_settings(self):
|
||||
if self._project_settings is None:
|
||||
|
|
@ -256,7 +246,6 @@ class AbstractTemplateBuilder(object):
|
|||
self._linked_asset_docs = None
|
||||
self._task_type = None
|
||||
|
||||
self._system_settings = None
|
||||
self._project_settings = None
|
||||
|
||||
self.clear_shared_data()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue