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

Cosmetics + minor optimization for CleanUp plugin #1086

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
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
31 changes: 17 additions & 14 deletions client/ayon_core/plugins/publish/cleanup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# -*- coding: utf-8 -*-
"""Cleanup leftover files from publish."""
import os
import re
import shutil
import tempfile

import pyblish.api
import re

from ayon_core.lib import is_in_tests
from ayon_core.pipeline import PublishError


class CleanUp(pyblish.api.InstancePlugin):
Expand Down Expand Up @@ -48,17 +51,15 @@ def process(self, instance):
if is_in_tests():
# let automatic test process clean up temporary data
return
# Get the errored instances
failed = []

# If instance has errors, do not clean up
for result in instance.context.data["results"]:
if (result["error"] is not None and result["instance"] is not None
and result["instance"] not in failed):
failed.append(result["instance"])
assert instance not in failed, (
"Result of '{}' instance were not success".format(
instance.data["name"]
)
)
if result["error"] is not None and result["instance"] is instance:
raise PublishError(
"Result of '{}' instance were not success".format(
instance.data["name"]
)
)

_skip_cleanup_filepaths = instance.context.data.get(
"skipCleanupFilepaths"
Expand All @@ -71,10 +72,12 @@ def process(self, instance):
self.log.debug("Cleaning renders new...")
self.clean_renders(instance, skip_cleanup_filepaths)

if [ef for ef in self.exclude_families
if instance.data["productType"] in ef]:
product_type = instance.data["productType"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh lord, this plugin...

This condition should probably happen before error checks. And we should change exclude_families to exclude_product_types.

I don't know why there was "str in str" check instead of "str == str"? I guess that is question for @jakubjezek001 who might be able to tell if there are product types that should be skipped too and contain "clip"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh lord, this plugin...

Thank for sharing my feelings 🙉 🙈 🙊

if product_type in self.exclude_families:
self.log.debug(
"Skipping cleanup for instance because product "
f"type is excluded from cleanup: {product_type}")
return
import tempfile

temp_root = tempfile.gettempdir()
staging_dir = instance.data.get("stagingDir", None)
Expand Down
Loading