mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge branch 'feature/OP-8123_Addon-initialization-phase-one' into enhancement/use-AYON-prefix-in-env-variables
# Conflicts: # client/ayon_core/modules/deadline/plugins/publish/submit_maya_remote_publish_deadline.py
This commit is contained in:
commit
3d06a753ae
9 changed files with 114 additions and 51 deletions
|
|
@ -35,10 +35,10 @@ class BlenderAddon(OpenPypeModule, IHostAddon):
|
|||
# loops - will be removed at the end
|
||||
previous_user_scripts.add(implementation_user_script_path)
|
||||
|
||||
openpype_blender_user_scripts = (
|
||||
env.get("OPENPYPE_BLENDER_USER_SCRIPTS") or ""
|
||||
ayon_blender_user_scripts = (
|
||||
env.get("AYON_BLENDER_USER_SCRIPTS") or ""
|
||||
)
|
||||
for path in openpype_blender_user_scripts.split(os.pathsep):
|
||||
for path in ayon_blender_user_scripts.split(os.pathsep):
|
||||
if path:
|
||||
previous_user_scripts.add(os.path.normpath(path))
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ class BlenderAddon(OpenPypeModule, IHostAddon):
|
|||
env["BLENDER_USER_SCRIPTS"] = implementation_user_script_path
|
||||
|
||||
# Set custom user scripts env
|
||||
env["OPENPYPE_BLENDER_USER_SCRIPTS"] = os.pathsep.join(
|
||||
env["AYON_BLENDER_USER_SCRIPTS"] = os.pathsep.join(
|
||||
previous_user_scripts
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ def load_scripts(paths):
|
|||
|
||||
|
||||
def append_user_scripts():
|
||||
user_scripts = os.environ.get("OPENPYPE_BLENDER_USER_SCRIPTS")
|
||||
user_scripts = os.environ.get("AYON_BLENDER_USER_SCRIPTS")
|
||||
if not user_scripts:
|
||||
return
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ def set_app_templates_path():
|
|||
# We look among the scripts paths for one of the paths that contains
|
||||
# the app templates. The path must contain the subfolder
|
||||
# `startup/bl_app_templates_user`.
|
||||
paths = os.environ.get("OPENPYPE_BLENDER_USER_SCRIPTS").split(os.pathsep)
|
||||
paths = os.environ.get("AYON_BLENDER_USER_SCRIPTS").split(os.pathsep)
|
||||
|
||||
app_templates_path = None
|
||||
for path in paths:
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from ayon_core.hosts.blender.api.pipeline import (
|
|||
AVALON_PROPERTY,
|
||||
)
|
||||
|
||||
logger = logging.getLogger("openpype").getChild("blender").getChild("load_action")
|
||||
logger = logging.getLogger("ayon").getChild("blender").getChild("load_action")
|
||||
|
||||
|
||||
class BlendActionLoader(plugin.AssetLoader):
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ from .path_tools import (
|
|||
from .ayon_info import (
|
||||
is_running_from_build,
|
||||
is_staging_enabled,
|
||||
is_dev_mode_enabled,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -276,6 +277,7 @@ __all__ = [
|
|||
|
||||
"is_running_from_build",
|
||||
"is_staging_enabled",
|
||||
"is_dev_mode_enabled",
|
||||
|
||||
"requests_get",
|
||||
"requests_post"
|
||||
|
|
|
|||
|
|
@ -38,6 +38,16 @@ def is_staging_enabled():
|
|||
return os.getenv("AYON_USE_STAGING") == "1"
|
||||
|
||||
|
||||
def is_dev_mode_enabled():
|
||||
"""Dev mode is enabled in AYON.
|
||||
|
||||
Returns:
|
||||
bool: True if dev mode is enabled.
|
||||
"""
|
||||
|
||||
return os.getenv("AYON_USE_DEV") == "1"
|
||||
|
||||
|
||||
def get_ayon_info():
|
||||
executable_args = get_ayon_launcher_args()
|
||||
if is_running_from_build():
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ Available deadline pools:
|
|||
This error is shown when a configured pool is not available on Deadline. It
|
||||
can happen when publishing old workfiles which were created with previous
|
||||
deadline pools, or someone changed the available pools in Deadline,
|
||||
but didn't modify Openpype Settings to match the changes.
|
||||
but didn't modify AYON Settings to match the changes.
|
||||
</detail>
|
||||
</error>
|
||||
</root>
|
||||
|
|
@ -107,7 +107,6 @@ class MayaSubmitRemotePublishDeadline(
|
|||
environment["AVALON_TASK"] = instance.context.data["task"]
|
||||
environment["AVALON_APP_NAME"] = os.environ.get("AVALON_APP_NAME")
|
||||
environment["OPENPYPE_PUBLISH_SUBSET"] = instance.data["subset"]
|
||||
environment["OPENPYPE_REMOTE_PUBLISH"] = "1"
|
||||
environment["AYON_LOG_NO_COLORS"] = "1"
|
||||
environment["AYON_USERNAME"] = instance.context.data["user"]
|
||||
environment["AYON_REMOTE_PUBLISH"] = "1"
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ def inject_openpype_environment(deadlinePlugin):
|
|||
|
||||
# tempfile.TemporaryFile cannot be used because of locking
|
||||
temp_file_name = "{}_{}.json".format(
|
||||
datetime.utcnow().strftime('%Y%m%d%H%M%S%f'),
|
||||
datetime.utcnow().strftime("%Y%m%d%H%M%S%f"),
|
||||
str(uuid.uuid1())
|
||||
)
|
||||
export_url = os.path.join(tempfile.gettempdir(), temp_file_name)
|
||||
|
|
@ -343,7 +343,7 @@ def inject_openpype_environment(deadlinePlugin):
|
|||
"envgroup": "farm"
|
||||
}
|
||||
|
||||
if job.GetJobEnvironmentKeyValue('IS_TEST'):
|
||||
if job.GetJobEnvironmentKeyValue("IS_TEST"):
|
||||
args.append("--automatic-tests")
|
||||
|
||||
if all(add_kwargs.values()):
|
||||
|
|
@ -412,13 +412,13 @@ def inject_openpype_environment(deadlinePlugin):
|
|||
|
||||
|
||||
def inject_ayon_environment(deadlinePlugin):
|
||||
""" Pull env vars from Ayon and push them to rendering process.
|
||||
""" Pull env vars from AYON and push them to rendering process.
|
||||
|
||||
Used for correct paths, configuration from OpenPype etc.
|
||||
Used for correct paths, configuration from AYON etc.
|
||||
"""
|
||||
job = deadlinePlugin.GetJob()
|
||||
|
||||
print(">>> Injecting Ayon environments ...")
|
||||
print(">>> Injecting AYON environments ...")
|
||||
try:
|
||||
exe_list = get_ayon_executable()
|
||||
exe = FileUtils.SearchFileList(exe_list)
|
||||
|
|
@ -435,17 +435,18 @@ def inject_ayon_environment(deadlinePlugin):
|
|||
|
||||
ayon_bundle_name = job.GetJobEnvironmentKeyValue("AYON_BUNDLE_NAME")
|
||||
if not ayon_bundle_name:
|
||||
raise RuntimeError("Missing env var in job properties "
|
||||
"AYON_BUNDLE_NAME")
|
||||
raise RuntimeError(
|
||||
"Missing env var in job properties AYON_BUNDLE_NAME"
|
||||
)
|
||||
|
||||
config = RepositoryUtils.GetPluginConfig("Ayon")
|
||||
ayon_server_url = (
|
||||
job.GetJobEnvironmentKeyValue("AYON_SERVER_URL") or
|
||||
config.GetConfigEntryWithDefault("AyonServerUrl", "")
|
||||
job.GetJobEnvironmentKeyValue("AYON_SERVER_URL") or
|
||||
config.GetConfigEntryWithDefault("AyonServerUrl", "")
|
||||
)
|
||||
ayon_api_key = (
|
||||
job.GetJobEnvironmentKeyValue("AYON_API_KEY") or
|
||||
config.GetConfigEntryWithDefault("AyonApiKey", "")
|
||||
job.GetJobEnvironmentKeyValue("AYON_API_KEY") or
|
||||
config.GetConfigEntryWithDefault("AyonApiKey", "")
|
||||
)
|
||||
|
||||
if not all([ayon_server_url, ayon_api_key]):
|
||||
|
|
@ -457,7 +458,7 @@ def inject_ayon_environment(deadlinePlugin):
|
|||
|
||||
# tempfile.TemporaryFile cannot be used because of locking
|
||||
temp_file_name = "{}_{}.json".format(
|
||||
datetime.utcnow().strftime('%Y%m%d%H%M%S%f'),
|
||||
datetime.utcnow().strftime("%Y%m%d%H%M%S%f"),
|
||||
str(uuid.uuid1())
|
||||
)
|
||||
export_url = os.path.join(tempfile.gettempdir(), temp_file_name)
|
||||
|
|
@ -477,7 +478,7 @@ def inject_ayon_environment(deadlinePlugin):
|
|||
"envgroup": "farm",
|
||||
}
|
||||
|
||||
if job.GetJobEnvironmentKeyValue('IS_TEST'):
|
||||
if job.GetJobEnvironmentKeyValue("IS_TEST"):
|
||||
args.append("--automatic-tests")
|
||||
|
||||
if all(add_kwargs.values()):
|
||||
|
|
@ -545,19 +546,23 @@ def inject_ayon_environment(deadlinePlugin):
|
|||
|
||||
|
||||
def get_ayon_executable():
|
||||
"""Return OpenPype Executable from Event Plug-in Settings
|
||||
"""Return AYON Executable from Event Plug-in Settings
|
||||
|
||||
Returns:
|
||||
(list) of paths
|
||||
list[str]: AYON executable paths.
|
||||
|
||||
Raises:
|
||||
(RuntimeError) if no path configured at all
|
||||
RuntimeError: When no path configured at all.
|
||||
|
||||
"""
|
||||
config = RepositoryUtils.GetPluginConfig("Ayon")
|
||||
exe_list = config.GetConfigEntryWithDefault("AyonExecutable", "")
|
||||
|
||||
if not exe_list:
|
||||
raise RuntimeError("Path to Ayon executable not configured."
|
||||
"Please set it in Ayon Deadline Plugin.")
|
||||
raise RuntimeError(
|
||||
"Path to AYON executable not configured."
|
||||
"Please set it in Ayon Deadline Plugin."
|
||||
)
|
||||
|
||||
# clean '\ ' for MacOS pasting
|
||||
if platform.system().lower() == "darwin":
|
||||
|
|
@ -581,8 +586,9 @@ def inject_render_job_id(deadlinePlugin):
|
|||
print(">>> Dependency IDs: {}".format(dependency_ids))
|
||||
render_job_ids = ",".join(dependency_ids)
|
||||
|
||||
deadlinePlugin.SetProcessEnvironmentVariable("RENDER_JOB_IDS",
|
||||
render_job_ids)
|
||||
deadlinePlugin.SetProcessEnvironmentVariable(
|
||||
"RENDER_JOB_IDS", render_job_ids
|
||||
)
|
||||
print(">>> Injection end.")
|
||||
|
||||
|
||||
|
|
@ -591,34 +597,33 @@ def __main__(deadlinePlugin):
|
|||
print(">>> Getting job ...")
|
||||
job = deadlinePlugin.GetJob()
|
||||
|
||||
openpype_render_job = \
|
||||
job.GetJobEnvironmentKeyValue('OPENPYPE_RENDER_JOB') or '0'
|
||||
openpype_publish_job = \
|
||||
job.GetJobEnvironmentKeyValue('OPENPYPE_PUBLISH_JOB') or '0'
|
||||
openpype_remote_job = \
|
||||
job.GetJobEnvironmentKeyValue('OPENPYPE_REMOTE_PUBLISH') or '0'
|
||||
openpype_render_job = job.GetJobEnvironmentKeyValue(
|
||||
"OPENPYPE_RENDER_JOB")
|
||||
openpype_publish_job = job.GetJobEnvironmentKeyValue(
|
||||
"OPENPYPE_PUBLISH_JOB")
|
||||
openpype_remote_job = job.GetJobEnvironmentKeyValue(
|
||||
"OPENPYPE_REMOTE_PUBLISH")
|
||||
|
||||
if openpype_publish_job == '1' and openpype_render_job == '1':
|
||||
raise RuntimeError("Misconfiguration. Job couldn't be both " +
|
||||
"render and publish.")
|
||||
if openpype_publish_job == "1" and openpype_render_job == "1":
|
||||
raise RuntimeError(
|
||||
"Misconfiguration. Job couldn't be both render and publish."
|
||||
)
|
||||
|
||||
if openpype_publish_job == '1':
|
||||
if openpype_publish_job == "1":
|
||||
inject_render_job_id(deadlinePlugin)
|
||||
if openpype_render_job == '1' or openpype_remote_job == '1':
|
||||
if openpype_render_job == "1" or openpype_remote_job == "1":
|
||||
inject_openpype_environment(deadlinePlugin)
|
||||
|
||||
ayon_render_job = \
|
||||
job.GetJobEnvironmentKeyValue('AYON_RENDER_JOB') or '0'
|
||||
ayon_publish_job = \
|
||||
job.GetJobEnvironmentKeyValue('AYON_PUBLISH_JOB') or '0'
|
||||
ayon_remote_job = \
|
||||
job.GetJobEnvironmentKeyValue('AYON_REMOTE_PUBLISH') or '0'
|
||||
ayon_render_job = job.GetJobEnvironmentKeyValue("AYON_RENDER_JOB")
|
||||
ayon_publish_job = job.GetJobEnvironmentKeyValue("AYON_PUBLISH_JOB")
|
||||
ayon_remote_job = job.GetJobEnvironmentKeyValue("AYON_REMOTE_PUBLISH")
|
||||
|
||||
if ayon_publish_job == '1' and ayon_render_job == '1':
|
||||
raise RuntimeError("Misconfiguration. Job couldn't be both " +
|
||||
"render and publish.")
|
||||
if ayon_publish_job == "1" and ayon_render_job == "1":
|
||||
raise RuntimeError(
|
||||
"Misconfiguration. Job couldn't be both render and publish."
|
||||
)
|
||||
|
||||
if ayon_publish_job == '1':
|
||||
if ayon_publish_job == "1":
|
||||
inject_render_job_id(deadlinePlugin)
|
||||
if ayon_render_job == '1' or ayon_remote_job == '1':
|
||||
if ayon_render_job == "1" or ayon_remote_job == "1":
|
||||
inject_ayon_environment(deadlinePlugin)
|
||||
|
|
|
|||
47
client/ayon_core/tools/workfiles/lock_dialog.py
Normal file
47
client/ayon_core/tools/workfiles/lock_dialog.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
from qtpy import QtWidgets, QtCore, QtGui
|
||||
|
||||
from ayon_core.style import load_stylesheet, get_app_icon_path
|
||||
from ayon_core.pipeline.workfile.lock_workfile import get_workfile_lock_data
|
||||
|
||||
|
||||
class WorkfileLockDialog(QtWidgets.QDialog):
|
||||
def __init__(self, workfile_path, parent=None):
|
||||
super(WorkfileLockDialog, self).__init__(parent)
|
||||
self.setWindowTitle("Warning")
|
||||
icon = QtGui.QIcon(get_app_icon_path())
|
||||
self.setWindowIcon(icon)
|
||||
|
||||
data = get_workfile_lock_data(workfile_path)
|
||||
|
||||
message = "{} on {} machine is working on the same workfile.".format(
|
||||
data["username"],
|
||||
data["hostname"]
|
||||
)
|
||||
|
||||
msg_label = QtWidgets.QLabel(message, self)
|
||||
|
||||
btns_widget = QtWidgets.QWidget(self)
|
||||
|
||||
cancel_btn = QtWidgets.QPushButton("Cancel", btns_widget)
|
||||
ignore_btn = QtWidgets.QPushButton("Ignore lock", btns_widget)
|
||||
|
||||
btns_layout = QtWidgets.QHBoxLayout(btns_widget)
|
||||
btns_layout.setContentsMargins(0, 0, 0, 0)
|
||||
btns_layout.setSpacing(10)
|
||||
btns_layout.addStretch(1)
|
||||
btns_layout.addWidget(cancel_btn, 0)
|
||||
btns_layout.addWidget(ignore_btn, 0)
|
||||
|
||||
main_layout = QtWidgets.QVBoxLayout(self)
|
||||
main_layout.setContentsMargins(15, 15, 15, 15)
|
||||
main_layout.addWidget(msg_label, 1, QtCore.Qt.AlignCenter),
|
||||
main_layout.addSpacing(10)
|
||||
main_layout.addWidget(btns_widget, 0)
|
||||
|
||||
cancel_btn.clicked.connect(self.reject)
|
||||
ignore_btn.clicked.connect(self.accept)
|
||||
|
||||
def showEvent(self, event):
|
||||
super(WorkfileLockDialog, self).showEvent(event)
|
||||
|
||||
self.setStyleSheet(load_stylesheet())
|
||||
Loading…
Add table
Add a link
Reference in a new issue