diff --git a/openpype/hosts/testhost/api/__init__.py b/openpype/hosts/testhost/api/__init__.py
index 1a5423be61..7840b25892 100644
--- a/openpype/hosts/testhost/api/__init__.py
+++ b/openpype/hosts/testhost/api/__init__.py
@@ -10,7 +10,8 @@ from .pipeline import (
update_instances,
remove_instances,
get_context_data,
- update_context_data
+ update_context_data,
+ get_context_title
)
@@ -36,6 +37,7 @@ __all__ = (
"remove_instances",
"get_context_data",
"update_context_data",
+ "get_context_title",
"install"
)
diff --git a/openpype/hosts/testhost/api/pipeline.py b/openpype/hosts/testhost/api/pipeline.py
index 063b90fbcc..442c6eeba0 100644
--- a/openpype/hosts/testhost/api/pipeline.py
+++ b/openpype/hosts/testhost/api/pipeline.py
@@ -7,6 +7,33 @@ class HostContext:
instances_json_path = None
context_json_path = None
+ @classmethod
+ def get_context_title(cls):
+ project_name = os.environ.get("AVALON_PROJECT")
+ if not project_name:
+ return "TestHost"
+
+ asset_name = os.environ.get("AVALON_ASSET")
+ if not asset_name:
+ return project_name
+
+ from avalon import io
+
+ asset_doc = io.find_one(
+ {"type": "asset", "name": asset_name},
+ {"data.parents": 1}
+ )
+ parents = asset_doc.get("data", {}).get("parents") or []
+
+ hierarchy = [project_name]
+ hierarchy.extend(parents)
+ hierarchy.append("{}".format(asset_name))
+ task_name = os.environ.get("AVALON_TASK")
+ if task_name:
+ hierarchy.append(task_name)
+
+ return "/".join(hierarchy)
+
@classmethod
def get_current_dir_filepath(cls, filename):
return os.path.join(
@@ -124,3 +151,7 @@ def get_context_data():
def update_context_data(data, changes):
HostContext.save_context_data(data)
+
+
+def get_context_title():
+ return HostContext.get_context_title()
diff --git a/openpype/tools/new_publisher/control.py b/openpype/tools/new_publisher/control.py
index e6f642dbba..5780f086fe 100644
--- a/openpype/tools/new_publisher/control.py
+++ b/openpype/tools/new_publisher/control.py
@@ -1,3 +1,4 @@
+import os
import copy
import logging
import traceback
@@ -430,6 +431,18 @@ class PublisherController:
def get_asset_docs(self):
return self._asset_docs_cache.get_asset_docs()
+ def get_context_title(self):
+ context_title = None
+ if hasattr(self.host, "get_context_title"):
+ context_title = self.host.get_context_title()
+
+ if context_title is None:
+ context_title = os.environ.get("AVALON_APP_NAME")
+ if context_title is None:
+ context_title = os.environ.get("AVALON_APP")
+
+ return context_title
+
def get_asset_hierarchy(self):
_queue = collections.deque(self.get_asset_docs())
diff --git a/openpype/tools/new_publisher/window.py b/openpype/tools/new_publisher/window.py
index b65a0f9094..e365b22362 100644
--- a/openpype/tools/new_publisher/window.py
+++ b/openpype/tools/new_publisher/window.py
@@ -245,11 +245,6 @@ class PublisherWindow(QtWidgets.QDialog):
self.resize(self.default_width, self.default_height)
- # DEBUGING
- self.set_context_label(
- "////"
- )
-
def showEvent(self, event):
super(PublisherWindow, self).showEvent(event)
if self._first_show:
@@ -384,6 +379,9 @@ class PublisherWindow(QtWidgets.QDialog):
self._validate_create_instances()
+ context_title = self.controller.get_context_title()
+ self.set_context_label(context_title)
+
def _on_subset_change(self, *_args):
# Ignore changes if in middle of refreshing
if self._refreshing_instances: