From 3323c298088c23c94f07aa5f6b35785e36810474 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:24:40 +0100 Subject: [PATCH] added collector to collect farm env variables --- .../publish/collect_farm_env_variables.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 client/ayon_ftrack/plugins/publish/collect_farm_env_variables.py diff --git a/client/ayon_ftrack/plugins/publish/collect_farm_env_variables.py b/client/ayon_ftrack/plugins/publish/collect_farm_env_variables.py new file mode 100644 index 00000000..ac9c67ea --- /dev/null +++ b/client/ayon_ftrack/plugins/publish/collect_farm_env_variables.py @@ -0,0 +1,30 @@ +import os + +import pyblish.api + +try: + from ayon_core.pipeline.publish import FARM_JOB_ENV_DATA_KEY +except ImportError: + # NOTE Can be removed when ayon-core >= 1.0.10 is required in package.py + FARM_JOB_ENV_DATA_KEY = "farmJobEnv" + + +class CollectFtrackJobEnvVars(pyblish.api.ContextPlugin): + """Collect set of environment variables to submit with deadline jobs""" + order = pyblish.api.CollectorOrder - 0.45 + label = "Collect ftrack farm environment variables" + targets = ["local"] + + def process(self, context): + env = context.data.setdefault(FARM_JOB_ENV_DATA_KEY, {}) + + # Disable colored logs on farm + for key in [ + "FTRACK_SERVER", + "FTRACK_API_USER", + "FTRACK_API_KEY", + ]: + value = os.getenv(key) + if value: + self.log.debug(f"Setting job env: {key}: {value}") + env[key] = value