Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AYON prefix in context environment variables #33

Merged
merged 8 commits into from
Feb 15, 2024
Merged
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
16 changes: 15 additions & 1 deletion client/ayon_core/cli_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ def publish(paths, targets=None, gui=False):
import pyblish.api
import pyblish.util

# Fix older jobs
for src_key, dst_key in (
("AVALON_PROJECT", "AYON_PROJECT_NAME"),
("AVALON_ASSET", "AYON_FOLDER_PATH"),
("AVALON_TASK", "AYON_TASK_NAME"),
("AVALON_WORKDIR", "AYON_WORKDIR"),
("AVALON_APP_NAME", "AYON_APP_NAME"),
("AVALON_APP", "AYON_HOST_NAME"),
):
if src_key in os.environ and dst_key not in os.environ:
os.environ[dst_key] = os.environ[src_key]
iLLiCiTiT marked this conversation as resolved.
Show resolved Hide resolved
# Remove old keys, so we're sure they're not used
os.environ.pop(src_key, None)

log = Logger.get_logger("CLI-publish")

install_ayon_plugins()
Expand All @@ -87,7 +101,7 @@ def publish(paths, targets=None, gui=False):
if not any(paths):
raise RuntimeError("No publish paths specified")

app_full_name = os.getenv("AVALON_APP_NAME")
app_full_name = os.getenv("AYON_APP_NAME")
if app_full_name:
context = get_global_context()
env = get_app_environments_for_context(
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hooks/pre_create_extra_workdir_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def execute(self):
return

env = self.data.get("env") or {}
workdir = env.get("AVALON_WORKDIR")
workdir = env.get("AYON_WORKDIR")
if not workdir or not os.path.exists(workdir):
return

Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/host/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,23 @@ def get_current_project_name(self):
Union[str, None]: Current project name.
"""

return os.environ.get("AVALON_PROJECT")
return os.environ.get("AYON_PROJECT_NAME")

def get_current_asset_name(self):
"""
Returns:
Union[str, None]: Current asset name.
"""

return os.environ.get("AVALON_ASSET")
return os.environ.get("AYON_FOLDER_PATH")

def get_current_task_name(self):
"""
Returns:
Union[str, None]: Current task name.
"""

return os.environ.get("AVALON_TASK")
return os.environ.get("AYON_TASK_NAME")

def get_current_context(self):
"""Get current context information.
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/host/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def work_root(self, session):
str: Path to new workdir.
"""

return session["AVALON_WORKDIR"]
return session["AYON_WORKDIR"]

# --- Deprecated method names ---
def file_extensions(self):
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/hosts/aftereffects/api/launch_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,11 @@ async def set_context(self, project, asset, task):
log.info("Setting context change")
log.info("project {} asset {} ".format(project, asset))
if project:
os.environ["AVALON_PROJECT"] = project
os.environ["AYON_PROJECT_NAME"] = project
if asset:
os.environ["AVALON_ASSET"] = asset
os.environ["AYON_FOLDER_PATH"] = asset
if task:
os.environ["AVALON_TASK"] = task
os.environ["AYON_TASK_NAME"] = task

async def read(self):
log.debug("aftereffects.read client calls server server calls "
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/hosts/blender/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def set_resolution(data):


def on_new():
project = os.environ.get("AVALON_PROJECT")
project = os.environ.get("AYON_PROJECT_NAME")
settings = get_project_settings(project).get("blender")

set_resolution_startup = settings.get("set_resolution_startup")
Expand All @@ -293,7 +293,7 @@ def on_new():


def on_open():
project = os.environ.get("AVALON_PROJECT")
project = os.environ.get("AYON_PROJECT_NAME")
settings = get_project_settings(project).get("blender")

set_resolution_startup = settings.get("set_resolution_startup")
Expand Down Expand Up @@ -379,7 +379,7 @@ def _on_task_changed():
# `directory` attribute, so it opens in that directory (does it?).
# https://docs.blender.org/api/blender2.8/bpy.types.Operator.html#calling-a-file-selector
# https://docs.blender.org/api/blender2.8/bpy.types.WindowManager.html#bpy.types.WindowManager.fileselect_add
workdir = os.getenv("AVALON_WORKDIR")
workdir = os.getenv("AYON_WORKDIR")
log.debug("New working directory: %s", workdir)


Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/blender/api/workio.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def file_extensions() -> List[str]:
def work_root(session: dict) -> str:
"""Return the default root to browse for work files."""

work_dir = session["AVALON_WORKDIR"]
work_dir = session["AYON_WORKDIR"]
scene_dir = session.get("AVALON_SCENEDIR")
if scene_dir:
return str(Path(work_dir, scene_dir))
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/flame/api/workio.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ def current_file():


def work_root(session):
return os.path.normpath(session["AVALON_WORKDIR"]).replace("\\", "/")
return os.path.normpath(session["AYON_WORKDIR"]).replace("\\", "/")
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/flame/plugins/load/load_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def load(self, context, name, namespace, options):
self.log.info("Loading with colorspace: `{}`".format(colorspace))

# create workfile path
workfile_dir = os.environ["AVALON_WORKDIR"]
workfile_dir = os.environ["AYON_WORKDIR"]
openclip_dir = os.path.join(
workfile_dir, clip_name
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def load(self, context, name, namespace, options):
self.log.info("Loading with colorspace: `{}`".format(colorspace))

# create workfile path
workfile_dir = options.get("workdir") or os.environ["AVALON_WORKDIR"]
workfile_dir = options.get("workdir") or os.environ["AYON_WORKDIR"]
openclip_dir = os.path.join(
workfile_dir, clip_name
)
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/fusion/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_fusion_version(app_name):
The function is triggered by the prelaunch hooks to get the fusion version.

`app_name` is obtained by prelaunch hooks from the
`launch_context.env.get("AVALON_APP_NAME")`.
`launch_context.env.get("AYON_APP_NAME")`.

To get a correct Fusion version, a version number should be present
in the `applications/fusion/variants` key
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/fusion/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def get_current_workfile(self):
return current_filepath

def work_root(self, session):
work_dir = session["AVALON_WORKDIR"]
work_dir = session["AYON_WORKDIR"]
scene_dir = session.get("AVALON_SCENEDIR")
if scene_dir:
return os.path.join(work_dir, scene_dir)
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/fusion/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _configure_saver_tool(self, data, tool, subset):
ext = data["creator_attributes"]["image_format"]

# Subset change detected
workdir = os.path.normpath(os.getenv("AVALON_WORKDIR"))
workdir = os.path.normpath(os.getenv("AYON_WORKDIR"))
formatting_data.update({
"workdir": workdir,
"frame": "0" * frame_padding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def execute(self):
) = self.get_copy_fusion_prefs_settings()

# Get launched application context and return correct app version
app_name = self.launch_context.env.get("AVALON_APP_NAME")
app_name = self.launch_context.env.get("AYON_APP_NAME")
app_version = get_fusion_version(app_name)
if app_version is None:
version_names = ", ".join(str(x) for x in FUSION_VERSIONS_DICT)
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/fusion/hooks/pre_fusion_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FusionPrelaunch(PreLaunchHook):
def execute(self):
# making sure python 3 is installed at provided path
# Py 3.3-3.10 for Fusion 18+ or Py 3.6 for Fu 16-17
app_data = self.launch_context.env.get("AVALON_APP_NAME")
app_data = self.launch_context.env.get("AYON_APP_NAME")
app_version = get_fusion_version(app_data)
if not app_version:
raise ApplicationLaunchFailed(
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/harmony/api/workio.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ def current_file():


def work_root(session):
return os.path.normpath(session["AVALON_WORKDIR"]).replace("\\", "/")
return os.path.normpath(session["AYON_WORKDIR"]).replace("\\", "/")
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def process(self, instance):
expected_settings.pop("resolutionWidth")
expected_settings.pop("resolutionHeight")

if (any(re.search(pattern, os.getenv('AVALON_TASK'))
if (any(re.search(pattern, os.getenv('AYON_TASK_NAME'))
for pattern in self.skip_timelines_check)):
self.log.info("Skipping frames check because of "
"task name and pattern {}".format(
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/hiero/api/workio.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ def current_file():


def work_root(session):
return os.path.normpath(session["AVALON_WORKDIR"]).replace("\\", "/")
return os.path.normpath(session["AYON_WORKDIR"]).replace("\\", "/")
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/houdini/hooks/set_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SetPath(PreLaunchHook):
launch_types = {LaunchTypes.local}

def execute(self):
workdir = self.launch_context.env.get("AVALON_WORKDIR", "")
workdir = self.launch_context.env.get("AYON_WORKDIR", "")
if not workdir:
self.log.warning("BUG: Workdir is not filled.")
return
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/max/hooks/set_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SetPath(PreLaunchHook):
launch_types = {LaunchTypes.local}

def execute(self):
workdir = self.launch_context.env.get("AVALON_WORKDIR", "")
workdir = self.launch_context.env.get("AYON_WORKDIR", "")
if not workdir:
self.log.warning("BUG: Workdir is not filled.")
return
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/hosts/maya/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def _set_project():
None

"""
workdir = os.getenv("AVALON_WORKDIR")
workdir = os.getenv("AYON_WORKDIR")

try:
os.makedirs(workdir)
Expand Down Expand Up @@ -628,7 +628,7 @@ def on_task_changed():
# Run
menu.update_menu_task_label()

workdir = os.getenv("AVALON_WORKDIR")
workdir = os.getenv("AYON_WORKDIR")
if os.path.exists(workdir):
log.info("Updating Maya workspace for task change to %s", workdir)
_set_project()
Expand Down Expand Up @@ -677,7 +677,7 @@ def workfile_save_before_xgen(event):

import xgenm

current_work_dir = os.getenv("AVALON_WORKDIR").replace("\\", "/")
current_work_dir = os.getenv("AYON_WORKDIR").replace("\\", "/")
expected_work_dir = event.data["workdir_path"].replace("\\", "/")
if current_work_dir == expected_work_dir:
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


DEFINITION_FILENAME = "{}/maya/shader_definition.txt".format(
os.getenv("AVALON_PROJECT"))
os.getenv("AYON_PROJECT_NAME"))


