Applications: Launch hooks cleanup (#5395)

* ApplicationManager can have more granular way how applications are launched

* executable is optional to be able create ApplicationLaunchContext

* launch context can run prelaunch hooks without launching application

* 'get_app_environments_for_context' is using launch context to prepare environments

* added 'launch_type' as one of filtering options for LaunchHook

* added 'local' launch type filter to existing launch hooks

* define 'automated' launch type in remote publish function

* modified publish and extract environments cli commands

* launch types are only for local by default

* fix import

* fix launch types of global host data

* change order or kwargs

* change unreal filter attribute

* use set instead of list

* removed '__init__' from celaction hooks

* use 'CELACTION_ROOT_DIR' in pre setup

* use full import from applications
This commit is contained in:
Jakub Trllo 2023-08-03 12:24:23 +02:00 committed by GitHub
parent 5da9e65975
commit 3ae020f064
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 37 additions and 42 deletions

View file

@ -13,7 +13,7 @@ class AddLastWorkfileToLaunchArgs(PreLaunchHook):
# Execute after workfile template copy
order = 10
app_groups = [
app_groups = {
"3dsmax",
"maya",
"nuke",
@ -26,8 +26,8 @@ class AddLastWorkfileToLaunchArgs(PreLaunchHook):
"photoshop",
"tvpaint",
"substancepainter",
"aftereffects"
]
"aftereffects",
}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -19,7 +19,7 @@ class CopyTemplateWorkfile(PreLaunchHook):
# Before `AddLastWorkfileToLaunchArgs`
order = 0
app_groups = ["blender", "photoshop", "tvpaint", "aftereffects"]
app_groups = {"blender", "photoshop", "tvpaint", "aftereffects"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -13,8 +13,8 @@ class LaunchFoundryAppsWindows(PreLaunchHook):
# Should be as last hook because must change launch arguments to string
order = 1000
app_groups = ["nuke", "nukeassist", "nukex", "hiero", "nukestudio"]
platforms = ["windows"]
app_groups = {"nuke", "nukeassist", "nukex", "hiero", "nukestudio"}
platforms = {"windows"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -12,7 +12,7 @@ class LaunchWithTerminal(PreLaunchHook):
"""
order = 1000
platforms = ["darwin"]
platforms = {"darwin"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -17,7 +17,7 @@ class NonPythonHostHook(PreLaunchHook):
python script which launch the host. For these cases it is necessary to
prepend python (or openpype) executable and script path before application's.
"""
app_groups = ["harmony", "photoshop", "aftereffects"]
app_groups = {"harmony", "photoshop", "aftereffects"}
order = 20
launch_types = {LaunchTypes.local}

View file

@ -1,8 +1,6 @@
from openpype.lib import PreLaunchHook
from openpype.lib.applications import PreLaunchHook
from openpype.pipeline.colorspace import (
get_imageio_config
)
from openpype.pipeline.colorspace import get_imageio_config
from openpype.pipeline.template_data import get_template_data_with_names
@ -10,7 +8,7 @@ class OCIOEnvHook(PreLaunchHook):
"""Set OCIO environment variable for hosts that use OpenColorIO."""
order = 0
hosts = [
hosts = {
"substancepainter",
"fusion",
"blender",
@ -20,8 +18,8 @@ class OCIOEnvHook(PreLaunchHook):
"maya",
"nuke",
"hiero",
"resolve"
]
"resolve",
}
launch_types = set()
def execute(self):

View file

@ -13,8 +13,8 @@ class BlenderConsoleWindows(PreLaunchHook):
# Should be as last hook because must change launch arguments to string
order = 1000
app_groups = ["blender"]
platforms = ["windows"]
app_groups = {"blender"}
platforms = {"windows"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -4,19 +4,15 @@ import winreg
import subprocess
from openpype.lib import get_openpype_execute_args
from openpype.lib.applications import PreLaunchHook, LaunchTypes
from openpype.hosts.celaction import scripts
CELACTION_SCRIPTS_DIR = os.path.dirname(
os.path.abspath(scripts.__file__)
)
from openpype.hosts.celaction import CELACTION_ROOT_DIR
class CelactionPrelaunchHook(PreLaunchHook):
"""
Bootstrap celacion with pype
"""
app_groups = ["celaction"]
platforms = ["windows"]
app_groups = {"celaction"}
platforms = {"windows"}
launch_types = {LaunchTypes.local}
def execute(self):
@ -39,7 +35,9 @@ class CelactionPrelaunchHook(PreLaunchHook):
winreg.KEY_ALL_ACCESS
)
path_to_cli = os.path.join(CELACTION_SCRIPTS_DIR, "publish_cli.py")
path_to_cli = os.path.join(
CELACTION_ROOT_DIR, "scripts", "publish_cli.py"
)
subprocess_args = get_openpype_execute_args("run", path_to_cli)
openpype_executable = subprocess_args.pop(0)
workfile_settings = self.get_workfile_settings()
@ -124,9 +122,8 @@ class CelactionPrelaunchHook(PreLaunchHook):
if not os.path.exists(workfile_path):
# TODO add ability to set different template workfile path via
# settings
openpype_celaction_dir = os.path.dirname(CELACTION_SCRIPTS_DIR)
template_path = os.path.join(
openpype_celaction_dir,
CELACTION_ROOT_DIR,
"resources",
"celaction_template_scene.scn"
)

View file

@ -19,7 +19,7 @@ class FlamePrelaunch(PreLaunchHook):
Will make sure flame_script_dirs are copied to user's folder defined
in environment var FLAME_SCRIPT_DIR.
"""
app_groups = ["flame"]
app_groups = {"flame"}
permissions = 0o777
wtc_script_path = os.path.join(

View file

@ -25,7 +25,7 @@ class FusionCopyPrefsPrelaunch(PreLaunchHook):
Master.prefs is defined in openpype/hosts/fusion/deploy/fusion_shared.prefs
"""
app_groups = ["fusion"]
app_groups = {"fusion"}
order = 2
launch_types = {LaunchTypes.local}

View file

@ -21,7 +21,7 @@ class FusionPrelaunch(PreLaunchHook):
Fusion 18 : Python 3.6 - 3.10
"""
app_groups = ["fusion"]
app_groups = {"fusion"}
order = 1
launch_types = {LaunchTypes.local}

View file

@ -6,7 +6,7 @@ class SetPath(PreLaunchHook):
Hook `GlobalHostDataHook` must be executed before this hook.
"""
app_groups = ["houdini"]
app_groups = {"houdini"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -14,7 +14,7 @@ class ForceStartupScript(PreLaunchHook):
Hook `GlobalHostDataHook` must be executed before this hook.
"""
app_groups = ["3dsmax"]
app_groups = {"3dsmax"}
order = 11
launch_types = {LaunchTypes.local}

View file

@ -13,7 +13,7 @@ class InjectPythonPath(PreLaunchHook):
Hook `GlobalHostDataHook` must be executed before this hook.
"""
app_groups = ["3dsmax"]
app_groups = {"3dsmax"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -6,7 +6,7 @@ class SetPath(PreLaunchHook):
Hook `GlobalHostDataHook` must be executed before this hook.
"""
app_groups = ["max"]
app_groups = {"max"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -6,7 +6,7 @@ class MayaPreAutoLoadPlugins(PreLaunchHook):
# Before AddLastWorkfileToLaunchArgs
order = 9
app_groups = ["maya"]
app_groups = {"maya"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -7,7 +7,7 @@ class PreCopyMel(PreLaunchHook):
Hook `GlobalHostDataHook` must be executed before this hook.
"""
app_groups = ["maya"]
app_groups = {"maya"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -6,7 +6,7 @@ class MayaPreOpenWorkfilePostInitialization(PreLaunchHook):
# Before AddLastWorkfileToLaunchArgs.
order = 9
app_groups = ["maya"]
app_groups = {"maya"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -5,7 +5,7 @@ class PrelaunchNukeAssistHook(PreLaunchHook):
"""
Adding flag when nukeassist
"""
app_groups = ["nukeassist"]
app_groups = {"nukeassist"}
launch_types = set()
def execute(self):

View file

@ -9,7 +9,7 @@ class PreLaunchResolveLastWorkfile(PreLaunchHook):
workfile. This property is set explicitly in Launcher.
"""
order = 10
app_groups = ["resolve"]
app_groups = {"resolve"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -30,7 +30,7 @@ class PreLaunchResolveSetup(PreLaunchHook):
"""
app_groups = ["resolve"]
app_groups = {"resolve"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -9,7 +9,7 @@ class PreLaunchResolveStartup(PreLaunchHook):
"""
order = 11
app_groups = ["resolve"]
app_groups = {"resolve"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -11,7 +11,7 @@ class TvpaintPrelaunchHook(PreLaunchHook):
Existence of last workfile is checked. If workfile does not exists tries
to copy templated workfile from predefined path.
"""
app_groups = ["tvpaint"]
app_groups = {"tvpaint"}
launch_types = {LaunchTypes.local}
def execute(self):