-
Notifications
You must be signed in to change notification settings - Fork 127
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
Global: supporting OPENPYPE_TMPDIR
in staging dir maker
#4398
Conversation
…ber-of-shots-fill-up-disk
so it supports `OPENPYPE_TEMP_DIR` with anatomy formatting keys
it is already available in more expanded feature at parent class
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice feature! :)
Is it to be expected that there are no Studio Settings to set the temp dir and its up to the machine itself to "choose" the temp directory by setting a global OPENPYPE_TEMP_DIR
variable from outside of OpenPype itself?
I like that a particular user/machine can set its own custom temporary directory, e.g. for if that machine has a strong local cache disk to use. But I felt that with the complex formatting that is possible using anatomy this feels more like a studio setting of sorts with a potential override in local settings?
Anyway, only other thing I'm worried about is that it breaks some logic I had set up for Substance Painter. In particular this line of code of using publish.get_instance_staging_dir(instance)
from within a Collector because that is in a CollectorOrder BEFORE instance.context.data["anatomy"]
already exists. Keeping that in mind this might be a change breaking other areas of code too.
EDIT:
Missing documentation!
Also, this feature must have a mention in the documentation too. So please make sure the Admin Docs contain an explicit mention about the feature and how it's intended to be used by a studio or artist.
Yes that was the idea. Yes the documentation would be important for this. |
Few comments:
def _format_tempdir(temp_dir, project_name, anatomy):
if "{" not in temp_dir:
return temp_dir
if anatomy is None:
anatomy = Anatomy(project_name)
data = {
"root": anatomy.roots,
"project": {
"name": project_name,
"code": anatomy.project_code
}
}
return StringTemplate.format_template(temp_dir, data).normalized()
def create_tempdir(project_name, anatomy=None, prefix=None):
if prefix is None:
prefix = "op_tmp_"
kwargs = {"prefix": prefix}
openpype_temp_dir = os.getenv("OPENPYPE_TMPDIR")
if openpype_temp_dir:
openpype_temp_dir = _format_tempdir(
openpype_temp_dir,
project_name,
anatomy
)
if not os.path.exists(openpype_temp_dir):
os.makedirs(openpype_temp_dir)
kwargs["dir"] = openpype_temp_dir
return os.path.normpath(
tempfile.mkdtemp(**kwargs)
) |
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small typos.
Question - shouldn't this be set per context? I mean - it would be useful to influence the staging dir per family (or asset). Considering cases like special share for transient renders or big caches...
It is still creating subdirectories in the temp dir, and must create them because of filename clashes. |
Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>
Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>
Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>
Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>
Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>
Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>
Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>
Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>
Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>
This is unfortunately breaking Python 2 hosts. |
Brief description
Productions can use OPENPYPE_TMPDIR for staging temp publishing directory
Description
Studios were demanding to be able to configure their own shared storages as temporary staging directories.
Template formatting is also supported with optional keys formatting and following anatomy keys:
- root[work | ]
- project[name | code]
Documentation:
future documentataion url
Testing notes:
OPENPYPE_TMPDIR
on a testing project with{root[work]}/{project[name]}/temp