General: Functions for current context #4324
Merged
+100
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Brief description
Defined more functions to receive current context information and added the methods to host integration so host can affect the result.
Description
This is one of steps to reduce usage of
legacy_io.Session
. This change define how to receive current context information -> call functions instead of accessinglegacy_io.Session
oros.environ
directly. Plus, direct access on session or environments is unfortunatelly not enough for some DCCs where multiple workfiles can be opened at one time which can heavily affect the context but host integration sometimes can't affect that at all.HostBase
already had implementedget_current_context
, that was enhanced by adding more specific methodsget_current_project_name
,get_current_asset_name
andget_current_task_name
. The same functions were added to~/openpype/pipeline/cotext_tools.py
. The functions in context tools are calling host integration methods (if are available) otherwise are using environent variables as default implementation does. Also was addedget_current_host_name
to receive host name from registered host if is available or from environment variable.Additional info
Didn't change usages of
legacy_io.Session
anywhere. We should make a decision and agree on an approach and then start replace current usages. Anyway there must be backwards compatibility for some time.Possible changes
legacy_io.Session
instead ofos.environ
. But I wanted to avoid that as the goal is to reduce usage oflegacy_io
. Those functions are for "reading", "change" of current context in legacy_io is changing environemnts too (if does not then it should).set_current_context
function to replacechange_current_context
and some logic in workfiles tool.Testing notes:
It's more about decisions. Any comments are welcome