diff --git a/client/ayon_core/host/host.py b/client/ayon_core/host/host.py index 5e5e8ac79f..45123d74a8 100644 --- a/client/ayon_core/host/host.py +++ b/client/ayon_core/host/host.py @@ -158,9 +158,7 @@ class HostBase(ABC): task_entity: dict[str, Any], *, reason: Optional[str] = None, - workdir: Optional[str] = None, project_entity: Optional[dict[str, Any]] = None, - project_settings: Optional[dict[str, Any]] = None, anatomy: Optional["Anatomy"] = None, ): """Set current context information. @@ -178,9 +176,7 @@ class HostBase(ABC): folder_entity (Optional[dict[str, Any]]): Folder entity. task_entity (Optional[dict[str, Any]]): Task entity. reason (Optional[str]): Reason for context change. - workdir (Optional[str]): Work directory path. project_entity (Optional[dict[str, Any]]): Project entity data. - project_settings (Optional[dict[str, Any]]): Project settings data. anatomy (Optional[Anatomy]): Anatomy instance for the project. """ @@ -208,24 +204,22 @@ class HostBase(ABC): project_entity, folder_entity, task_entity, - anatomy, reason, + anatomy, ) self._set_current_context( project_entity, folder_entity, task_entity, reason, - workdir, anatomy, - project_settings, ) self._after_context_change( project_entity, folder_entity, task_entity, - anatomy, reason, + anatomy, ) return self._emit_context_change_event( @@ -309,10 +303,22 @@ class HostBase(ABC): folder_entity: Optional[dict[str, Any]], task_entity: Optional[dict[str, Any]], reason: Optional[str], - workdir: Optional[str], - anatomy: Optional["Anatomy"], - project_settings: Optional[dict[str, Any]], + anatomy: "Anatomy", ): + """Method that changes the context in host. + + Can be overriden for hosts that do need different handling of context + than using environment variables. + + Args: + project_entity (dict[str, Any]): Project entity. + folder_entity (dict[str, Any]): Folder entity of new context. + task_entity (dict[str, Any]): Task entity of new context. + reason (Optional[str]): Reason why change happened. Currently + known reasons are that workfile is being opened or saved. + anatomy (Anatomy): Project anatomy. + + """ from ayon_core.pipeline.workfile import get_workdir project_name = self.get_current_project_name() @@ -323,28 +329,10 @@ class HostBase(ABC): if task_entity: task_name = task_entity["name"] - if ( - workdir is None - and isinstance(self, IWorkfileHost) - and folder_entity - ): - if project_entity is None: - project_entity = ayon_api.get_project(project_name) - - workdir = get_workdir( - project_entity, - folder_entity, - task_entity, - self.name, - anatomy=anatomy, - project_settings=project_settings, - ) - envs = { "AYON_PROJECT_NAME": project_name, "AYON_FOLDER_PATH": folder_path, "AYON_TASK_NAME": task_name, - "AYON_WORKDIR": workdir, } # Update the Session and environments. Pop from environments all @@ -360,8 +348,8 @@ class HostBase(ABC): project_entity: dict[str, Any], folder_entity: Optional[dict[str, Any]], task_entity: Optional[dict[str, Any]], - anatomy: "Anatomy", reason: Optional[str], + anatomy: "Anatomy", ): """Before context is changed. @@ -382,8 +370,8 @@ class HostBase(ABC): project_entity: dict[str, Any], folder_entity: dict[str, Any], task_entity: dict[str, Any], - anatomy: "Anatomy", reason: Optional[str], + anatomy: "Anatomy", ): """After context is changed. diff --git a/client/ayon_core/host/interfaces/workfiles.py b/client/ayon_core/host/interfaces/workfiles.py index ab61e608f8..97f71690f5 100644 --- a/client/ayon_core/host/interfaces/workfiles.py +++ b/client/ayon_core/host/interfaces/workfiles.py @@ -326,9 +326,7 @@ class IWorkfileHost: folder_entity, task_entity, reason=WORKFILE_SAVE_REASON, - workdir=workdir, project_entity=project_entity, - project_settings=project_settings, anatomy=anatomy, ) @@ -398,9 +396,7 @@ class IWorkfileHost: folder_entity, task_entity, reason=WORKFILE_OPEN_REASON, - workdir=workdir, project_entity=project_entity, - project_settings=project_settings, anatomy=anatomy, ) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index c51f0ad0d9..5043902b67 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -524,11 +524,11 @@ def change_current_context( This updates the live Session to a different task under folder. Notes: - This function does a lot of things related to workfiles which + * This function does a lot of things related to workfiles which extends arguments options a lot. - We might want to implement 'set_current_context' on host integration + * We might want to implement 'set_current_context' on host integration instead. But `AYON_WORKDIR`, which is related to 'IWorkfileHost', - would not be available in that case which might be break some + would not be available in that case which might break some logic. Args: @@ -572,9 +572,8 @@ def change_current_context( folder_entity, task_entity, reason=reason, - anatomy=anatomy, project_entity=project_entity, - project_settings=project_settings, + anatomy=anatomy, )