class ShaderDefinitionsEditor(QtWidgets.QWidget):
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/maya/api/workio.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def current_file():


def work_root(session):
work_dir = session["AVALON_WORKDIR"]
work_dir = session["AYON_WORKDIR"]
scene_dir = None

# Query scene file rule from workspace.mel if it exists in WORKDIR
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/maya/hooks/pre_copy_mel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PreCopyMel(PreLaunchHook):

def execute(self):
project_doc = self.data["project_doc"]
workdir = self.launch_context.env.get("AVALON_WORKDIR")
workdir = self.launch_context.env.get("AYON_WORKDIR")
if not workdir:
self.log.warning("BUG: Workdir is not filled.")
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
Requires:
instance -> families
instance -> setMembers
instance -> asset

context -> currentFile
context -> workspaceDir
context -> user

session -> AVALON_ASSET

Optional:

Provides:
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/maya/startup/userSetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _explicit_load_plugins():
key = "AYON_OPEN_WORKFILE_POST_INITIALIZATION"
if bool(int(os.environ.get(key, "0"))):
def _log_and_open():
path = os.environ["AVALON_LAST_WORKFILE"]
path = os.environ["AYON_LAST_WORKFILE"]
print("Opening \"{}\"".format(path))
cmds.file(path, open=True, force=True)
cmds.evalDeferred(
Expand Down
8 changes: 4 additions & 4 deletions client/ayon_core/hosts/nuke/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def wrapper(*args, **kwargs):
class Context:
main_window = None
context_action_item = None
project_name = os.getenv("AVALON_PROJECT")
project_name = os.getenv("AYON_PROJECT_NAME")
# Workfile related code
workfiles_launched = False
workfiles_tool_timer = None
Expand Down Expand Up @@ -2605,7 +2605,7 @@ def set_context_settings(self):
def set_favorites(self):
from .utils import set_context_favorites

work_dir = os.getenv("AVALON_WORKDIR")
work_dir = os.getenv("AYON_WORKDIR")
asset = get_current_asset_name()
favorite_items = OrderedDict()

Expand Down Expand Up @@ -2953,7 +2953,7 @@ def process_workfile_builder():
create_fv_on = workfile_builder.get("create_first_version") or None
builder_on = workfile_builder.get("builder_on_start") or None

last_workfile_path = os.environ.get("AVALON_LAST_WORKFILE")
last_workfile_path = os.environ.get("AYON_LAST_WORKFILE")

# generate first version in file not existing and feature is enabled
if create_fv_on and not os.path.exists(last_workfile_path):
Expand Down Expand Up @@ -3203,7 +3203,7 @@ class DirmapCache:
@classmethod
def project_name(cls):
if cls._project_name is None:
cls._project_name = os.getenv("AVALON_PROJECT")
cls._project_name = os.getenv("AYON_PROJECT_NAME")
return cls._project_name

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/nuke/api/workio.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def current_file():

def work_root(session):

work_dir = session["AVALON_WORKDIR"]
work_dir = session["AYON_WORKDIR"]
scene_dir = session.get("AVALON_SCENEDIR")
if scene_dir:
path = os.path.join(work_dir, scene_dir)
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/nuke/startup/custom_write_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def process(self):
for write_node in write_selected_nodes:
# data for mapping the path
data = {
"work": os.getenv("AVALON_WORKDIR"),
"work": os.getenv("AYON_WORKDIR"),
"subset": write_node["name"].value(),
"frame": "#" * frame_padding,
"ext": ext
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/photoshop/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def current_file(self):
return None

def work_root(self, session):
return os.path.normpath(session["AVALON_WORKDIR"]).replace("\\", "/")
return os.path.normpath(session["AYON_WORKDIR"]).replace("\\", "/")

def open_workfile(self, filepath):
lib.stub().open(filepath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def process(self, context):
assert os.path.exists(batch_dir), \
"Folder {} doesn't exist".format(batch_dir)

project_name = os.environ.get("AVALON_PROJECT")
project_name = os.environ.get("AYON_PROJECT_NAME")
if project_name is None:
raise AssertionError(
"Environment `AVALON_PROJECT` was not found."
"Environment `AYON_PROJECT_NAME` was not found."
"Could not set project `root` which may cause issues."
)

Expand All @@ -68,8 +68,8 @@ def process(self, context):
batch_data["context"]
)

os.environ["AVALON_ASSET"] = asset_name
os.environ["AVALON_TASK"] = task_name
os.environ["AYON_FOLDER_PATH"] = asset_name
os.environ["AYON_TASK_NAME"] = task_name

context.data["asset"] = asset_name
context.data["task"] = task_name
Expand Down
Loading