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

Global: supporting OPENPYPE_TMPDIR in staging dir maker #4398

Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a574620
Merge branch 'develop' into feature/OP-3663_Hiero-export-of-large-num…
jakubjezek001 Jan 30, 2023
c8fb00c
global: expanding staging dir maker abstraction
jakubjezek001 Jan 30, 2023
ef86f14
global: update docstrings at `get_instance_staging_dir`
jakubjezek001 Jan 30, 2023
43399a0
flame: removing class override for staging dir creation
jakubjezek001 Jan 30, 2023
4dc9fad
Update openpype/pipeline/publish/lib.py
jakubjezek001 Jan 30, 2023
a9cc081
global: refactor code for better readibility
jakubjezek001 Jan 30, 2023
e10859d
pr comments
jakubjezek001 Feb 1, 2023
b2ed65c
pr comments
jakubjezek001 Feb 1, 2023
76ab705
added documenation
jakubjezek001 Feb 1, 2023
a3c9f79
refactor tempdir creator function wip
jakubjezek001 Feb 9, 2023
304d758
renaming module for temporarydir, fixing docstring
jakubjezek001 Feb 9, 2023
5de967b
updated documentation
jakubjezek001 Feb 9, 2023
d774eab
end line added
jakubjezek001 Feb 9, 2023
1656894
typo
jakubjezek001 Feb 10, 2023
da46873
Merge branch 'develop' into feature/OP-3663_Hiero-export-of-large-num…
jakubjezek001 Feb 10, 2023
87f9cf0
Update openpype/pipeline/temporarydir.py
jakubjezek001 Feb 10, 2023
bbd634b
Update openpype/pipeline/publish/lib.py
jakubjezek001 Feb 10, 2023
af3c0cb
pr comments
jakubjezek001 Feb 10, 2023
69937c6
Update openpype/pipeline/publish/lib.py
jakubjezek001 Feb 10, 2023
be0209e
refactor in favour of code changes from #4445
jakubjezek001 Feb 10, 2023
3927dc1
adding back project name
jakubjezek001 Feb 10, 2023
f458fbc
Update openpype/pipeline/tempdir.py
jakubjezek001 Feb 10, 2023
09dff16
Update openpype/pipeline/tempdir.py
jakubjezek001 Feb 13, 2023
8daa805
Update openpype/pipeline/tempdir.py
jakubjezek001 Feb 13, 2023
1980509
Update openpype/pipeline/tempdir.py
jakubjezek001 Feb 13, 2023
053a903
Update openpype/pipeline/tempdir.py
jakubjezek001 Feb 13, 2023
7ea78fe
Update openpype/pipeline/tempdir.py
jakubjezek001 Feb 13, 2023
8598631
Update openpype/pipeline/publish/lib.py
jakubjezek001 Feb 13, 2023
1735d6c
Update openpype/pipeline/publish/lib.py
jakubjezek001 Feb 13, 2023
abe8032
Update website/docs/admin_environment.md
jakubjezek001 Feb 13, 2023
3885f3c
Update website/docs/admin_settings_system.md
jakubjezek001 Feb 13, 2023
9591d42
spell errors
jakubjezek001 Feb 13, 2023
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
27 changes: 0 additions & 27 deletions openpype/hosts/flame/plugins/publish/extract_subset_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,30 +548,3 @@ def import_clip(self, path):
"Path `{}` is containing more that one clip".format(path)
)
return clips[0]

def staging_dir(self, instance):
"""Provide a temporary directory in which to store extracted files

Upon calling this method the staging directory is stored inside
the instance.data['stagingDir']
"""
staging_dir = instance.data.get('stagingDir', None)
openpype_temp_dir = os.getenv("OPENPYPE_TEMP_DIR")

if not staging_dir:
if openpype_temp_dir and os.path.exists(openpype_temp_dir):
staging_dir = os.path.normpath(
tempfile.mkdtemp(
prefix="pyblish_tmp_",
dir=openpype_temp_dir
)
)
else:
staging_dir = os.path.normpath(
tempfile.mkdtemp(prefix="pyblish_tmp_")
)
instance.data['stagingDir'] = staging_dir

instance.context.data["cleanupFullPaths"].append(staging_dir)

return staging_dir
76 changes: 70 additions & 6 deletions openpype/pipeline/publish/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
import pyblish.plugin
import pyblish.api

from openpype.lib import Logger, filter_profiles
from openpype.lib import (
Logger,
filter_profiles,
StringTemplate
)
from openpype.settings import (
get_project_settings,
get_system_settings,
Expand Down Expand Up @@ -609,8 +613,22 @@ def context_plugin_should_run(plugin, context):
def get_instance_staging_dir(instance):
"""Unified way how staging dir is stored and created on instances.

First check if 'stagingDir' is already set in instance data. If there is
not create new in tempdir.
First check if 'stagingDir' is already set in instance data.
In case there already is new tempdir will not be created.

It also supports `OPENPYPE_TEMP_DIR`, so studio can define own temp
shared repository per project or even per more granular context.
Template formating is supported also with optional keys. Folder is
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
created in case it doesnt exists.

Available anatomy formatting keys:
- root[work | <root name key>]
- project[name | code]
- asset
- hierarchy
- task
- username
- app

Note:
Staging dir does not have to be necessarily in tempdir so be carefull
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -623,12 +641,58 @@ def get_instance_staging_dir(instance):
Returns:
str: Path to staging dir of instance.
"""
staging_dir = instance.data.get('stagingDir')
if staging_dir:
return staging_dir

openpype_temp_dir = os.getenv("OPENPYPE_TEMP_DIR")
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
custom_temp_dir = None
if openpype_temp_dir:
if "{" in openpype_temp_dir:
custom_temp_dir = _formated_staging_dir(
instance, openpype_temp_dir
)
elif os.path.exists(openpype_temp_dir):
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
custom_temp_dir = openpype_temp_dir

staging_dir = instance.data.get("stagingDir")
if not staging_dir:

if custom_temp_dir:
staging_dir = os.path.normpath(
tempfile.mkdtemp(
prefix="pyblish_tmp_",
dir=custom_temp_dir
)
)
else:
staging_dir = os.path.normpath(
tempfile.mkdtemp(prefix="pyblish_tmp_")
)
instance.data["stagingDir"] = staging_dir
instance.data['stagingDir'] = staging_dir

instance.context.data["cleanupFullPaths"].append(staging_dir)
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved

return staging_dir


def _formated_staging_dir(instance, openpype_temp_dir):
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
anatomy = instance.context.data["anatomy"]
# get anatomy formating data
# so template formating is supported
anatomy_data = copy.deepcopy(instance.context.data["anatomyData"])
anatomy_data["root"] = anatomy.roots
"""Template path formatting is supporting:
- optional key formating
- available keys:
- root[work | <root name key>]
- project[name | code]
- asset
- hierarchy
- task
- username
- app
"""
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
result = StringTemplate.format_template(openpype_temp_dir, anatomy_data)
result = os.path.normpath(result)
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
# create the dir in case it doesnt exists
os.makedirs(os.path.dirname(result))
return result