mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
removed unnecessary workdir handling from set current context
This commit is contained in:
parent
e6bb395d67
commit
524ed03423
3 changed files with 23 additions and 40 deletions
|
|
@ -158,9 +158,7 @@ class HostBase(ABC):
|
||||||
task_entity: dict[str, Any],
|
task_entity: dict[str, Any],
|
||||||
*,
|
*,
|
||||||
reason: Optional[str] = None,
|
reason: Optional[str] = None,
|
||||||
workdir: Optional[str] = None,
|
|
||||||
project_entity: Optional[dict[str, Any]] = None,
|
project_entity: Optional[dict[str, Any]] = None,
|
||||||
project_settings: Optional[dict[str, Any]] = None,
|
|
||||||
anatomy: Optional["Anatomy"] = None,
|
anatomy: Optional["Anatomy"] = None,
|
||||||
):
|
):
|
||||||
"""Set current context information.
|
"""Set current context information.
|
||||||
|
|
@ -178,9 +176,7 @@ class HostBase(ABC):
|
||||||
folder_entity (Optional[dict[str, Any]]): Folder entity.
|
folder_entity (Optional[dict[str, Any]]): Folder entity.
|
||||||
task_entity (Optional[dict[str, Any]]): Task entity.
|
task_entity (Optional[dict[str, Any]]): Task entity.
|
||||||
reason (Optional[str]): Reason for context change.
|
reason (Optional[str]): Reason for context change.
|
||||||
workdir (Optional[str]): Work directory path.
|
|
||||||
project_entity (Optional[dict[str, Any]]): Project entity data.
|
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.
|
anatomy (Optional[Anatomy]): Anatomy instance for the project.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
@ -208,24 +204,22 @@ class HostBase(ABC):
|
||||||
project_entity,
|
project_entity,
|
||||||
folder_entity,
|
folder_entity,
|
||||||
task_entity,
|
task_entity,
|
||||||
anatomy,
|
|
||||||
reason,
|
reason,
|
||||||
|
anatomy,
|
||||||
)
|
)
|
||||||
self._set_current_context(
|
self._set_current_context(
|
||||||
project_entity,
|
project_entity,
|
||||||
folder_entity,
|
folder_entity,
|
||||||
task_entity,
|
task_entity,
|
||||||
reason,
|
reason,
|
||||||
workdir,
|
|
||||||
anatomy,
|
anatomy,
|
||||||
project_settings,
|
|
||||||
)
|
)
|
||||||
self._after_context_change(
|
self._after_context_change(
|
||||||
project_entity,
|
project_entity,
|
||||||
folder_entity,
|
folder_entity,
|
||||||
task_entity,
|
task_entity,
|
||||||
anatomy,
|
|
||||||
reason,
|
reason,
|
||||||
|
anatomy,
|
||||||
)
|
)
|
||||||
|
|
||||||
return self._emit_context_change_event(
|
return self._emit_context_change_event(
|
||||||
|
|
@ -309,10 +303,22 @@ class HostBase(ABC):
|
||||||
folder_entity: Optional[dict[str, Any]],
|
folder_entity: Optional[dict[str, Any]],
|
||||||
task_entity: Optional[dict[str, Any]],
|
task_entity: Optional[dict[str, Any]],
|
||||||
reason: Optional[str],
|
reason: Optional[str],
|
||||||
workdir: Optional[str],
|
anatomy: "Anatomy",
|
||||||
anatomy: Optional["Anatomy"],
|
|
||||||
project_settings: Optional[dict[str, Any]],
|
|
||||||
):
|
):
|
||||||
|
"""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
|
from ayon_core.pipeline.workfile import get_workdir
|
||||||
|
|
||||||
project_name = self.get_current_project_name()
|
project_name = self.get_current_project_name()
|
||||||
|
|
@ -323,28 +329,10 @@ class HostBase(ABC):
|
||||||
if task_entity:
|
if task_entity:
|
||||||
task_name = task_entity["name"]
|
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 = {
|
envs = {
|
||||||
"AYON_PROJECT_NAME": project_name,
|
"AYON_PROJECT_NAME": project_name,
|
||||||
"AYON_FOLDER_PATH": folder_path,
|
"AYON_FOLDER_PATH": folder_path,
|
||||||
"AYON_TASK_NAME": task_name,
|
"AYON_TASK_NAME": task_name,
|
||||||
"AYON_WORKDIR": workdir,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update the Session and environments. Pop from environments all
|
# Update the Session and environments. Pop from environments all
|
||||||
|
|
@ -360,8 +348,8 @@ class HostBase(ABC):
|
||||||
project_entity: dict[str, Any],
|
project_entity: dict[str, Any],
|
||||||
folder_entity: Optional[dict[str, Any]],
|
folder_entity: Optional[dict[str, Any]],
|
||||||
task_entity: Optional[dict[str, Any]],
|
task_entity: Optional[dict[str, Any]],
|
||||||
anatomy: "Anatomy",
|
|
||||||
reason: Optional[str],
|
reason: Optional[str],
|
||||||
|
anatomy: "Anatomy",
|
||||||
):
|
):
|
||||||
"""Before context is changed.
|
"""Before context is changed.
|
||||||
|
|
||||||
|
|
@ -382,8 +370,8 @@ class HostBase(ABC):
|
||||||
project_entity: dict[str, Any],
|
project_entity: dict[str, Any],
|
||||||
folder_entity: dict[str, Any],
|
folder_entity: dict[str, Any],
|
||||||
task_entity: dict[str, Any],
|
task_entity: dict[str, Any],
|
||||||
anatomy: "Anatomy",
|
|
||||||
reason: Optional[str],
|
reason: Optional[str],
|
||||||
|
anatomy: "Anatomy",
|
||||||
):
|
):
|
||||||
"""After context is changed.
|
"""After context is changed.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -326,9 +326,7 @@ class IWorkfileHost:
|
||||||
folder_entity,
|
folder_entity,
|
||||||
task_entity,
|
task_entity,
|
||||||
reason=WORKFILE_SAVE_REASON,
|
reason=WORKFILE_SAVE_REASON,
|
||||||
workdir=workdir,
|
|
||||||
project_entity=project_entity,
|
project_entity=project_entity,
|
||||||
project_settings=project_settings,
|
|
||||||
anatomy=anatomy,
|
anatomy=anatomy,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -398,9 +396,7 @@ class IWorkfileHost:
|
||||||
folder_entity,
|
folder_entity,
|
||||||
task_entity,
|
task_entity,
|
||||||
reason=WORKFILE_OPEN_REASON,
|
reason=WORKFILE_OPEN_REASON,
|
||||||
workdir=workdir,
|
|
||||||
project_entity=project_entity,
|
project_entity=project_entity,
|
||||||
project_settings=project_settings,
|
|
||||||
anatomy=anatomy,
|
anatomy=anatomy,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -524,11 +524,11 @@ def change_current_context(
|
||||||
This updates the live Session to a different task under folder.
|
This updates the live Session to a different task under folder.
|
||||||
|
|
||||||
Notes:
|
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.
|
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',
|
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.
|
logic.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|
@ -572,9 +572,8 @@ def change_current_context(
|
||||||
folder_entity,
|
folder_entity,
|
||||||
task_entity,
|
task_entity,
|
||||||
reason=reason,
|
reason=reason,
|
||||||
anatomy=anatomy,
|
|
||||||
project_entity=project_entity,
|
project_entity=project_entity,
|
||||||
project_settings=project_settings,
|
anatomy=anatomy,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue