From f47c0b4027eccc0ce17962c3298a21f5ce3745d0 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 29 Apr 2025 16:21:40 +0800 Subject: [PATCH 01/15] If there is no valid review representation for thumbnail creation, make sure the representation is with the image content so that it can create thumbnail --- .../plugins/publish/extract_thumbnail.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index b72862ea22..adcd7be846 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -17,7 +17,7 @@ from ayon_core.lib import ( ) from ayon_core.lib.transcoding import convert_colorspace -from ayon_core.lib.transcoding import VIDEO_EXTENSIONS +from ayon_core.lib.transcoding import VIDEO_EXTENSIONS, IMAGE_EXTENSIONS class ExtractThumbnail(pyblish.api.InstancePlugin): @@ -349,7 +349,8 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): continue if "review" not in tags: - continue + if not self._is_valid_media_repre(repre): + continue if not repre.get("files"): self.log.debug(( @@ -360,6 +361,21 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): filtered_repres.append(repre) return filtered_repres + def _is_valid_media_repre(self, repre): + """Check if representation contains valid media files""" + files = repre.get("files") + if not files: + return False + + # Get first file's extension + if isinstance(files, (list, tuple)): + first_file = files[0] + else: + first_file = files + + ext = os.path.splitext(first_file)[1].lower() + return ext in IMAGE_EXTENSIONS + def _create_thumbnail_oiio( self, src_path, From 59e986dde23fb53cac335ca454b7405d9579ec1e Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 29 Apr 2025 16:23:27 +0800 Subject: [PATCH 02/15] add debug message into self._is_valid_media_repre --- client/ayon_core/plugins/publish/extract_thumbnail.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index adcd7be846..47710de5f6 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -365,6 +365,9 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): """Check if representation contains valid media files""" files = repre.get("files") if not files: + self.log.debug(( + "Representation \"{}\" doesn't have files. Skipping" + ).format(repre["name"])) return False # Get first file's extension From 637b157fd387c5d7943c2f57ec3508aaa79a3823 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 29 Apr 2025 16:24:28 +0800 Subject: [PATCH 03/15] rename self._is_valid_media_repre to self._is_valid_image_repre --- client/ayon_core/plugins/publish/extract_thumbnail.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 47710de5f6..b48e6a69b7 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -349,7 +349,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): continue if "review" not in tags: - if not self._is_valid_media_repre(repre): + if not self._is_valid_images_repre(repre): continue if not repre.get("files"): @@ -361,8 +361,8 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): filtered_repres.append(repre) return filtered_repres - def _is_valid_media_repre(self, repre): - """Check if representation contains valid media files""" + def _is_valid_images_repre(self, repre): + """Check if representation contains valid image files""" files = repre.get("files") if not files: self.log.debug(( From 625e782d7e2065bde600f3cd6c99387b411a3d10 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 29 Apr 2025 16:32:17 +0800 Subject: [PATCH 04/15] improve the docstring --- client/ayon_core/plugins/publish/extract_thumbnail.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index b48e6a69b7..6e0d899f30 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -362,7 +362,14 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): return filtered_repres def _is_valid_images_repre(self, repre): - """Check if representation contains valid image files""" + """Check if representation contains valid image files + + Args: + repre (dict): representation + + Returns: + bool: whether the representation has the valid image content + """ files = repre.get("files") if not files: self.log.debug(( From c0db02f7b519eb36ab249f60d5c122053cca862d Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 29 Apr 2025 17:14:14 +0800 Subject: [PATCH 05/15] improve the check on the valid representations for thumbnail creation --- .../plugins/publish/extract_thumbnail.py | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 6e0d899f30..cb941a53a9 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -336,7 +336,8 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): return need_thumb_repres def _get_filtered_repres(self, instance): - filtered_repres = [] + review_repres = [] + other_repres = [] src_repres = instance.data.get("representations") or [] for repre in src_repres: @@ -348,18 +349,22 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): # to be published locally continue - if "review" not in tags: - if not self._is_valid_images_repre(repre): - continue - if not repre.get("files"): self.log.debug(( "Representation \"{}\" doesn't have files. Skipping" ).format(repre["name"])) continue - filtered_repres.append(repre) - return filtered_repres + has_review_tag = "review" in tags + if not has_review_tag and not self._is_valid_images_repre(repre): + continue + + if has_review_tag: + review_repres.append(repre) + else: + other_repres.append(repre) + + return review_repres + other_repres def _is_valid_images_repre(self, repre): """Check if representation contains valid image files @@ -372,9 +377,6 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): """ files = repre.get("files") if not files: - self.log.debug(( - "Representation \"{}\" doesn't have files. Skipping" - ).format(repre["name"])) return False # Get first file's extension @@ -384,7 +386,8 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): first_file = files ext = os.path.splitext(first_file)[1].lower() - return ext in IMAGE_EXTENSIONS + + return ext in IMAGE_EXTENSIONS or ext in VIDEO_EXTENSIONS def _create_thumbnail_oiio( self, From 4bb0e14106cb65e5937225695ef336c5e87a3a1d Mon Sep 17 00:00:00 2001 From: Kayla Man <64118225+moonyuet@users.noreply.github.com> Date: Tue, 29 Apr 2025 19:10:01 +0800 Subject: [PATCH 06/15] Update client/ayon_core/plugins/publish/extract_thumbnail.py Co-authored-by: Roy Nieterau --- client/ayon_core/plugins/publish/extract_thumbnail.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index cb941a53a9..9592264ee2 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -356,12 +356,9 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): continue has_review_tag = "review" in tags - if not has_review_tag and not self._is_valid_images_repre(repre): - continue - if has_review_tag: review_repres.append(repre) - else: + elif self._is_valid_images_repre(repre): other_repres.append(repre) return review_repres + other_repres From 212a918b3151b9d69ec0eafc69f911b61561e259 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:25:49 +0200 Subject: [PATCH 07/15] added base ruff config file --- ruff.toml | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 ruff.toml diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000000..153a5c7d88 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,74 @@ +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +# Same as Black. +line-length = 79 +indent-width = 4 + +[lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E", "F", "W"] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" From 644f79bf0d67341f05474240840fe129faa459eb Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:29:17 +0200 Subject: [PATCH 08/15] added specific ignores --- ruff.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ruff.toml b/ruff.toml index 153a5c7d88..e94728c0fc 100644 --- a/ruff.toml +++ b/ruff.toml @@ -26,6 +26,8 @@ exclude = [ "node_modules", "site-packages", "venv", + "vendor", + "generated", ] # Same as Black. @@ -46,6 +48,14 @@ unfixable = [] # Allow unused variables when underscore-prefixed. dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" +exclude = [ + "client/ayon_core/modules/click_wrap.py", + "client/ayon_core/scripts/slates/__init__.py" +] + +[lint.per-file-ignores] +"client/ayon_core/lib/__init__.py" = ["E402"] + [format] # Like Black, use double quotes for strings. quote-style = "double" From 79dbdb38e2c682a126d0c7f75aad00f6ecabef02 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:29:36 +0200 Subject: [PATCH 09/15] added linting details --- ruff.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ruff.toml b/ruff.toml index e94728c0fc..49dd7a8c17 100644 --- a/ruff.toml +++ b/ruff.toml @@ -35,9 +35,9 @@ line-length = 79 indent-width = 4 [lint] +preview = true +pydocstyle.convention = "google" # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. -# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or -# McCabe complexity (`C901`) by default. select = ["E", "F", "W"] ignore = [] From 9f7f1ed314d6e2419b587053229e2bb870812765 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:29:43 +0200 Subject: [PATCH 10/15] added target python --- ruff.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ruff.toml b/ruff.toml index 49dd7a8c17..701055a65a 100644 --- a/ruff.toml +++ b/ruff.toml @@ -34,6 +34,9 @@ exclude = [ line-length = 79 indent-width = 4 +# Assume Python 3.9 +target-version = "py39" + [lint] preview = true pydocstyle.convention = "google" From 87514ba2e30a13e30d2bccfe6db6bd5962a87b8c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:30:02 +0200 Subject: [PATCH 11/15] remove ruff config from pyproject.toml --- pyproject.toml | 76 -------------------------------------------------- 1 file changed, 76 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4c4272cc30..309b0f91a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,82 +41,6 @@ pymdown-extensions = "^10.14.3" mike = "^2.1.3" mkdocstrings-shell = "^1.0.2" - -[tool.ruff] -# Exclude a variety of commonly ignored directories. -exclude = [ - ".bzr", - ".direnv", - ".eggs", - ".git", - ".git-rewrite", - ".hg", - ".ipynb_checkpoints", - ".mypy_cache", - ".nox", - ".pants.d", - ".pyenv", - ".pytest_cache", - ".pytype", - ".ruff_cache", - ".svn", - ".tox", - ".venv", - ".vscode", - "__pypackages__", - "_build", - "buck-out", - "build", - "dist", - "node_modules", - "site-packages", - "venv", - "vendor", - "generated", -] - -# Same as Black. -line-length = 79 -indent-width = 4 - -# Assume Python 3.9 -target-version = "py39" - -[tool.ruff.lint] -preview = true -pydocstyle.convention = "google" -# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. -select = ["E", "F", "W"] -ignore = [] - -# Allow fix for all enabled rules (when `--fix`) is provided. -fixable = ["ALL"] -unfixable = [] - -# Allow unused variables when underscore-prefixed. -dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" - -exclude = [ - "client/ayon_core/modules/click_wrap.py", - "client/ayon_core/scripts/slates/__init__.py" -] - -[tool.ruff.lint.per-file-ignores] -"client/ayon_core/lib/__init__.py" = ["E402"] - -[tool.ruff.format] -# Like Black, use double quotes for strings. -quote-style = "double" - -# Like Black, indent with spaces, rather than tabs. -indent-style = "space" - -# Like Black, respect magic trailing commas. -skip-magic-trailing-comma = false - -# Like Black, automatically detect the appropriate line ending. -line-ending = "auto" - [tool.codespell] # Ignore words that are not in the dictionary. ignore-words-list = "ayon,ynput,parms,parm,hda,developpement" From 2cb2a71e51e37614a12fc0c23378b61d57eee716 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:31:07 +0200 Subject: [PATCH 12/15] remove outdated paths --- pyproject.toml | 2 +- ruff.toml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 309b0f91a1..51f6048d8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ ignore-words-list = "ayon,ynput,parms,parm,hda,developpement" # Remove with next codespell release (>2.2.6) ignore-regex = ".*codespell:ignore.*" -skip = "./.*,./package/*,*/vendor/*,*/unreal/integration/*,*/aftereffects/api/extension/js/libs/*" +skip = "./.*,./package/*,*/client/ayon_core/vendor/*" count = true quiet-level = 3 diff --git a/ruff.toml b/ruff.toml index 701055a65a..f9b073e818 100644 --- a/ruff.toml +++ b/ruff.toml @@ -52,7 +52,6 @@ unfixable = [] dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" exclude = [ - "client/ayon_core/modules/click_wrap.py", "client/ayon_core/scripts/slates/__init__.py" ] From 591bf7c57be83a34677e4df720a42dd02d6b6017 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Apr 2025 14:01:01 +0200 Subject: [PATCH 13/15] bump ruff version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 51f6048d8a..3d85c30eda 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ pytest = "^8.0" pytest-print = "^1.0" ayon-python-api = "^1.0" # linting dependencies -ruff = "^0.3.3" +ruff = "0.11.7" pre-commit = "^3.6.2" codespell = "^2.2.6" semver = "^3.0.2" From c32cdba660ae1d30bfb22831cb3d63dfec325d82 Mon Sep 17 00:00:00 2001 From: Kayla Man <64118225+moonyuet@users.noreply.github.com> Date: Tue, 29 Apr 2025 20:40:50 +0800 Subject: [PATCH 14/15] Update client/ayon_core/plugins/publish/extract_thumbnail.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/plugins/publish/extract_thumbnail.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 9592264ee2..f67c571c90 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -372,15 +372,10 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): Returns: bool: whether the representation has the valid image content """ - files = repre.get("files") - if not files: - return False - # Get first file's extension - if isinstance(files, (list, tuple)): - first_file = files[0] - else: - first_file = files + first_file = repre["files"] + if isinstance(first_file, (list, tuple)): + first_file = first_file[0] ext = os.path.splitext(first_file)[1].lower() From 6d517d5e87074d7b4d4295c96e9bb405b36306b2 Mon Sep 17 00:00:00 2001 From: Kayla Man <64118225+moonyuet@users.noreply.github.com> Date: Tue, 29 Apr 2025 20:41:01 +0800 Subject: [PATCH 15/15] Update client/ayon_core/plugins/publish/extract_thumbnail.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/plugins/publish/extract_thumbnail.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index f67c571c90..3a428c46a7 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -355,8 +355,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): ).format(repre["name"])) continue - has_review_tag = "review" in tags - if has_review_tag: + if "review" in tags: review_repres.append(repre) elif self._is_valid_images_repre(repre): other_repres.append(repre)